mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ from litellm.exceptions import ( # noqa
|
||||
APIError,
|
||||
AuthenticationError,
|
||||
BadRequestError,
|
||||
ContentPolicyViolationError,
|
||||
ContextWindowExceededError,
|
||||
InternalServerError,
|
||||
NotFoundError,
|
||||
@@ -250,7 +251,12 @@ class AgentController:
|
||||
self.state.last_error = err_id
|
||||
elif isinstance(e, BadRequestError) and 'ExceededBudget' in str(e):
|
||||
err_id = 'STATUS$ERROR_LLM_OUT_OF_CREDITS'
|
||||
# Set error reason for budget exceeded
|
||||
self.state.last_error = err_id
|
||||
elif isinstance(e, ContentPolicyViolationError) or (
|
||||
isinstance(e, BadRequestError)
|
||||
and 'ContentPolicyViolationError' in str(e)
|
||||
):
|
||||
err_id = 'STATUS$ERROR_LLM_CONTENT_POLICY_VIOLATION'
|
||||
self.state.last_error = err_id
|
||||
elif isinstance(e, RateLimitError):
|
||||
await self.set_agent_state_to(AgentState.RATE_LIMITED)
|
||||
@@ -283,6 +289,7 @@ class AgentController:
|
||||
or isinstance(e, InternalServerError)
|
||||
or isinstance(e, AuthenticationError)
|
||||
or isinstance(e, RateLimitError)
|
||||
or isinstance(e, ContentPolicyViolationError)
|
||||
or isinstance(e, LLMContextWindowExceedError)
|
||||
):
|
||||
reported = e
|
||||
|
||||
Reference in New Issue
Block a user