Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,21 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -49,13 +64,14 @@ custom_role_conversions=None,
|
|
| 49 |
|
| 50 |
# Import tool from Hub
|
| 51 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
|
|
| 52 |
|
| 53 |
with open("prompts.yaml", 'r') as stream:
|
| 54 |
prompt_templates = yaml.safe_load(stream)
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer,get_current_time_in_timezone,image_generation_tool], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def creative_story_starter(theme: str, setting: str) -> str:
|
| 38 |
+
"""A tool that generates a unique creative writing prompt based on a theme and setting.
|
| 39 |
+
Args:
|
| 40 |
+
theme: The central idea or emotion (e.g., 'betrayal', 'discovery', 'solitude').
|
| 41 |
+
setting: Where the story takes place (e.g., 'a floating city', 'a Victorian library').
|
| 42 |
+
"""
|
| 43 |
+
import random
|
| 44 |
+
openers = [
|
| 45 |
+
f"The air in {setting} tasted of {theme}.",
|
| 46 |
+
f"Nobody in {setting} expected that {theme} would be their undoing.",
|
| 47 |
+
f"In the heart of {setting}, a small spark of {theme} began to grow."
|
| 48 |
+
]
|
| 49 |
+
return random.choice(openers)
|
| 50 |
+
|
| 51 |
|
| 52 |
final_answer = FinalAnswerTool()
|
| 53 |
|
|
|
|
| 64 |
|
| 65 |
# Import tool from Hub
|
| 66 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 67 |
+
search_tool = DuckDuckGoSearchTool()
|
| 68 |
|
| 69 |
with open("prompts.yaml", 'r') as stream:
|
| 70 |
prompt_templates = yaml.safe_load(stream)
|
| 71 |
|
| 72 |
agent = CodeAgent(
|
| 73 |
model=model,
|
| 74 |
+
tools=[final_answer,search_tool,get_current_time_in_timezone,image_generation_tool,creative_story_starter], ## add your tools here (don't remove final answer)
|
| 75 |
max_steps=6,
|
| 76 |
verbosity_level=1,
|
| 77 |
grammar=None,
|