smokxy commited on
Commit
a371aad
·
1 Parent(s): ea2783d

update img tool

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -24,13 +24,13 @@ def generate_image(prompt: str, style: str) -> str:
24
 
25
  # Generate the image
26
  image = image_generation_tool(full_prompt)
27
-
28
- # Convert the image to a string representation that can be displayed
29
- if hasattr(image, 'to_string'):
30
- return image.to_string()
31
- else:
32
- # If we can't convert the image, return a message with the image object
33
- return f"Image generated successfully! Please check the image object: {str(image)}"
34
  except Exception as e:
35
  return f"Error generating image: {str(e)}"
36
 
 
24
 
25
  # Generate the image
26
  image = image_generation_tool(full_prompt)
27
+
28
+ # Convert the PIL image to AgentImage
29
+ from smolagents.agent_types import AgentImage
30
+ agent_image = AgentImage(image)
31
+
32
+ # Return the AgentImage object
33
+ return agent_image
34
  except Exception as e:
35
  return f"Error generating image: {str(e)}"
36