Siqi commited on
Commit
33d4d05
·
1 Parent(s): 12ce35b

Fixed search tool

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
@@ -8,17 +8,18 @@ from tools.final_answer import FinalAnswerTool
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
12
- def my_search_tool(search_query:str)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- search_query: a string representing the search query user wants to search for
17
  """
18
  try:
19
  if not search_query or not search_query.strip():
20
- search_query = "Search for the latest popular arxiv papers in the field of reinforcement learning"
21
- result = DuckDuckGoSearchTool().run(search_query=search_query)
22
  except Exception as e:
23
  result = f"An error occurred while performing the search, error: {e}."
24
  print(f"Error occurred: {e}")
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
+ _search_tool = DuckDuckGoSearchTool()
12
+
13
  @tool
14
+ def my_search_tool(search_query: str) -> str:
15
+ """Search the web for information using DuckDuckGo.
 
16
  Args:
17
+ search_query: a string representing the search query to look up
18
  """
19
  try:
20
  if not search_query or not search_query.strip():
21
+ search_query = "latest popular arxiv papers in reinforcement learning"
22
+ result = _search_tool.run(search_query=search_query)
23
  except Exception as e:
24
  result = f"An error occurred while performing the search, error: {e}."
25
  print(f"Error occurred: {e}")