Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,20 +51,20 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 51 |
except Exception as e:
|
| 52 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
|
| 70 |
# @tool
|
|
@@ -108,14 +108,14 @@ custom_role_conversions=None,
|
|
| 108 |
|
| 109 |
|
| 110 |
# Import tool from Hub
|
| 111 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 112 |
|
| 113 |
with open("prompts.yaml", 'r') as stream:
|
| 114 |
prompt_templates = yaml.safe_load(stream)
|
| 115 |
|
| 116 |
agent = CodeAgent(
|
| 117 |
model=model,
|
| 118 |
-
tools=[final_answer, get_web_search_results,
|
| 119 |
max_steps=6,
|
| 120 |
verbosity_level=1,
|
| 121 |
grammar=None,
|
|
|
|
| 51 |
except Exception as e:
|
| 52 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 53 |
|
| 54 |
+
@tool
|
| 55 |
+
def generate_image(description: str) -> str:
|
| 56 |
+
"""A tool that generates an image from a text description. The generated image should be displayed using Markdown.
|
| 57 |
+
Args:
|
| 58 |
+
description: A string representing the text description to generate an image of.
|
| 59 |
+
"""
|
| 60 |
+
image_generation_tool = Tool.from_space(
|
| 61 |
+
"black-forest-labs/FLUX.1-schnell",
|
| 62 |
+
name="image_generator",
|
| 63 |
+
description="Generate an image from a prompt"
|
| 64 |
+
)
|
| 65 |
+
# image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 66 |
+
image = image_generation_tool(description)
|
| 67 |
+
return f"Image generated for prompt: {description} is {image}."
|
| 68 |
|
| 69 |
|
| 70 |
# @tool
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
# Import tool from Hub
|
| 111 |
+
# image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 112 |
|
| 113 |
with open("prompts.yaml", 'r') as stream:
|
| 114 |
prompt_templates = yaml.safe_load(stream)
|
| 115 |
|
| 116 |
agent = CodeAgent(
|
| 117 |
model=model,
|
| 118 |
+
tools=[final_answer, get_web_search_results, generate_image], ## add your tools here (don't remove final answer)
|
| 119 |
max_steps=6,
|
| 120 |
verbosity_level=1,
|
| 121 |
grammar=None,
|