Refactor web_search function to remove max_results parameter and default to 5 results in DuckDuckGo search.
Browse files- __pycache__/agent.cpython-39.pyc +0 -0
- agent.py +3 -4
__pycache__/agent.cpython-39.pyc
CHANGED
|
Binary files a/__pycache__/agent.cpython-39.pyc and b/__pycache__/agent.cpython-39.pyc differ
|
|
|
agent.py
CHANGED
|
@@ -34,9 +34,9 @@ model = ChatGroq(
|
|
| 34 |
)
|
| 35 |
|
| 36 |
@tool
|
| 37 |
-
def web_search(keywords: str
|
| 38 |
"""
|
| 39 |
-
Uses duckduckgo to search the web
|
| 40 |
|
| 41 |
Use cases:
|
| 42 |
- Identify personal information
|
|
@@ -46,7 +46,6 @@ def web_search(keywords: str, max_results:int = 5) -> str:
|
|
| 46 |
|
| 47 |
Args:
|
| 48 |
keywords: keywords used to search the web
|
| 49 |
-
max_results: number of results to show after searching the web, defaults to 5
|
| 50 |
|
| 51 |
Returns:
|
| 52 |
Search result (Header + body + url)
|
|
@@ -54,7 +53,7 @@ def web_search(keywords: str, max_results:int = 5) -> str:
|
|
| 54 |
with DDGS() as ddgs:
|
| 55 |
# Perform a text search
|
| 56 |
output = ""
|
| 57 |
-
results = ddgs.text(keywords, max_results =
|
| 58 |
for result in results:
|
| 59 |
output += f"Results: {result['title']}\n{result['body']}\n{result['href']}\n\n"
|
| 60 |
return(output)
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
@tool
|
| 37 |
+
def web_search(keywords: str) -> str:
|
| 38 |
"""
|
| 39 |
+
Uses duckduckgo to search the top 5 result on web
|
| 40 |
|
| 41 |
Use cases:
|
| 42 |
- Identify personal information
|
|
|
|
| 46 |
|
| 47 |
Args:
|
| 48 |
keywords: keywords used to search the web
|
|
|
|
| 49 |
|
| 50 |
Returns:
|
| 51 |
Search result (Header + body + url)
|
|
|
|
| 53 |
with DDGS() as ddgs:
|
| 54 |
# Perform a text search
|
| 55 |
output = ""
|
| 56 |
+
results = ddgs.text(keywords, max_results = 5)
|
| 57 |
for result in results:
|
| 58 |
output += f"Results: {result['title']}\n{result['body']}\n{result['href']}\n\n"
|
| 59 |
return(output)
|