Dagoss commited on
Commit
ea5bbee
·
verified ·
1 Parent(s): 806bfce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -21
app.py CHANGED
@@ -7,34 +7,26 @@ from tools.final_answer import FinalAnswerTool
7
  import random
8
  from Gradio_UI import GradioUI
9
 
10
- from pydantic import BaseModel, Field
11
- import random
12
-
13
- class RandomNumberInput(BaseModel):
14
- start_range: int = Field(..., description="The start number of the range")
15
- end_range: int = Field(..., description="The end number of the range")
16
-
17
- @tool(args_schema=RandomNumberInput)
18
- def get_random_number_between_range(start_range: int, end_range: int) -> int:
19
  """A tool that generates a random number given a range.
20
-
21
  Args:
22
  start_range: The start number of the range.
23
  end_range: The end number of the range.
24
  """
 
 
 
 
 
 
 
 
 
 
25
  return random.randint(start_range, end_range)
26
 
27
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
28
- @tool
29
- def get_random_number_between_range(start_range:int, end_range:int)-> int: #it's import to specify the return type
30
- #Keep this format for the description / args / args description but feel free to modify the tool
31
- """A tool that generate a random number given a range
32
- Args:
33
- start_range: the start number of the range
34
- end_range: the end number of the range
35
- """
36
- return random.randrange(start_range, end_range)
37
-
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
40
  """A tool that fetches the current local time in a specified timezone.
 
7
  import random
8
  from Gradio_UI import GradioUI
9
 
10
+ @tool
11
+ def get_random_number_between_range(start_range: int = None, end_range: int = None) -> int:
 
 
 
 
 
 
 
12
  """A tool that generates a random number given a range.
13
+
14
  Args:
15
  start_range: The start number of the range.
16
  end_range: The end number of the range.
17
  """
18
+ # Ask the user for missing inputs
19
+ if start_range is None:
20
+ return "Please provide the start number of the range."
21
+ if end_range is None:
22
+ return "Please provide the end number of the range."
23
+
24
+ # Ensure valid range
25
+ if start_range >= end_range:
26
+ return "Error: The start number must be smaller than the end number."
27
+
28
  return random.randint(start_range, end_range)
29
 
 
 
 
 
 
 
 
 
 
 
 
30
  @tool
31
  def get_current_time_in_timezone(timezone: str) -> str:
32
  """A tool that fetches the current local time in a specified timezone.