Added 3 tools just to make something slightly stupid
Browse files
app.py
CHANGED
|
@@ -9,14 +9,27 @@ 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
|
| 13 |
-
|
| 14 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +68,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,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def convert_usd_to_eur(amount: float) -> str:
|
| 13 |
+
"""A tool to convert USD to EUR at a fixed exchange rate.
|
|
|
|
| 14 |
Args:
|
| 15 |
+
amount: Amount in USD.
|
|
|
|
| 16 |
"""
|
| 17 |
+
exchange_rate = 0.93 # You could make this dynamic with an API
|
| 18 |
+
euros = amount * exchange_rate
|
| 19 |
+
return f"{amount} USD is approximately {euros:.2f} EUR."
|
| 20 |
+
|
| 21 |
+
@tool
|
| 22 |
+
def get_fun_fact(topic: str) -> str:
|
| 23 |
+
"""A tool that returns a fun fact about a given topic.
|
| 24 |
+
Args:
|
| 25 |
+
topic: A topic like 'space', 'octopus', or 'time'.
|
| 26 |
+
"""
|
| 27 |
+
facts = {
|
| 28 |
+
"space": "There are more stars in the universe than grains of sand on Earth.",
|
| 29 |
+
"octopus": "Octopuses have three hearts and blue blood.",
|
| 30 |
+
"time": "Time passes faster at the top of a mountain than at sea level."
|
| 31 |
+
}
|
| 32 |
+
return facts.get(topic.lower(), f"I don't have a fun fact about {topic} — yet.")
|
| 33 |
|
| 34 |
@tool
|
| 35 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[get_current_time_in_timezone, get_fun_fact, convert_usd_to_eur, final_answer], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|