namansnghl commited on
Commit
653699a
·
verified ·
1 Parent(s): f9d1c13

Die Rolling tool

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -3,6 +3,7 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
@@ -33,6 +34,20 @@ 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
 
@@ -55,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer, get_current_time_in_timezone, my_custom_tool], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import random
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
 
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
+ @tool
38
+ def roll_die(dice_size: int) -> int:
39
+ """
40
+ This tool rolls a die and returns the number we get after rolling
41
+ Args:
42
+ dice_size: A natural number representing our die size
43
+ """
44
+
45
+ try:
46
+ options = list(range(1, dice_size+1))
47
+ return f"You got {random.choice(options)}"
48
+ except Exception as msg:
49
+ return f"Oops the die broke before I could roll, \nError {msg}"
50
+
51
 
52
  final_answer = FinalAnswerTool()
53
 
 
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer, get_current_time_in_timezone, my_custom_tool, roll_die], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,