Fix argument and doc string for search tool
Browse files
app.py
CHANGED
|
@@ -83,18 +83,18 @@ class BasicAgent:
|
|
| 83 |
|
| 84 |
def search_tool(self, question: str, max_length: int = 2048) -> str:
|
| 85 |
"""
|
| 86 |
-
Use DuckDuckGo’s
|
| 87 |
|
| 88 |
Args:
|
| 89 |
-
|
| 90 |
max_length: Max chars to return.
|
| 91 |
Returns:
|
| 92 |
-
|
| 93 |
"""
|
| 94 |
print(f"Calling search tool with: {question}, max_lentgh: {max_length}")
|
| 95 |
with DDGS() as ddgs:
|
| 96 |
-
hits = list(ddgs.text(
|
| 97 |
-
print("Got", hits)
|
| 98 |
ans = "\n".join((r.get("body") or r.get("snippet", "") for r in hits))
|
| 99 |
|
| 100 |
if not ans:
|
|
|
|
| 83 |
|
| 84 |
def search_tool(self, question: str, max_length: int = 2048) -> str:
|
| 85 |
"""
|
| 86 |
+
Use DuckDuckGo’s API to fetch a direct answer.
|
| 87 |
|
| 88 |
Args:
|
| 89 |
+
question: The question to ask.
|
| 90 |
max_length: Max chars to return.
|
| 91 |
Returns:
|
| 92 |
+
Answer text, or a fallback message.
|
| 93 |
"""
|
| 94 |
print(f"Calling search tool with: {question}, max_lentgh: {max_length}")
|
| 95 |
with DDGS() as ddgs:
|
| 96 |
+
hits = list(ddgs.text(question, max_results=5))
|
| 97 |
+
print("Got from DDGS:", hits)
|
| 98 |
ans = "\n".join((r.get("body") or r.get("snippet", "") for r in hits))
|
| 99 |
|
| 100 |
if not ans:
|