Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 55 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
Returns:
|
| 58 |
-
A string
|
| 59 |
"""
|
| 60 |
try:
|
| 61 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 62 |
-
|
|
|
|
| 63 |
except Exception as e:
|
| 64 |
-
return f"Error
|
| 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)
|