Spaces:
Sleeping
Sleeping
Added my own tool
Browse files
app.py
CHANGED
@@ -3,20 +3,26 @@ 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
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
def
|
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 |
-
|
17 |
-
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -35,6 +41,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
35 |
|
36 |
|
37 |
final_answer = FinalAnswerTool()
|
|
|
38 |
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
@@ -55,7 +62,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 math
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
+
def pythagoreas_tool(number1:int, number2:int)-> float: #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 does nothing yet
|
16 |
Args:
|
17 |
+
number1: the first number
|
18 |
+
number2: the second number
|
19 |
"""
|
20 |
+
try:
|
21 |
+
c = math.sqrt((number1**2)+(number2**2))
|
22 |
+
except error:
|
23 |
+
-1
|
24 |
+
|
25 |
+
return c
|
26 |
|
27 |
@tool
|
28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
41 |
|
42 |
|
43 |
final_answer = FinalAnswerTool()
|
44 |
+
duckDuckGoSearch = DuckDuckGoSearchTool()
|
45 |
|
46 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
47 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
62 |
|
63 |
agent = CodeAgent(
|
64 |
model=model,
|
65 |
+
tools=[final_answer,pythagoreas_tool,duckDuckGoSearch,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
66 |
max_steps=6,
|
67 |
verbosity_level=1,
|
68 |
grammar=None,
|