Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -581,12 +581,25 @@ def extract_ingredients(transcription: str) -> str:
|
|
581 |
|
582 |
def web_search(query: str) -> str:
|
583 |
print_coso(f"tool web_search con query: {query}")
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
|
591 |
def log_thought(thought: str) -> str:
|
592 |
print_coso(f"Tool log_thought: {thought}")
|
|
|
581 |
|
582 |
def web_search(query: str) -> str:
|
583 |
print_coso(f"tool web_search con query: {query}")
|
584 |
+
with DDGS() as ddgs:
|
585 |
+
results = ddgs.text(keywords = query, max_results=3)
|
586 |
+
if not results:
|
587 |
+
return "No results found."
|
588 |
+
formattedResult = "\n".join([f"{res['title']} - {res['href']}" for res in results])
|
589 |
+
print_coso(f"tool web_search formattedResult: {formattedResult}")
|
590 |
+
return formattedResult
|
591 |
+
'''
|
592 |
+
def web_search(query: str) -> str:
|
593 |
+
print_coso(f"tool web_search con query: {query}")
|
594 |
+
try:
|
595 |
+
with DDGS() as ddgs:
|
596 |
+
results = ddgs.text(query)
|
597 |
+
if not results:
|
598 |
+
return "No results found."
|
599 |
+
return "\n".join([r["body"] for r in results[:3]])
|
600 |
+
except Exception as e:
|
601 |
+
return f"Error: {e}"
|
602 |
+
'''
|
603 |
|
604 |
def log_thought(thought: str) -> str:
|
605 |
print_coso(f"Tool log_thought: {thought}")
|