kdipakkumar commited on
Commit
beffa3f
·
verified ·
1 Parent(s): c716c87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -1
app.py CHANGED
@@ -4,8 +4,54 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from Gradio_UI import GradioUI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from Gradio_UI import GradioUI
8
+ from typing import Callable
9
+
10
+
11
+ class Tool:
12
+ """
13
+ A class representing a reusable piece of code (Tool).
14
+
15
+ Attributes:
16
+ name (str): Name of the tool.
17
+ description (str): A textual description of what the tool does.
18
+ func (callable): The function this tool wraps.
19
+ arguments (list): A list of arguments.
20
+ outputs (str or list): The return type(s) of the wrapped function.
21
+ """
22
+ def __init__(self,
23
+ name: str,
24
+ description: str,
25
+ func: Callable,
26
+ arguments: list,
27
+ outputs: str):
28
+ self.name = name
29
+ self.description = description
30
+ self.func = func
31
+ self.arguments = arguments
32
+ self.outputs = outputs
33
+
34
+ def to_string(self) -> str:
35
+ """
36
+ Return a string representation of the tool,
37
+ including its name, description, arguments, and outputs.
38
+ """
39
+ args_str = ", ".join([
40
+ f"{arg_name}: {arg_type}" for arg_name, arg_type in self.arguments
41
+ ])
42
+
43
+ return (
44
+ f"Tool Name: {self.name},"
45
+ f" Description: {self.description},"
46
+ f" Arguments: {args_str},"
47
+ f" Outputs: {self.outputs}"
48
+ )
49
+
50
+ def __call__(self, *args, **kwargs):
51
+ """
52
+ Invoke the underlying function (callable) with provided arguments.
53
+ """
54
+ return self.func(*args, **kwargs)
55
 
56
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
57
  @tool