dizolivemint commited on
Commit
78daf9f
·
1 Parent(s): ae7a494

🚀 added dice tool

Browse files
Files changed (1) hide show
  1. app.py +14 -4
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
@@ -11,12 +12,21 @@ from Gradio_UI import GradioUI
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:
 
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
 
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> 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
15
+ """A tool that rolls a dice and returns the result.
16
  Args:
17
+ arg1: A string representing the type of dice to roll (e.g., 'd6', 'd20').
18
+ arg2: An integer representing the number of dice to roll.
19
+ Returns:
20
+ A string describing the result of the dice roll.
21
  """
22
+ # Parse the dice type
23
+ dice_type = arg1.lower()
24
+ if dice_type.startswith('d'):
25
+ sides = int(dice_type[1:])
26
+ results = [random.randint(1, sides) for _ in range(arg2)]
27
+ return f"You rolled {arg2} {dice_type} and got: {', '.join(map(str, results))}"
28
+ else:
29
+ return "Invalid dice type. Please use the format 'dX' where X is the number of sides."
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str: