Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,13 +32,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 32 |
except Exception as e:
|
| 33 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 34 |
|
| 35 |
-
# Add image generation tool (simple example)
|
| 36 |
-
@tool
|
| 37 |
-
def image_generation_tool(prompt: str) -> str:
|
| 38 |
-
"""Generate an image from text prompt. Returns image URL."""
|
| 39 |
-
# In real usage, replace with actual API call
|
| 40 |
-
return f"https://dummyimage.com/600x400/000/fff&text={prompt.replace(' ', '+')}"
|
| 41 |
-
|
| 42 |
final_answer = FinalAnswerTool()
|
| 43 |
model = HfApiModel(
|
| 44 |
max_tokens=2096,
|
|
@@ -47,6 +40,9 @@ model = HfApiModel(
|
|
| 47 |
custom_role_conversions=None,
|
| 48 |
)
|
| 49 |
|
|
|
|
|
|
|
|
|
|
| 50 |
with open("prompts.yaml", 'r') as stream:
|
| 51 |
prompt_templates = yaml.safe_load(stream)
|
| 52 |
|
|
@@ -54,7 +50,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 54 |
agent = CodeAgent(
|
| 55 |
model=model,
|
| 56 |
#tools=[final_answer], # add your tools here (don't remove final_answer)
|
| 57 |
-
tools=[final_answer,image_generation_tool,
|
| 58 |
max_steps=6,
|
| 59 |
verbosity_level=1,
|
| 60 |
grammar=None,
|
|
|
|
| 32 |
except Exception as e:
|
| 33 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
final_answer = FinalAnswerTool()
|
| 36 |
model = HfApiModel(
|
| 37 |
max_tokens=2096,
|
|
|
|
| 40 |
custom_role_conversions=None,
|
| 41 |
)
|
| 42 |
|
| 43 |
+
# Import tool from Hub
|
| 44 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 45 |
+
|
| 46 |
with open("prompts.yaml", 'r') as stream:
|
| 47 |
prompt_templates = yaml.safe_load(stream)
|
| 48 |
|
|
|
|
| 50 |
agent = CodeAgent(
|
| 51 |
model=model,
|
| 52 |
#tools=[final_answer], # add your tools here (don't remove final_answer)
|
| 53 |
+
tools=[final_answer,image_generation_tool,DuckDuckGoSearchTool],
|
| 54 |
max_steps=6,
|
| 55 |
verbosity_level=1,
|
| 56 |
grammar=None,
|