petrov826 commited on
Commit
862c828
·
verified ·
1 Parent(s): 4e86d66

replace custom rate limiter with wait tool

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,10 +1,12 @@
1
  import os
 
2
  import gradio as gr
3
  import litellm
4
  import requests
5
  import inspect
6
  import pandas as pd
7
  from smolagents import (
 
8
  Tool,
9
  CodeAgent,
10
  LiteLLMModel,
@@ -38,7 +40,18 @@ CUSTOM_PROMPT = """
38
  When downloading files, try to download them in python code before visiting the website.
39
  """
40
 
41
- rate_limiter = RateLimiter()
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  # --- Basic Agent Definition ---
44
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
@@ -56,9 +69,10 @@ class BasicAgent:
56
  WikipediaTool(),
57
  YoutubeTranscriptTool(),
58
  AssemblyAIAudioTranscriptTool(),
 
59
  ],
60
  model=model,
61
- step_callbacks=[rate_limiter.increment_and_sleep_if_needed],
62
  additional_authorized_imports=["pandas", "openpyxl", "requests"],
63
  instructions=CUSTOM_PROMPT
64
  )
 
1
  import os
2
+ import time
3
  import gradio as gr
4
  import litellm
5
  import requests
6
  import inspect
7
  import pandas as pd
8
  from smolagents import (
9
+ tool,
10
  Tool,
11
  CodeAgent,
12
  LiteLLMModel,
 
40
  When downloading files, try to download them in python code before visiting the website.
41
  """
42
 
43
+ # rate_limiter = RateLimiter()
44
+
45
+ @tool
46
+ def wait(seconds: int = 60) -> None:
47
+ """
48
+ This tool is used to wait for a certain amount of time.
49
+ Use this tool if you encountered RPM(Requests per minute) or TMP(Tokens per minute) when calling the API.
50
+
51
+ Args:
52
+ seconds (int): How many seconds to wait. Default value is 60.
53
+ """
54
+ time.sleep(seconds)
55
 
56
  # --- Basic Agent Definition ---
57
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
69
  WikipediaTool(),
70
  YoutubeTranscriptTool(),
71
  AssemblyAIAudioTranscriptTool(),
72
+ wait,
73
  ],
74
  model=model,
75
+ # step_callbacks=[rate_limiter.increment_and_sleep_if_needed],
76
  additional_authorized_imports=["pandas", "openpyxl", "requests"],
77
  instructions=CUSTOM_PROMPT
78
  )