Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -122,6 +122,21 @@ class DocumentQuestionAnswering(BaseTool):
|
|
122 |
response = self.qa_chain.run(query)
|
123 |
return str(response)
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
# Function to handle different input types and choose the right tool
|
126 |
def handle_input(user_prompt, image=None, audio=None, websearch=False, document=None):
|
127 |
if audio:
|
|
|
122 |
response = self.qa_chain.run(query)
|
123 |
return str(response)
|
124 |
|
125 |
+
class DuckDuckGoSearchRun(BaseTool):
|
126 |
+
name = "DuckDuckGo"
|
127 |
+
description = "Useful for searching the internet for general information"
|
128 |
+
|
129 |
+
def _run(self, query: str) -> str:
|
130 |
+
url = "https://api.duckduckgo.com/"
|
131 |
+
params = {
|
132 |
+
"q": query,
|
133 |
+
"format": "json"
|
134 |
+
}
|
135 |
+
response = requests.get(url, params=params)
|
136 |
+
data = response.json()
|
137 |
+
answer = data["Abstract"]
|
138 |
+
return answer
|
139 |
+
|
140 |
# Function to handle different input types and choose the right tool
|
141 |
def handle_input(user_prompt, image=None, audio=None, websearch=False, document=None):
|
142 |
if audio:
|