Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,18 +42,36 @@ image_generation_tool = Tool.from_space(
|
|
| 42 |
description="Generate an image from a prompt"
|
| 43 |
)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
@tool
|
| 46 |
-
def
|
| 47 |
"""
|
| 48 |
-
|
| 49 |
-
|
| 50 |
Args:
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
"""
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
final_answer = FinalAnswerTool()
|
| 59 |
|
|
@@ -76,7 +94,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 76 |
|
| 77 |
agent = CodeAgent(
|
| 78 |
model=model,
|
| 79 |
-
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, wiki_of_person, display_image], ## add your tools here (don't remove final answer)
|
| 80 |
max_steps=6,
|
| 81 |
verbosity_level=1,
|
| 82 |
grammar=None,
|
|
|
|
| 42 |
description="Generate an image from a prompt"
|
| 43 |
)
|
| 44 |
|
| 45 |
+
# @tool
|
| 46 |
+
# def display_image(path: str) -> str:
|
| 47 |
+
# """
|
| 48 |
+
# Use the PIL library to display an image from a given path.
|
| 49 |
+
|
| 50 |
+
# Args:
|
| 51 |
+
# path: output path from the image generation tool
|
| 52 |
+
# """
|
| 53 |
+
# image = Image.open(path)
|
| 54 |
+
# image.show()
|
| 55 |
+
|
| 56 |
+
# return "Success"
|
| 57 |
+
|
| 58 |
@tool
|
| 59 |
+
def convert_currency(amount: float, from_currency: str, to_currency: str) -> float:
|
| 60 |
"""
|
| 61 |
+
Convert an amount from one currency to another using fawazahmed0's free API.
|
| 62 |
+
|
| 63 |
Args:
|
| 64 |
+
amount: The amount to convert
|
| 65 |
+
from_currency: The source currency code (e.g., 'USD', 'EUR', 'BTC')
|
| 66 |
+
to_currency: The target currency code (e.g., 'USD', 'EUR', 'BTC')
|
| 67 |
"""
|
| 68 |
+
url = f'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/{from_currency.lower()}.json'
|
| 69 |
+
|
| 70 |
+
response = requests.get(url)
|
| 71 |
+
rates = response.json()[from_currency.lower()]
|
| 72 |
+
converted = amount * rates[to_currency.lower()]
|
| 73 |
+
|
| 74 |
+
return round(converted, 2)
|
| 75 |
|
| 76 |
final_answer = FinalAnswerTool()
|
| 77 |
|
|
|
|
| 94 |
|
| 95 |
agent = CodeAgent(
|
| 96 |
model=model,
|
| 97 |
+
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, wiki_of_person, display_image, convert_currency], ## add your tools here (don't remove final answer)
|
| 98 |
max_steps=6,
|
| 99 |
verbosity_level=1,
|
| 100 |
grammar=None,
|