VP21 commited on
Commit
0a4fc7c
·
verified ·
1 Parent(s): 7784b07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -21,21 +21,18 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
21
 
22
  @tool
23
  def calculate_bandwidth(users: int, usage: Dict[str, int]) -> float:
24
- """
25
- Calculate the recommended internet speed based on user inputs.
26
-
27
- :param users: The total number of users requiring internet access.
28
- :type users: int
29
- :param usage: A dictionary with usage categories as keys. Expected keys are:
30
- "browsing" - Number of users browsing the web.
31
- "video_call" - Number of users on video calls.
32
- "hd_streaming" - Number of users streaming in HD.
33
- "4k_streaming" - Number of users streaming in 4K.
34
- "gaming" - Number of users gaming online.
35
- "remote_work" - Number of users working remotely.
36
- :type usage: Dict[str, int]
37
- :return: Recommended bandwidth in Mbps to ensure smooth performance.
38
- :rtype: float
39
  """
40
  usage_requirements = {
41
  "browsing": 1, # Mbps per user
@@ -46,8 +43,7 @@ def calculate_bandwidth(users: int, usage: Dict[str, int]) -> float:
46
  "remote_work": 3 # Mbps per user
47
  }
48
 
49
- total_bandwidth = sum(usage_requirements[activity] * count for activity, count in usage.items())
50
-
51
  overhead = 1.2 # 20% overhead for seamless experience
52
  return round(total_bandwidth * overhead, 2)
53
 
 
21
 
22
  @tool
23
  def calculate_bandwidth(users: int, usage: Dict[str, int]) -> float:
24
+ """Calculate the recommended internet speed based on user inputs.
25
+
26
+ Args:
27
+ users: The total number of users requiring internet access.
28
+ usage: A dictionary with usage categories as keys and the number of users per category as values.
29
+ Expected keys are:
30
+ - "browsing": Number of users browsing the web.
31
+ - "video_call": Number of users on video calls.
32
+ - "hd_streaming": Number of users streaming in HD.
33
+ - "4k_streaming": Number of users streaming in 4K.
34
+ - "gaming": Number of users gaming online.
35
+ - "remote_work": Number of users working remotely.
 
 
 
36
  """
37
  usage_requirements = {
38
  "browsing": 1, # Mbps per user
 
43
  "remote_work": 3 # Mbps per user
44
  }
45
 
46
+ total_bandwidth = sum(usage_requirements[activity] * usage.get(activity, 0) for activity in usage_requirements)
 
47
  overhead = 1.2 # 20% overhead for seamless experience
48
  return round(total_bandwidth * overhead, 2)
49