Spaces:
Sleeping
Sleeping
added stats tool
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
| 2 |
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
|
|
@@ -17,6 +17,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 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:
|
|
@@ -55,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer,get_current_time_in_timezone,image_generation_tool], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
+
import yaml,statistics
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
|
|
|
| 17 |
arg2: the second argument
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
+
@tool
|
| 21 |
+
def basic_statistics(numbers:list[float]) -> str:
|
| 22 |
+
"""this function calculates the mean,median,mode for the provided list of numbers
|
| 23 |
+
args:
|
| 24 |
+
numbers : a list of numbers
|
| 25 |
+
"""
|
| 26 |
+
try:
|
| 27 |
+
avg = statistics.mean(numbers)
|
| 28 |
+
med = statistics.median(numbers)
|
| 29 |
+
mod = statistics.mode(numbers)
|
| 30 |
+
return f"stats for your provided numbers are average/mean : {avd}\n median : {med} \n mode : {mod}\n "
|
| 31 |
+
except Exception as e:
|
| 32 |
+
return f"error in processing:{str(e)} "
|
| 33 |
|
| 34 |
@tool
|
| 35 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[final_answer,get_current_time_in_timezone,image_generation_tool,basic_statistics], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|