k0smes commited on
Commit
82a391b
·
verified ·
1 Parent(s): 5e4a233

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
@@ -20,6 +21,11 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
20
  """
21
  return "What magic will you build ?"
22
 
 
 
 
 
 
23
 
24
  @tool
25
  def web_search(query: str) -> str:
@@ -76,7 +82,7 @@ custom_role_conversions=None,
76
 
77
 
78
  # Import tool from Hub
79
- image_generator = load_tool("agents-course/text-to-image", trust_remote_code=True)
80
 
81
  with open("prompts.yaml", 'r') as stream:
82
  prompt_templates = yaml.safe_load(stream)
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from smolagents.agent_types import AgentImage
8
 
9
  from Gradio_UI import GradioUI
10
 
 
21
  """
22
  return "What magic will you build ?"
23
 
24
+ @tool
25
+ def image_generator(prompt: str) -> AgentImage:
26
+ """Generate an image from text prompt."""
27
+ img = image_generation_tool(prompt)
28
+ return AgentImage(img)
29
 
30
  @tool
31
  def web_search(query: str) -> str:
 
82
 
83
 
84
  # Import tool from Hub
85
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
86
 
87
  with open("prompts.yaml", 'r') as stream:
88
  prompt_templates = yaml.safe_load(stream)