leonwoo commited on
Commit
bd41c5e
·
verified ·
1 Parent(s): 8c5c24b

added in tools

Browse files
Files changed (1) hide show
  1. app.py +45 -8
app.py CHANGED
@@ -7,16 +7,51 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
 
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -52,10 +87,12 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
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,
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ from random import choice
11
+
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
+ def my_custom_tool(arg1: str, arg2: int) -> str:
15
+ """A magical fortune cookie generator tool
 
16
  Args:
17
+ arg1: your name or a keyword to seed the fortune
18
+ arg2: your luck level (0–10), higher means more optimistic fortunes
19
  """
20
+ fortunes_positive = [
21
+ "A pleasant surprise is waiting for you.",
22
+ "You will soon embark on a journey of growth.",
23
+ "An opportunity will arise that you must not ignore.",
24
+ "Your creativity will unlock new doors.",
25
+ "Today is a good day to start something bold.",
26
+ ]
27
+
28
+ fortunes_neutral = [
29
+ "Uncertainty lies ahead, but so does potential.",
30
+ "An answer will come when you least expect it.",
31
+ "Sometimes not knowing is part of the adventure.",
32
+ "The future is like clay — soft, but firm when shaped.",
33
+ "Change is inevitable. Be ready, not afraid.",
34
+ ]
35
+
36
+ fortunes_negative = [
37
+ "Even the brightest flame casts shadows.",
38
+ "A detour may delay your plans — stay calm.",
39
+ "Expect turbulence before smooth skies.",
40
+ "Not every seed will bloom — choose wisely.",
41
+ "Some days the magic feels hidden — keep looking.",
42
+ ]
43
+
44
+ # Clamp luck level to 0–10
45
+ luck = max(0, min(arg2, 10))
46
+ if luck >= 7:
47
+ fortunes = fortunes_positive
48
+ elif luck >= 4:
49
+ fortunes = fortunes_neutral
50
+ else:
51
+ fortunes = fortunes_negative
52
+
53
+ fortune = choice(fortunes)
54
+ return f"🔮 {arg1}, your fortune is: '{fortune}'"
55
 
56
  @tool
57
  def get_current_time_in_timezone(timezone: str) -> str:
 
87
 
88
  with open("prompts.yaml", 'r') as stream:
89
  prompt_templates = yaml.safe_load(stream)
90
+
91
+ duckduckGo = DuckDuckGoSearchTool()
92
+
93
  agent = CodeAgent(
94
  model=model,
95
+ tools=[final_answer,image_generation_tool,get_current_time_in_timezone,duckduckGo], ## add your tools here (don't remove final answer)
96
  max_steps=6,
97
  verbosity_level=1,
98
  grammar=None,