Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,18 +36,19 @@ model = OpenAIServerModel(
|
|
| 36 |
|
| 37 |
|
| 38 |
|
|
|
|
| 39 |
@tool
|
| 40 |
-
def simple_web_search(query: str, num_results: int =
|
| 41 |
"""
|
| 42 |
Performs a web search using DuckDuckGo's HTML interface.
|
| 43 |
|
| 44 |
Args:
|
| 45 |
-
query (str): The search term to look up
|
| 46 |
-
num_results (int): Maximum number of results to return
|
| 47 |
|
| 48 |
Returns:
|
| 49 |
-
str: JSON string containing search results
|
| 50 |
-
|
| 51 |
"""
|
| 52 |
try:
|
| 53 |
url = f"https://html.duckduckgo.com/html/?q={quote(query)}"
|
|
@@ -74,7 +75,6 @@ def simple_web_search(query: str, num_results: int = 3) -> str:
|
|
| 74 |
|
| 75 |
except Exception as e:
|
| 76 |
return json.dumps({"error": str(e)})
|
| 77 |
-
|
| 78 |
#simple_web_search = simple_web_search()
|
| 79 |
|
| 80 |
class BasicAgent:
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
+
|
| 40 |
@tool
|
| 41 |
+
def simple_web_search(query: str, num_results: int = 5) -> str:
|
| 42 |
"""
|
| 43 |
Performs a web search using DuckDuckGo's HTML interface.
|
| 44 |
|
| 45 |
Args:
|
| 46 |
+
query (str): The search term to look up. Example: "latest AI news".
|
| 47 |
+
num_results (int): Maximum number of results to return. Defaults to 3.
|
| 48 |
|
| 49 |
Returns:
|
| 50 |
+
str: JSON string containing search results with titles, links and snippets.
|
| 51 |
+
Example: [{"title": "...", "link": "...", "snippet": "..."}]
|
| 52 |
"""
|
| 53 |
try:
|
| 54 |
url = f"https://html.duckduckgo.com/html/?q={quote(query)}"
|
|
|
|
| 75 |
|
| 76 |
except Exception as e:
|
| 77 |
return json.dumps({"error": str(e)})
|
|
|
|
| 78 |
#simple_web_search = simple_web_search()
|
| 79 |
|
| 80 |
class BasicAgent:
|