Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,11 +13,15 @@ from langchain import HuggingFaceHub
|
|
| 13 |
import torch
|
| 14 |
import streamlit as st
|
| 15 |
from langchain.utilities import SerpAPIWrapper
|
|
|
|
| 16 |
import os
|
| 17 |
hf_token = os.environ['HF_TOKEN']
|
| 18 |
serp_token = os.environ['SERP_TOKEN']
|
| 19 |
repo_id = "sentence-transformers/all-mpnet-base-v2"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
HUGGINGFACEHUB_API_TOKEN= hf_token
|
| 22 |
hf = HuggingFaceHubEmbeddings(
|
| 23 |
repo_id=repo_id,
|
|
@@ -103,14 +107,19 @@ def main():
|
|
| 103 |
description="""Use this tool to answer document related questions. The input to this tool should be the question.""",
|
| 104 |
)
|
| 105 |
|
| 106 |
-
search = SerpAPIWrapper(serpapi_api_key=serp_token)
|
| 107 |
-
|
| 108 |
-
google_searchtool= Tool(
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
# tool for asking human
|
| 115 |
human_ask_tool = CustomAskHumanTool()
|
| 116 |
# agent prompt
|
|
@@ -120,7 +129,7 @@ def main():
|
|
| 120 |
# initialize agent
|
| 121 |
agent = initialize_agent(
|
| 122 |
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 123 |
-
tools=[db_search_tool,
|
| 124 |
llm=llm,
|
| 125 |
verbose=True,
|
| 126 |
max_iterations=5,
|
|
|
|
| 13 |
import torch
|
| 14 |
import streamlit as st
|
| 15 |
from langchain.utilities import SerpAPIWrapper
|
| 16 |
+
from langchain.tools import DuckDuckGoSearchRun
|
| 17 |
import os
|
| 18 |
hf_token = os.environ['HF_TOKEN']
|
| 19 |
serp_token = os.environ['SERP_TOKEN']
|
| 20 |
repo_id = "sentence-transformers/all-mpnet-base-v2"
|
| 21 |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
HUGGINGFACEHUB_API_TOKEN= hf_token
|
| 26 |
hf = HuggingFaceHubEmbeddings(
|
| 27 |
repo_id=repo_id,
|
|
|
|
| 107 |
description="""Use this tool to answer document related questions. The input to this tool should be the question.""",
|
| 108 |
)
|
| 109 |
|
| 110 |
+
# search = SerpAPIWrapper(serpapi_api_key=serp_token)
|
| 111 |
+
|
| 112 |
+
# google_searchtool= Tool(
|
| 113 |
+
# name="Current Search",
|
| 114 |
+
# func=search.run,
|
| 115 |
+
# description="use this tool to answer real time or current search related questions.",
|
| 116 |
+
# )
|
| 117 |
+
search = DuckDuckGoSearchRun()
|
| 118 |
+
search_tool = Tool(
|
| 119 |
+
name="search",
|
| 120 |
+
func=search,
|
| 121 |
+
description="use this tool to answer real time or current search related questions."
|
| 122 |
+
)
|
| 123 |
# tool for asking human
|
| 124 |
human_ask_tool = CustomAskHumanTool()
|
| 125 |
# agent prompt
|
|
|
|
| 129 |
# initialize agent
|
| 130 |
agent = initialize_agent(
|
| 131 |
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 132 |
+
tools=[db_search_tool,search_tool],
|
| 133 |
llm=llm,
|
| 134 |
verbose=True,
|
| 135 |
max_iterations=5,
|