Louis-bou commited on
Commit
bcd86c6
·
verified ·
1 Parent(s): 54a9697

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool, WebSearchTool
2
  import datetime
3
  import requests
4
  import pytz
@@ -32,15 +32,15 @@ def web_search_DDG(query:str)-> str:
32
  if not results or "No results found" in results:
33
  return f"No answer was found to the request '{query}'. Please reformulate."
34
  return f"The answer for the question '{query}' is:\n\n{results}"
35
- except Exception as e:
36
  try:
37
- search_tool = WebSearchTool(engine="bing")
38
  results = search_tool(query)
39
  if not results or "No results found" in results:
40
  return f"No answer was found to the request '{query}'. Please reformulate."
41
  return f"The answer for the question '{query}' is:\n\n{results}"
42
- except Exception as e:
43
- return f"An unexpected issue occurred: {str(e)}"
44
 
45
 
46
  @tool
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool, GoogleSearchTool
2
  import datetime
3
  import requests
4
  import pytz
 
32
  if not results or "No results found" in results:
33
  return f"No answer was found to the request '{query}'. Please reformulate."
34
  return f"The answer for the question '{query}' is:\n\n{results}"
35
+ except Exception as e1:
36
  try:
37
+ search_tool = GoogleSearchTool(engine="bing")
38
  results = search_tool(query)
39
  if not results or "No results found" in results:
40
  return f"No answer was found to the request '{query}'. Please reformulate."
41
  return f"The answer for the question '{query}' is:\n\n{results}"
42
+ except Exception as e2:
43
+ return f"An unexpected issue occurred: {str(e1) + ' ' + str(e2)}"
44
 
45
 
46
  @tool