Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ 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 !
|
|
@@ -22,9 +23,9 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 22 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 23 |
|
| 24 |
@tool
|
| 25 |
-
def generate_image(prompt: str) ->
|
| 26 |
"""
|
| 27 |
-
Generates an image from a text prompt and
|
| 28 |
|
| 29 |
Args:
|
| 30 |
prompt: A detailed description of the image to generate.
|
|
@@ -34,7 +35,7 @@ def generate_image(prompt: str) -> str:
|
|
| 34 |
filename = f"{uuid.uuid4()}.png"
|
| 35 |
image.save(filename)
|
| 36 |
|
| 37 |
-
return filename
|
| 38 |
|
| 39 |
@tool
|
| 40 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from Gradio_UI import GradioUI
|
| 8 |
+
from smolagents.agent_types import AgentImage
|
| 9 |
import uuid
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
| 23 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 24 |
|
| 25 |
@tool
|
| 26 |
+
def generate_image(prompt: str) -> AgentImage:
|
| 27 |
"""
|
| 28 |
+
Generates an image from a text prompt and returns it as an AgentImage.
|
| 29 |
|
| 30 |
Args:
|
| 31 |
prompt: A detailed description of the image to generate.
|
|
|
|
| 35 |
filename = f"{uuid.uuid4()}.png"
|
| 36 |
image.save(filename)
|
| 37 |
|
| 38 |
+
return AgentImage(filename)
|
| 39 |
|
| 40 |
@tool
|
| 41 |
def get_current_time_in_timezone(timezone: str) -> str:
|