abhinav7891 commited on
Commit
d18663f
·
verified ·
1 Parent(s): a801362

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -10,13 +10,19 @@ 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 search_with_duckduckgo(query: str, num_results: int = 3) -> str:
14
  """Searches DuckDuckGo for the given query and returns the top results.
15
  Raises an exception if the search fails.
 
 
 
 
16
  """
17
  search_tool = DuckDuckGoSearchTool()
18
  try:
19
  results = search_tool.call(tool_input=f"{query} {num_results}")
 
20
  if not results or "No results found" in results.lower() or "error" in results.lower():
21
  raise ValueError("DuckDuckGo search failed to return valid results.")
22
  return results
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ @tool
14
  def search_with_duckduckgo(query: str, num_results: int = 3) -> str:
15
  """Searches DuckDuckGo for the given query and returns the top results.
16
  Raises an exception if the search fails.
17
+
18
+ Args:
19
+ query: The search query string. <-- Add description here
20
+ num_results: The number of search results to return (default is 3). <-- And here
21
  """
22
  search_tool = DuckDuckGoSearchTool()
23
  try:
24
  results = search_tool.call(tool_input=f"{query} {num_results}")
25
+ # Add a basic check for a successful result.
26
  if not results or "No results found" in results.lower() or "error" in results.lower():
27
  raise ValueError("DuckDuckGo search failed to return valid results.")
28
  return results