Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,7 +60,7 @@ def get_stock_price(stock: str) -> str:
|
|
| 60 |
return f"Error fetching price for stock '{stock}': {str(e)}"
|
| 61 |
|
| 62 |
@tool
|
| 63 |
-
def web_search(query: str) ->
|
| 64 |
"""Fetches the result from a web search.
|
| 65 |
|
| 66 |
Args:
|
|
@@ -78,12 +78,12 @@ def web_search(query: str) -> json:
|
|
| 78 |
|
| 79 |
# If search_results is a list, extract the first relevant result
|
| 80 |
if isinstance(search_results, list) and len(search_results) > 0:
|
| 81 |
-
return {search_results[0]}
|
| 82 |
|
| 83 |
-
return
|
| 84 |
|
| 85 |
except Exception as e:
|
| 86 |
-
return f"Error
|
| 87 |
|
| 88 |
|
| 89 |
|
|
|
|
| 60 |
return f"Error fetching price for stock '{stock}': {str(e)}"
|
| 61 |
|
| 62 |
@tool
|
| 63 |
+
def web_search(query: str) -> dict:
|
| 64 |
"""Fetches the result from a web search.
|
| 65 |
|
| 66 |
Args:
|
|
|
|
| 78 |
|
| 79 |
# If search_results is a list, extract the first relevant result
|
| 80 |
if isinstance(search_results, list) and len(search_results) > 0:
|
| 81 |
+
return {"query": query, "result": search_results[0]}
|
| 82 |
|
| 83 |
+
return {"query": query, "error": "No results found."}
|
| 84 |
|
| 85 |
except Exception as e:
|
| 86 |
+
return {"query": query, "error": f"Error during search: {str(e)}"}
|
| 87 |
|
| 88 |
|
| 89 |
|