Spaces:
Sleeping
Sleeping
ddg
Browse files- requirements.txt +2 -1
- tools.py +3 -2
requirements.txt
CHANGED
|
@@ -12,4 +12,5 @@ openai
|
|
| 12 |
duckduckgo-search
|
| 13 |
regex
|
| 14 |
pytesseract
|
| 15 |
-
openpyxl
|
|
|
|
|
|
| 12 |
duckduckgo-search
|
| 13 |
regex
|
| 14 |
pytesseract
|
| 15 |
+
openpyxl
|
| 16 |
+
duckduckgo-search
|
tools.py
CHANGED
|
@@ -9,6 +9,7 @@ from state import AgentState
|
|
| 9 |
from langchain.schema import HumanMessage
|
| 10 |
import regex as re
|
| 11 |
import time
|
|
|
|
| 12 |
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 14 |
|
|
@@ -49,13 +50,13 @@ def web_search_tool(state: AgentState) -> AgentState:
|
|
| 49 |
if not query:
|
| 50 |
return {} # nothing to do
|
| 51 |
|
| 52 |
-
|
| 53 |
max_retries = 5
|
| 54 |
result_text = ""
|
| 55 |
|
| 56 |
for attempt in range(1, max_retries + 1):
|
| 57 |
try:
|
| 58 |
-
result_text = ddg.run(query)
|
| 59 |
except Exception as e:
|
| 60 |
# Network error or timeout—retry up to max_retries
|
| 61 |
if attempt < max_retries:
|
|
|
|
| 9 |
from langchain.schema import HumanMessage
|
| 10 |
import regex as re
|
| 11 |
import time
|
| 12 |
+
from duckduckgo_search import ddg
|
| 13 |
|
| 14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 15 |
|
|
|
|
| 50 |
if not query:
|
| 51 |
return {} # nothing to do
|
| 52 |
|
| 53 |
+
|
| 54 |
max_retries = 5
|
| 55 |
result_text = ""
|
| 56 |
|
| 57 |
for attempt in range(1, max_retries + 1):
|
| 58 |
try:
|
| 59 |
+
result_text = ddg.run(query, max_results=5)
|
| 60 |
except Exception as e:
|
| 61 |
# Network error or timeout—retry up to max_retries
|
| 62 |
if attempt < max_retries:
|