Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,8 @@ 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
|
|
@@ -23,19 +23,18 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
| 23 |
|
| 24 |
@tool
|
| 25 |
def generate_image(prompt: str) -> str:
|
| 26 |
-
"""
|
| 27 |
-
Generates an image based on a text prompt.
|
| 28 |
-
|
| 29 |
-
Args:
|
| 30 |
-
prompt: A detailed description of the image to generate.
|
| 31 |
-
"""
|
| 32 |
try:
|
| 33 |
result = image_generation_tool(prompt)
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
except Exception as e:
|
| 36 |
return f"Error generating image: {str(e)}"
|
| 37 |
|
| 38 |
-
|
| 39 |
@tool
|
| 40 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 41 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
from Gradio_UI import GradioUI
|
| 8 |
+
import uuid
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
|
|
|
| 23 |
|
| 24 |
@tool
|
| 25 |
def generate_image(prompt: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
try:
|
| 27 |
result = image_generation_tool(prompt)
|
| 28 |
+
image = result["image"]
|
| 29 |
+
|
| 30 |
+
filename = f"{uuid.uuid4()}.png"
|
| 31 |
+
image.save(filename)
|
| 32 |
+
|
| 33 |
+
return filename
|
| 34 |
+
|
| 35 |
except Exception as e:
|
| 36 |
return f"Error generating image: {str(e)}"
|
| 37 |
|
|
|
|
| 38 |
@tool
|
| 39 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 40 |
"""A tool that fetches the current local time in a specified timezone.
|