abdullahfurquan commited on
Commit
01b8073
·
verified ·
1 Parent(s): 0700f80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -17,15 +17,19 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
17
 
18
  # Image generation !
19
 
 
20
  def generate_image_tool(prompt: str) -> str:
21
  """Generates an image from text and returns the file path."""
22
  try:
23
- image = image_generation_tool(prompt)
24
- return image # Return the file path
 
 
25
  except Exception as e:
26
  return f"Error generating image: {str(e)}"
27
 
28
 
 
29
  # @tool
30
  # def generate_image_tool(prompt: str) -> Image:
31
  # """Generates an image from text using the image generation tool.
 
17
 
18
  # Image generation !
19
 
20
+ @tool
21
  def generate_image_tool(prompt: str) -> str:
22
  """Generates an image from text and returns the file path."""
23
  try:
24
+ image = image_generation_tool(prompt) # Get PIL Image
25
+ file_path = "generated_image.jpg"
26
+ image.save(file_path) # Save it
27
+ return file_path # Return the file path
28
  except Exception as e:
29
  return f"Error generating image: {str(e)}"
30
 
31
 
32
+
33
  # @tool
34
  # def generate_image_tool(prompt: str) -> Image:
35
  # """Generates an image from text using the image generation tool.