usemil commited on
Commit
bd1a7e6
·
verified ·
1 Parent(s): 7b93576

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -10
app.py CHANGED
@@ -9,14 +9,37 @@ from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_cutom_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:
@@ -36,10 +59,10 @@ def get_current_time_in_timezone(timezone: str) -> str:
36
 
37
  final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
- max_tokens=2096,
40
- temperature=0.5,
41
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
42
- custom_role_conversions=None,
43
  )
44
 
45
 
@@ -51,7 +74,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def calculator(a: int, b: int, oper: str)-> 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 functions as a calculator between two arguments and performs the selected operation.
15
  Args:
16
+ a: the first argument
17
+ b: the second argument
18
+ oper: operetion to be performed. Either "add", "sub", "mult" or "div".
19
  """
20
+
21
+ if oper == "add":
22
+ result = a + b
23
+ elif oper == "sub":
24
+ result = a - b
25
+ elif oper == "mult":
26
+ result = a * b
27
+ elif oper == "div":
28
+
29
+ #try:
30
+ # result = a / b
31
+ #except ZeroDivisionError:
32
+ # result = "inf"
33
+
34
+
35
+ if b == 0:
36
+ return "Error: Division by zero."
37
+ result = a / b
38
+ else:
39
+ return "Error: Invalid operation."
40
+
41
+ return str(result)
42
+
43
 
44
  @tool
45
  def get_current_time_in_timezone(timezone: str) -> str:
 
59
 
60
  final_answer = FinalAnswerTool()
61
  model = HfApiModel(
62
+ max_tokens=2096,
63
+ temperature=0.5,
64
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
65
+ custom_role_conversions=None,
66
  )
67
 
68
 
 
74
 
75
  agent = CodeAgent(
76
  model=model,
77
+ tools=[final_answer, DuckDuckGoSearchToolSpec, calculator, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
78
  max_steps=6,
79
  verbosity_level=1,
80
  grammar=None,