Spaces:
Runtime error
Runtime error
Update app.py
Browse filesScrap deepseek
app.py
CHANGED
|
@@ -53,23 +53,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 53 |
except Exception as e:
|
| 54 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 55 |
|
| 56 |
-
# @tool
|
| 57 |
-
# def generate_image(description: str) -> Image:
|
| 58 |
-
# """A tool that generates an image from a text description.
|
| 59 |
-
# Args:
|
| 60 |
-
# description: A string representing the text description to generate an image of.
|
| 61 |
-
# """
|
| 62 |
-
# image_generation_tool = Tool.from_space(
|
| 63 |
-
# "black-forest-labs/FLUX.1-schnell",
|
| 64 |
-
# name="image_generator",
|
| 65 |
-
# description="Generate an image from a prompt"
|
| 66 |
-
# )
|
| 67 |
-
# # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 68 |
-
# image: Image = image_generation_tool(description)
|
| 69 |
-
# # return f"Image generated for prompt: {description}."
|
| 70 |
-
# return image
|
| 71 |
-
|
| 72 |
-
|
| 73 |
@tool
|
| 74 |
def generate_image(description: str) -> str:
|
| 75 |
"""A tool that generates an image from a text description.
|
|
@@ -81,19 +64,35 @@ def generate_image(description: str) -> str:
|
|
| 81 |
name="image_generator",
|
| 82 |
description="Generate an image from a prompt"
|
| 83 |
)
|
| 84 |
-
#
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
|
| 98 |
|
| 99 |
|
|
|
|
| 53 |
except Exception as e:
|
| 54 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
@tool
|
| 57 |
def generate_image(description: str) -> str:
|
| 58 |
"""A tool that generates an image from a text description.
|
|
|
|
| 64 |
name="image_generator",
|
| 65 |
description="Generate an image from a prompt"
|
| 66 |
)
|
| 67 |
+
# image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 68 |
+
image = image_generation_tool(description)
|
| 69 |
+
return f"Image generated for prompt: {description}."
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# @tool
|
| 73 |
+
# def generate_image(description: str) -> str:
|
| 74 |
+
# """A tool that generates an image from a text description.
|
| 75 |
+
# Args:
|
| 76 |
+
# description: A string representing the text description to generate an image of.
|
| 77 |
+
# """
|
| 78 |
+
# image_generation_tool = Tool.from_space(
|
| 79 |
+
# "black-forest-labs/FLUX.1-schnell",
|
| 80 |
+
# name="image_generator",
|
| 81 |
+
# description="Generate an image from a prompt"
|
| 82 |
+
# )
|
| 83 |
+
# # Generate the image
|
| 84 |
+
# pil_image: Image = image_generation_tool(description)
|
| 85 |
|
| 86 |
+
# # Convert image to bytes
|
| 87 |
+
# buffered = BytesIO()
|
| 88 |
+
# pil_image.save(buffered, format="PNG")
|
| 89 |
+
# buffered.seek(0)
|
| 90 |
|
| 91 |
+
# # Encode as base64
|
| 92 |
+
# img_base64 = base64.b64encode(buffered.read()).decode()
|
| 93 |
|
| 94 |
+
# # Return as Markdown image
|
| 95 |
+
# return f""
|
| 96 |
|
| 97 |
|
| 98 |
|