-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallback Model Support #516
Comments
Fixes pydantic#516 Add support for fallback models in the `Agent` class. * **Agent Class Changes:** - Add `fallback_models` attribute to store a list of fallback models. - Modify `run`, `run_sync`, and `run_stream` methods to iterate through `fallback_models` if the primary model fails. - Update `_get_model` method to handle fallback models. * **Model and AgentModel Classes Changes:** - Add `fallback_models` attribute to `Model` and `AgentModel` classes. * **Tests:** - Add tests in `tests/test_agent.py` to verify the functionality of fallback models.
I think the API can be as Simple as model = FallbackModel('openai:gpt-4o', 'claude-3-5-haiku-latest', GeminiModel(...))
agent = Agent(model, ...) E.g. the signature of class FallbackModel:
def __init__(self, default_model: models.Model | models.KnownModelName, *fallback_models: models.Model | models.KnownModelName):
... |
Implemented a pydantic-ai FallbackModel some time ago here, in case there is interest: |
Another advantage of having a consistent way to detect 503 etc. responses, is we can use it to mark live tests as xfail when the underlying model fails. |
It´s actually quite funny what kind of things all can be done at model level. I now added a model to |
Will be starting work on this later today. PR to come soon 👍 |
Awesome, thanks so much @phil65! |
To mitigate issues with unpredictable LLM downtime: we'd like to add a new model that supports a list of models to use as fallbacks if the first doesn't work.
The text was updated successfully, but these errors were encountered: