DChen2007 commited on
Commit
2a11fc7
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -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,18 @@ 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 +68,7 @@ with open("prompts.yaml", 'r') as 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,
 
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 get_a_random_integer(start: int, end, int) -> int:
39
+ """A tool that generate a random integer in the interval given through the arguments.
40
+ Args:
41
+ start: starting integer of the interval.
42
+ end: ending integer of the interval
43
+ """
44
+ try:
45
+ random_integer = random.randint(start, end)
46
+ return f"The random integer between {start} and {end} is: {random_integer}"
47
+ except Exception as e:
48
+ return f"Error getting the random integer in between'{start} and {end}': {str(e)}"
49
 
50
  final_answer = FinalAnswerTool()
51
 
 
68
 
69
  agent = CodeAgent(
70
  model=model,
71
+ tools=[final_answer,get_a_random_integer], ## add your tools here (don't remove final answer)
72
  max_steps=6,
73
  verbosity_level=1,
74
  grammar=None,