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

update img tool

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -13,7 +13,6 @@ from Gradio_UI import GradioUI
13
  @tool
14
  # it's import to specify the return type
15
  def generate_image(prompt: str, style: str) -> str:
16
- # Keep this format for the description / args / args description but feel free to modify the tool
17
  """A tool that generates an image based on a prompt and a style.
18
  Args:
19
  prompt: the prompt to generate the image
@@ -25,9 +24,13 @@ def generate_image(prompt: str, style: str) -> str:
25
 
26
  # Generate the image
27
  image = image_generation_tool(full_prompt)
28
-
29
- # Return the image
30
- return image
 
 
 
 
31
  except Exception as e:
32
  return f"Error generating image: {str(e)}"
33
 
 
13
  @tool
14
  # it's import to specify the return type
15
  def generate_image(prompt: str, style: str) -> str:
 
16
  """A tool that generates an image based on a prompt and a style.
17
  Args:
18
  prompt: the prompt to generate the image
 
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