mohammadKa143 commited on
Commit
0d4c240
·
verified ·
1 Parent(s): aa65258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -6,6 +6,9 @@ import yaml
6
  from tools.final_answer import FinalAnswerTool
7
  import os
8
  from Gradio_UI import GradioUI
 
 
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
@@ -17,7 +20,24 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
17
  arg2: the second argument
18
  """
19
  return "What magic will you build ?"
 
 
 
 
 
20
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -75,7 +95,7 @@ with open("prompts.yaml", 'r') as stream:
75
 
76
  agent = CodeAgent(
77
  model=gemini_model,
78
- tools=[final_answer,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
79
  max_steps=6,
80
  verbosity_level=1,
81
  grammar=None,
 
6
  from tools.final_answer import FinalAnswerTool
7
  import os
8
  from Gradio_UI import GradioUI
9
+ from duckduckgo_search import DDGS
10
+
11
+
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
 
20
  arg2: the second argument
21
  """
22
  return "What magic will you build ?"
23
+
24
+ @tool
25
+ def search_duckduckgo(topic : str)-> list(str):
26
+ """
27
+ Searches DuckDuckGo for a given topic and returns a list of results.
28
 
29
+ Args:
30
+ topic: The topic to search for.
31
+
32
+ Returns:
33
+ A list of dictionaries, where each dictionary represents a search result
34
+ and contains keys like 'title', 'href', and 'body'.
35
+ """
36
+ results = DDGS().text(topic, max_results=10)
37
+ return results
38
+
39
+
40
+
41
  @tool
42
  def get_current_time_in_timezone(timezone: str) -> str:
43
  """A tool that fetches the current local time in a specified timezone.
 
95
 
96
  agent = CodeAgent(
97
  model=gemini_model,
98
+ tools=[final_answer,get_current_time_in_timezone,search_duckduckgo], ## add your tools here (don't remove final answer)
99
  max_steps=6,
100
  verbosity_level=1,
101
  grammar=None,