tresbien1 commited on
Commit
8dd5500
·
verified ·
1 Parent(s): d37eddb

Fixed functioncalls in search_tool

Browse files
Files changed (1) hide show
  1. app.py +10 -15
app.py CHANGED
@@ -62,28 +62,23 @@ def get_current_time_in_timezone(timezone: str) -> str:
62
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
63
 
64
  @tool
65
- def search_tool(query: str) -> str: # it's important to specify the return type
66
  """
67
- Search the web using DuckDuckGo. Only one input with one output
68
-
69
  Args:
70
  query: The search query string
71
  """
72
  try:
73
  if not query or not query.strip():
74
- raise ValueError("Query is empty")
75
-
76
- # assume DuckDuckGoSearch is already imported
77
- search = DuckDuckGoSearch()
78
- results = search.run(query)
79
-
80
- if not results:
81
- return "No results found."
82
-
83
- return f" The following results have been found '{results}'."
84
-
85
  except Exception as e:
86
- return f"Error during DuckDuckGo search: {e}"
87
 
88
  final_answer = FinalAnswerTool()
89
 
 
62
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
63
 
64
  @tool
65
+ def search_tool(query: str) -> str:
66
  """
67
+ Search the web using DuckDuckGo.
 
68
  Args:
69
  query: The search query string
70
  """
71
  try:
72
  if not query or not query.strip():
73
+ return "Query is empty"
74
+
75
+ search = DuckDuckGoSearchTool()
76
+
77
+ results = search.forward(query)
78
+
79
+ return f"The following results have been found: '{results}'"
 
 
 
 
80
  except Exception as e:
81
+ return f"Error during search: {e}"
82
 
83
  final_answer = FinalAnswerTool()
84