Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,40 @@ import requests
|
|
5 |
import pytz
|
6 |
import yaml
|
7 |
from tools.final_answer import FinalAnswerTool
|
|
|
8 |
|
9 |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
-
"""A tool that
|
16 |
Args:
|
17 |
-
|
18 |
-
|
19 |
"""
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
@tool
|
23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -57,7 +78,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
57 |
|
58 |
agent = CodeAgent(
|
59 |
model=model,
|
60 |
-
tools=[final_answer,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
61 |
max_steps=6,
|
62 |
verbosity_level=1,
|
63 |
grammar=None,
|
|
|
5 |
import pytz
|
6 |
import yaml
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
+
from tools.web_search import WebSearchTool
|
9 |
|
10 |
from Gradio_UI import GradioUI
|
11 |
|
12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
13 |
@tool
|
14 |
+
def find_best_receipt_websites(dish: str, agent: CodeAgent) -> str:
|
15 |
+
"""Agent selects the best websites to seek for receipt of dish."""
|
16 |
+
|
17 |
+
reasoning_prompt = f"""
|
18 |
+
Seek the top 3 websites that are most likely to have reciept of {dish}.
|
19 |
+
Consider cultural habits.
|
20 |
+
"""
|
21 |
+
|
22 |
+
websites = agent.run_tool("final_answer", prompt=reasoning_prompt)
|
23 |
+
return "No suitable websites found"
|
24 |
+
|
25 |
+
@tool
|
26 |
+
def receipt(dish: str, persons: int, agent: CodeAgent) -> str: #it's import to specify the return type
|
27 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
28 |
+
"""A tool that calculates the ingredients for the number of dishes for persons
|
29 |
Args:
|
30 |
+
dish: the target dish
|
31 |
+
persons: the number of persons
|
32 |
"""
|
33 |
+
websites = find_best_receipt_websites(dish, agent)
|
34 |
+
|
35 |
+
for website in websites.split(","):
|
36 |
+
reasoning_prompt = f"""
|
37 |
+
Seek the reciept of {dish} on the website {website}.
|
38 |
+
"""
|
39 |
+
|
40 |
+
receipt = agent.run_tool("final_answer", prompt=reasoning_prompt)
|
41 |
+
return f"Receipt is {receipt}"
|
42 |
|
43 |
@tool
|
44 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
78 |
|
79 |
agent = CodeAgent(
|
80 |
model=model,
|
81 |
+
tools=[final_answer,get_current_time_in_timezone,receipt,WebSearchTool,image_generation_tool], ## add your tools here (don't remove final answer)
|
82 |
max_steps=6,
|
83 |
verbosity_level=1,
|
84 |
grammar=None,
|