Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,34 +34,23 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
@tool
|
| 37 |
-
def image_generation_tool():
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
Note:
|
| 55 |
-
While the Tool construction is pure, the actual image generation may involve
|
| 56 |
-
non-deterministic elements from the underlying model. The function itself
|
| 57 |
-
remains referentially transparent as it consistently returns the same Tool
|
| 58 |
-
configuration.
|
| 59 |
-
"""
|
| 60 |
-
return Tool.from_space(
|
| 61 |
-
"black-forest-labs/FLUX.1-schnell",
|
| 62 |
-
name="image_generator",
|
| 63 |
-
description="Generate an image from a prompt"
|
| 64 |
-
)
|
| 65 |
|
| 66 |
final_answer = FinalAnswerTool()
|
| 67 |
|
|
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
@tool
|
| 37 |
+
def image_generation_tool(prompt: str) -> str:
|
| 38 |
+
"""A tool that generates images using the FLUX.1-schnell model.
|
| 39 |
+
Args:
|
| 40 |
+
prompt: A string containing the image generation prompt.
|
| 41 |
+
Returns:
|
| 42 |
+
str: Status message indicating success or error of image generation.
|
| 43 |
+
"""
|
| 44 |
+
try:
|
| 45 |
+
tool = Tool.from_space(
|
| 46 |
+
"black-forest-labs/FLUX.1-schnell",
|
| 47 |
+
name="image_generator",
|
| 48 |
+
description="Generate an image from a prompt"
|
| 49 |
+
)
|
| 50 |
+
result = tool.generate(prompt)
|
| 51 |
+
return f"Successfully generated image from prompt: {prompt}"
|
| 52 |
+
except Exception as e:
|
| 53 |
+
return f"Error generating image from prompt '{prompt}': {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
final_answer = FinalAnswerTool()
|
| 56 |
|