Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
@@ -7,34 +8,41 @@ 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 my_custom_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
|
23 |
-
"""
|
|
|
24 |
Args:
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
"""
|
27 |
-
|
28 |
-
#
|
29 |
-
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ##
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
+
from typing import Dict
|
3 |
import datetime
|
4 |
import requests
|
5 |
import pytz
|
|
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
@tool
|
13 |
+
def calculate_bandwidth(users: int, usage: Dict[str, int]) -> float:
|
14 |
+
"""Calculate the recommended internet speed based on user inputs.
|
15 |
+
|
16 |
Args:
|
17 |
+
users: The total number of users requiring internet access.
|
18 |
+
usage: A dictionary with usage categories as keys and the number of users per category as values.
|
19 |
+
Expected keys are:
|
20 |
+
- "browsing": Number of users browsing the web.
|
21 |
+
- "video_call": Number of users on video calls.
|
22 |
+
- "hd_streaming": Number of users streaming in HD.
|
23 |
+
- "4k_streaming": Number of users streaming in 4K.
|
24 |
+
- "gaming": Number of users gaming online.
|
25 |
+
- "remote_work": Number of users working remotely.
|
26 |
"""
|
27 |
+
usage_requirements = {
|
28 |
+
"browsing": 1, # Mbps per user
|
29 |
+
"video_call": 2, # Mbps per user
|
30 |
+
"hd_streaming": 5, # Mbps per user
|
31 |
+
"4k_streaming": 25, # Mbps per user
|
32 |
+
"gaming": 10, # Mbps per user
|
33 |
+
"remote_work": 3 # Mbps per user
|
34 |
+
}
|
35 |
+
|
36 |
+
total_bandwidth = sum(usage_requirements[activity] * usage.get(activity, 0) for activity in usage_requirements)
|
37 |
+
overhead = 1.2 # 20% overhead for seamless experience
|
38 |
+
# Apply overhead of 1.2
|
39 |
+
total_bandwidth_with_overhead = total_bandwidth * overhead
|
40 |
+
|
41 |
+
return round(total_bandwidth_with_overhead, 2)
|
42 |
|
43 |
|
44 |
final_answer = FinalAnswerTool()
|
45 |
+
#duck_duck_go_search = DuckDuckGoSearchTool()
|
46 |
|
47 |
# 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:
|
48 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
63 |
|
64 |
agent = CodeAgent(
|
65 |
model=model,
|
66 |
+
tools=[final_answer,calculate_bandwidth], ## Internet bandwidth Calculator Tool
|
67 |
max_steps=6,
|
68 |
verbosity_level=1,
|
69 |
grammar=None,
|