8PeopleINC commited on
Commit
4ee54b0
·
verified ·
1 Parent(s): e817ed1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -12,12 +12,29 @@ from Gradio_UI import GradioUI
12
  @tool
13
  def ddg_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
14
  # Keep this format for the tool description / args description but feel free to modify the tool
15
- """A tool that passes searches through duck duck go.
16
  Args:
17
- arg1: the first argument
18
- arg2: the second argument
19
  """
20
- return DDSG().text("Query Results", max_results=5)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
 
23
  @tool
 
12
  @tool
13
  def ddg_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
14
  # Keep this format for the tool description / args description but feel free to modify the tool
15
+ """A tool that searches for open restaraunts using DuckDuckGo search.
16
  Args:
17
+ query: The type of restaraunt or keyword (e.g. "italian").
18
+ location: The location the restaraunts are being searched.
19
  """
20
+ try:
21
+ search_tool = ddg_tool()
22
+ search_query = f"{query} restaraunts in {location}"
23
+
24
+ # Perform the search
25
+ results = search_tool(search_query)
26
+
27
+ # extract top links (if available)
28
+ food_links = [result['href'] for result in results if isinstance(results, dict) and 'href' in result][:5] #return top 5 links
29
+
30
+ if food_links:
31
+ return f"Here are some restaraunts ofr '{query}' in {location}:\n" +"\n".join(food_links)
32
+
33
+ else:
34
+ return "No restaraunts found near you."
35
+
36
+ except Exception as e:
37
+ return f"Error searching for food links: {str(e)}"
38
 
39
 
40
  @tool