arunprasadh commited on
Commit
156fd84
·
verified ·
1 Parent(s): 6c03f0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -51,17 +51,21 @@ custom_role_conversions=None,
51
  # @tool
52
  # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
53
  @tool
54
- def get_image_generation_tool() -> str:
55
- """Loads the image generation tool for generating images from text prompts.
 
 
 
56
 
57
  Returns:
58
- A string confirming the tool has been loaded successfully.
59
  """
60
  try:
61
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
62
- return "Image generation tool has been successfully loaded."
 
63
  except Exception as e:
64
- return f"Error loading image generation tool: {str(e)}"
65
 
66
  with open("prompts.yaml", 'r') as stream:
67
  prompt_templates = yaml.safe_load(stream)
 
51
  # @tool
52
  # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
53
  @tool
54
+ def generate_image_from_text(prompt: str) -> str:
55
+ """Generates an image based on the given text prompt.
56
+
57
+ Args:
58
+ prompt: A string describing the image to be generated.
59
 
60
  Returns:
61
+ A string indicating the success or failure of the image generation process.
62
  """
63
  try:
64
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
65
+ image_url = image_generation_tool(prompt)
66
+ return f"Image successfully generated: {image_url}"
67
  except Exception as e:
68
+ return f"Error generating image: {str(e)}"
69
 
70
  with open("prompts.yaml", 'r') as stream:
71
  prompt_templates = yaml.safe_load(stream)