Masrkai commited on
Commit
cdb5db8
·
verified ·
1 Parent(s): 09a3162

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -34,24 +34,24 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
- # @tool
38
- # def image_generation_tool(prompt: str) -> Image:
39
- # """A tool that generates images using the FLUX.1-schnell model.
40
- # Args:
41
- # prompt: A string containing the image generation prompt.
42
- # Returns:
43
- # str: Status message indicating success or error of image generation.
44
- # """
45
- # try:
46
- # tool = Tool.from_space(
47
- # "black-forest-labs/FLUX.1-schnell",
48
- # name="image_generator",
49
- # description="Generate an image from a prompt"
50
- # )
51
- # result = tool.generate(prompt)
52
- # return f"Successfully generated image from prompt: {prompt}"
53
- # except Exception as e:
54
- # return f"Error generating image from prompt '{prompt}': {str(e)}"
55
 
56
 
57
  @tool
@@ -102,7 +102,7 @@ with open("prompts.yaml", 'r') as stream:
102
 
103
  agent = CodeAgent(
104
  model=model,
105
- tools=[final_answer, get_weather ], ## add your tools here (don't remove final answer)
106
  max_steps=6,
107
  verbosity_level=1,
108
  grammar=None,
 
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
+ @tool
38
+ def image_generation_tool(prompt: str) -> Image:
39
+ """A tool that generates images using the FLUX.1-schnell model.
40
+ Args:
41
+ prompt: A string containing the image generation prompt.
42
+ Returns:
43
+ str: Status message indicating success or error of image generation.
44
+ """
45
+ try:
46
+ tool = Tool.from_space(
47
+ "black-forest-labs/FLUX.1-schnell",
48
+ name="image_generator",
49
+ description="Generate an image from a prompt"
50
+ )
51
+ result = tool.generate(prompt)
52
+ return f"Successfully generated image from prompt: {prompt}"
53
+ except Exception as e:
54
+ return f"Error generating image from prompt '{prompt}': {str(e)}"
55
 
56
 
57
  @tool
 
102
 
103
  agent = CodeAgent(
104
  model=model,
105
+ tools=[final_answer, get_weather, image_generation_tool ], ## add your tools here (don't remove final answer)
106
  max_steps=6,
107
  verbosity_level=1,
108
  grammar=None,