Skip to content

Fallback to a different model in RetryChatModel #436

@ashwin153

Description

@ashwin153
  • We have a recurring problem with Anthropic Overloaded exceptions
  • We want to fallback to a different model (either a different version or a different provider)
  • It would be cool if we could do something like the following.
RetryChatModel(
    ...,
    retries=[
        AnthropicChatModel("claude-3-7-sonnet-latest"),
        AnthropicChatModel("claude-3-5-sonnet-latest"),
        OpenAiChatModel("40"),
    ],
)
  • Maybe also support selecting a different model depending on the exception?
def _model_selector(attempt: int, exception: Exception) -> ChatModel | None:
    ...

RetryChatModel(
    ...,
    retries=_model_selector,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions