Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,30 +59,6 @@ def get_stock_price(stock: str) -> str:
|
|
| 59 |
except Exception as e:
|
| 60 |
return f"Error fetching price for stock '{stock}': {str(e)}"
|
| 61 |
|
| 62 |
-
from typing import Dict
|
| 63 |
-
|
| 64 |
-
@tool
|
| 65 |
-
def web_search(query: str) -> Dict[str, str]:
|
| 66 |
-
"""
|
| 67 |
-
Fetches the result from a web search using DuckDuckGo.
|
| 68 |
-
|
| 69 |
-
Args:
|
| 70 |
-
query (str): A search query or question.
|
| 71 |
-
|
| 72 |
-
Returns:
|
| 73 |
-
Dict[str, str]: A dictionary with either the result or an error message.
|
| 74 |
-
"""
|
| 75 |
-
try:
|
| 76 |
-
search_tool = DuckDuckGoSearchTool()
|
| 77 |
-
search_results = search_tool.run(query)
|
| 78 |
-
|
| 79 |
-
if isinstance(search_results, list) and len(search_results) > 0:
|
| 80 |
-
return {"query": query, "result": search_results[0]}
|
| 81 |
-
|
| 82 |
-
return {"query": query, "error": "No results found."}
|
| 83 |
-
|
| 84 |
-
except Exception as e:
|
| 85 |
-
return {"query": query, "error": f"Error during search: {str(e)}"}
|
| 86 |
|
| 87 |
|
| 88 |
final_answer = FinalAnswerTool()
|
|
|
|
| 59 |
except Exception as e:
|
| 60 |
return f"Error fetching price for stock '{stock}': {str(e)}"
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
final_answer = FinalAnswerTool()
|