petrov826 commited on
Commit
eae1478
·
verified ·
1 Parent(s): f3ec160

translate Japanese comments into English

Browse files
Files changed (1) hide show
  1. rate_limiter.py +5 -3
rate_limiter.py CHANGED
@@ -3,7 +3,8 @@ from smolagents import CodeAgent, ActionStep
3
 
4
  class RateLimiter:
5
  """
6
- APIの呼び出し回数を数えて、一定回数の呼び出しが行われたら一定秒数待機する
 
7
  """
8
  def __init__(self, calls_per_wait: int = 10, seconds_to_wait: int = 60):
9
  self.calls_per_wait = calls_per_wait
@@ -12,11 +13,12 @@ class RateLimiter:
12
 
13
  def increment_and_sleep_if_needed(self, memory_step: ActionStep, agent: CodeAgent):
14
  """
15
- 呼び出し回数をインクリメントし、一定回数の呼び出しが行われたら一定秒数待機する
 
16
  """
17
  self._call_count += 1
18
 
19
  if self._call_count >= self.calls_per_wait:
20
- print(f"呼び出し回数が{self.calls_per_wait}回を超えたので{self.seconds_to_wait}秒待機します")
21
  time.sleep(self.seconds_to_wait)
22
  self._call_count = 0
 
3
 
4
  class RateLimiter:
5
  """
6
+ responsible for counting the number of API calls
7
+ and waiting for a certain number of seconds when a certain number of calls have been made.
8
  """
9
  def __init__(self, calls_per_wait: int = 10, seconds_to_wait: int = 60):
10
  self.calls_per_wait = calls_per_wait
 
13
 
14
  def increment_and_sleep_if_needed(self, memory_step: ActionStep, agent: CodeAgent):
15
  """
16
+ Increment the number of calls, and wait for a certain number of seconds
17
+ after a certain number of calls have been made.
18
  """
19
  self._call_count += 1
20
 
21
  if self._call_count >= self.calls_per_wait:
22
+ print(f"Since the number of calls exceeded {self.calls_per_wait} times, wait for {self.seconds_to_wait} seconds")
23
  time.sleep(self.seconds_to_wait)
24
  self._call_count = 0