Miladata commited on
Commit
8aeb9ba
·
verified ·
1 Parent(s): bedf89f

Feat: Second tool, tribble counter

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -9,6 +9,7 @@ import random
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
12
  @tool
13
  def get_star_trek_quote(character: str)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
@@ -18,7 +19,7 @@ def get_star_trek_quote(character: str)-> str: #it's import to specify the retur
18
  character: The name of the character whose quote is requested (e.g., "Seven of Nine", "Spock", "Picard", "Data").
19
 
20
  Returns:
21
- A quote from the specified Star Trek character.
22
  """
23
  quotes = {
24
  "Seven of Nine": [
@@ -38,7 +39,29 @@ def get_star_trek_quote(character: str)-> str: #it's import to specify the retur
38
  "One is my name. The other is not."
39
  ]
40
  }
41
- return quotes.get(character, ["Sorry, no quotes available for this character"])[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  @tool
44
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -77,7 +100,7 @@ with open("prompts.yaml", 'r') as stream:
77
 
78
  agent = CodeAgent(
79
  model=model,
80
- tools=[final_answer, get_star_trek_quote], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,
 
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
+ # In this case, the user should input the name of the character to get the quote :)
13
  @tool
14
  def get_star_trek_quote(character: str)-> str: #it's import to specify the return type
15
  #Keep this format for the description / args / args description but feel free to modify the tool
 
19
  character: The name of the character whose quote is requested (e.g., "Seven of Nine", "Spock", "Picard", "Data").
20
 
21
  Returns:
22
+ A quote from the specified Star Trek character, or a message if the character is not found.
23
  """
24
  quotes = {
25
  "Seven of Nine": [
 
39
  "One is my name. The other is not."
40
  ]
41
  }
42
+
43
+ # If the character exists in the dictionary, return a quote
44
+ if character in quote:
45
+ return quotes[character][0] # Fetch the first character
46
+ else:
47
+ return f"Sorry, no quotes available for {character}. Please provide a valid Star Trek character name."
48
+
49
+ # To invoke this tool, just type something like "How many tribbles are there? or "Check the Tribble infestation!"
50
+ @tool
51
+ def tribbles_counter() -> str:
52
+ """
53
+ Simulates the number of Tribbles aboard a starship.
54
+
55
+ Returns:
56
+ A string with the count of Tribbles aboard.
57
+ """
58
+ tribbles_counter = random.randint(1,1000)
59
+ if tribbles_count > 500:
60
+ return f"There are {tribbles_count} Tribbles aboard! It's a *serious* infestation!"
61
+ elif tribbles_count > 200:
62
+ return f"There are {tribbles_count} Tribbles aboard. It's getting out of hand!"
63
+ else:
64
+ return f"There are {tribbles_count} Tribbles aboard. It's under control...for now."
65
 
66
  @tool
67
  def get_current_time_in_timezone(timezone: str) -> str:
 
100
 
101
  agent = CodeAgent(
102
  model=model,
103
+ tools=[final_answer, get_star_trek_quote, tribbles_counter], ## add your tools here (don't remove final answer)
104
  max_steps=6,
105
  verbosity_level=1,
106
  grammar=None,