venjp commited on
Commit
dc1e893
·
verified ·
1 Parent(s): 94f53e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -33,6 +33,23 @@ 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 +66,18 @@ 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], ## 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
+ # Now add 'creative_story_starter' to your agent's tools list!
52
+
53
 
54
  final_answer = FinalAnswerTool()
55
 
 
66
 
67
  # Import tool from Hub
68
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
69
+ search_tool = DuckDuckGoSearchTool()
70
 
71
  with open("prompts.yaml", 'r') as stream:
72
  prompt_templates = yaml.safe_load(stream)
73
 
74
  agent = CodeAgent(
75
  model=model,
76
+ tools=[final_answer,
77
+ get_current_time_in_timezone,
78
+ search_tool,
79
+ image_generation_tool,
80
+ creative_story_starter], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,