mirror of
https://github.com/browser-use/browser-use
synced 2026-05-13 17:56:35 +02:00
add anthropic RateLimitError to list of defined rate limit errors
This commit is contained in:
@@ -563,8 +563,16 @@ class Agent(Generic[Context]):
|
||||
else:
|
||||
from google.api_core.exceptions import ResourceExhausted
|
||||
from openai import RateLimitError
|
||||
from anthropic import RateLimitError as AnthropicRateLimitError
|
||||
|
||||
if isinstance(error, RateLimitError) or isinstance(error, ResourceExhausted):
|
||||
# Define a tuple of rate limit error types for easier maintenance
|
||||
RATE_LIMIT_ERRORS = (
|
||||
RateLimitError, # OpenAI
|
||||
ResourceExhausted, # Google
|
||||
AnthropicRateLimitError, # Anthropic
|
||||
)
|
||||
|
||||
if isinstance(error, RATE_LIMIT_ERRORS):
|
||||
logger.warning(f'{prefix}{error_msg}')
|
||||
await asyncio.sleep(self.settings.retry_delay)
|
||||
self.state.consecutive_failures += 1
|
||||
|
||||
Reference in New Issue
Block a user