corquaerit commited on
Commit
beec040
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files

inlcuded a resturant search tool

Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import yaml
6
  from tools.final_answer import FinalAnswerTool
7
 
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
@@ -33,6 +34,24 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
@@ -55,7 +74,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
+ from duckduckgo_search import DDGS
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
 
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
+ @tool
38
+ def ddg_tool(query:str, area:str, max_results:int=5) -> list:
39
+ """A tool that searches for restuarants in a particular location using DuckDuckGo search.
40
+ Args:
41
+ query:The type of restuarant cuisine or keyword (e.g mexican).
42
+ area: The city in which the restaurants are located in(e.g Paris).
43
+ max_results: Number of results to return, which is 5.
44
+ """
45
+ ddg_tool =DDGS()
46
+ full_query = f"{query} restuarant in {area}"
47
+
48
+ search_results =DDGS().text(full_query, max_results=max_results)
49
+ results= []
50
+ for result in search_results:
51
+ results.append(result)
52
+
53
+ return results
54
+
55
 
56
  final_answer = FinalAnswerTool()
57
 
 
74
 
75
  agent = CodeAgent(
76
  model=model,
77
+ tools=[final_answer, ddg_tool], ## add your tools here (don't remove final answer)
78
  max_steps=6,
79
  verbosity_level=1,
80
  grammar=None,