srkdev384 commited on
Commit
0127888
·
verified ·
1 Parent(s): 5c5ad56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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) -> str:
26
  """
27
- Generates an image from a text prompt and saves it locally.
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: