Baldros commited on
Commit
b34abe5
·
verified ·
1 Parent(s): c8e174e

add internet search

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -47,6 +47,19 @@ def get_current_time_in_timezone(timezone: str) -> str:
47
  except Exception as e:
48
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  final_answer = FinalAnswerTool()
52
 
@@ -70,8 +83,9 @@ with open("prompts.yaml", 'r') as stream:
70
 
71
  agent = CodeAgent(
72
  model=model,
73
- tools=[final_answer, image_generation_tool,
74
- get_current_time_in_timezone,math_operation], ## add your tools here (don't remove final answer)
 
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,
 
47
  except Exception as e:
48
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
49
 
50
+ @tool
51
+ def internet_search(query: str) -> str:
52
+ """
53
+ A tool to search the internet using DuckDuckGo.
54
+
55
+ Args:
56
+ query: The search query.
57
+
58
+ Returns:
59
+ The top search result.
60
+ """
61
+ results = search_tool.run(query)
62
+ return results if results else "No results found."
63
 
64
  final_answer = FinalAnswerTool()
65
 
 
83
 
84
  agent = CodeAgent(
85
  model=model,
86
+ tools=[final_answer, image_generation_tool, ## add your tools here (don't remove final answer)
87
+ get_current_time_in_timezone,math_operation,
88
+ internet_search],
89
  max_steps=6,
90
  verbosity_level=1,
91
  grammar=None,