Update app.py
Browse files
app.py
CHANGED
|
@@ -4,19 +4,31 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
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
|
| 12 |
-
def my_custom_tool(
|
| 13 |
-
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +67,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from tools.web
|
| 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 my_custom_tool(bread_type: str, cheese_type: str, meat: bool, lettuce: bool)-> str:
|
| 14 |
+
|
| 15 |
+
"""A tool that retrieves the calorie of the ingredients making up the sandwich.
|
| 16 |
Args:
|
| 17 |
+
bread_type: The type of bread (e.g: White bread, whole wheat bread, etc...)
|
| 18 |
+
cheese_type: The type of cheese (e.g: Mozzarella, etc..)
|
| 19 |
+
meat: Whether the sandwich should contain some commercially available ham.
|
| 20 |
+
lettuce: Whether the sandwich should contain a standard leaf of lettuce on it.
|
| 21 |
"""
|
| 22 |
+
|
| 23 |
+
params = locals()
|
| 24 |
+
search_tool = DuckDuckGoSearchTool(max_results=1)
|
| 25 |
+
info = ""
|
| 26 |
+
for param_name, param_value in params.items():
|
| 27 |
+
info += search_tool(f"Calorie of {param_value} {param_name}")
|
| 28 |
+
|
| 29 |
+
return info
|
| 30 |
+
|
| 31 |
+
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 67 |
|
| 68 |
agent = CodeAgent(
|
| 69 |
model=model,
|
| 70 |
+
tools=[final_answer, get_current_time_in_timezone, my_custom_tool], ## add your tools here (don't remove final answer)
|
| 71 |
max_steps=6,
|
| 72 |
verbosity_level=1,
|
| 73 |
grammar=None,
|