Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import os
|
2 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
3 |
import datetime
|
4 |
import requests
|
@@ -11,37 +10,45 @@ from Gradio_UI import GradioUI
|
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
def find_best_receipt_websites(dish: str, agent: CodeAgent) -> str:
|
14 |
-
"""A tool that selects the best websites to seek for
|
|
|
15 |
Args:
|
16 |
-
dish:
|
|
|
|
|
|
|
|
|
17 |
"""
|
18 |
|
19 |
reasoning_prompt = f"""
|
20 |
-
Seek the top 3 websites that are most likely to have
|
21 |
Consider cultural habits.
|
22 |
"""
|
23 |
|
24 |
websites = agent.run_tool("final_answer", prompt=reasoning_prompt)
|
25 |
-
return "No suitable websites found"
|
26 |
|
27 |
@tool
|
28 |
-
def receipt(dish: str, persons: int, agent: CodeAgent) -> str:
|
29 |
-
|
30 |
|
31 |
-
"""A tool that calculates the ingredients for the number of dishes for persons
|
32 |
Args:
|
33 |
-
dish:
|
34 |
-
persons:
|
|
|
|
|
|
|
|
|
35 |
"""
|
36 |
websites = find_best_receipt_websites(dish, agent)
|
37 |
|
38 |
for website in websites.split(","):
|
39 |
reasoning_prompt = f"""
|
40 |
-
Seek the
|
41 |
"""
|
42 |
|
43 |
receipt = agent.run_tool("final_answer", prompt=reasoning_prompt)
|
44 |
-
return f"
|
45 |
|
46 |
@tool
|
47 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
|
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
def find_best_receipt_websites(dish: str, agent: CodeAgent) -> str:
|
13 |
+
"""A tool that selects the best websites to seek for the recipe of a dish.
|
14 |
+
|
15 |
Args:
|
16 |
+
dish: The target dish.
|
17 |
+
agent: The CodeAgent instance that will perform reasoning.
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
A string with the best websites for finding the recipe.
|
21 |
"""
|
22 |
|
23 |
reasoning_prompt = f"""
|
24 |
+
Seek the top 3 websites that are most likely to have the recipe for {dish}.
|
25 |
Consider cultural habits.
|
26 |
"""
|
27 |
|
28 |
websites = agent.run_tool("final_answer", prompt=reasoning_prompt)
|
29 |
+
return websites if websites else "No suitable websites found"
|
30 |
|
31 |
@tool
|
32 |
+
def receipt(dish: str, persons: int, agent: CodeAgent) -> str:
|
33 |
+
"""A tool that calculates the ingredients for a given dish and fetches its recipe.
|
34 |
|
|
|
35 |
Args:
|
36 |
+
dish: The target dish.
|
37 |
+
persons: The number of persons.
|
38 |
+
agent: The CodeAgent instance used for tool execution.
|
39 |
+
|
40 |
+
Returns:
|
41 |
+
A formatted string with the recipe details.
|
42 |
"""
|
43 |
websites = find_best_receipt_websites(dish, agent)
|
44 |
|
45 |
for website in websites.split(","):
|
46 |
reasoning_prompt = f"""
|
47 |
+
Seek the recipe of {dish} on the website {website.strip()}.
|
48 |
"""
|
49 |
|
50 |
receipt = agent.run_tool("final_answer", prompt=reasoning_prompt)
|
51 |
+
return f"Recipe is: {receipt}"
|
52 |
|
53 |
@tool
|
54 |
def get_current_time_in_timezone(timezone: str) -> str:
|