Cheangys commited on
Commit
3643196
·
verified ·
1 Parent(s): 5211d8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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) -> json:
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 f"Could not find {query}. Please try again."
84
 
85
  except Exception as e:
86
- return f"Error finding '{query}': {str(e)}"
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