leghair commited on
Commit
a54ad81
·
verified ·
1 Parent(s): 9325db3

Update app.py

Browse files

Changed to DucKDuckgo search

Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -10,14 +10,17 @@ from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
- def wikipedia_summary(topic:str, sentences:int = 2)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
- """Fetch a summary from wikipedia for a given topic
16
  Args:
17
- topic: the subject to search on wikipedia
18
- sentences: the number of sentences to include in the summary
19
  """
20
- return wikipedia.summary(topic, sentences=sentences)
 
 
 
21
 
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -56,7 +59,7 @@ with open("prompts.yaml", 'r') as stream:
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer, wikipedia_summary], ## add your tools here (don't remove final answer)
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def search_duckduckgo(query:str, num_results:int = 3)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
+ """Search DuckDuckGo and return the top results
16
  Args:
17
+ query: The search term to look up
18
+ num_results: Number of search results to return (default is 3)
19
  """
20
+ # Format results into a readable string
21
+ formatted_results = "\n".join([f"{i+1}. {res['title']} - {res['url']}" for i, res in enumerate(results)])
22
+
23
+ return f"Top {num_results} search results for '{query}':\n{formatted_results}"
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
 
59
 
60
  agent = CodeAgent(
61
  model=model,
62
+ tools=[final_answer, search_duckduckgo], ## add your tools here (don't remove final answer)
63
  max_steps=6,
64
  verbosity_level=1,
65
  grammar=None,