Skip to content
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

Add fallback models support #532

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

The-CodeINN
Copy link

Fixes #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.

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.
@The-CodeINN The-CodeINN marked this pull request as draft December 23, 2024 07:47
@The-CodeINN The-CodeINN marked this pull request as ready for review December 23, 2024 08:56
@samuelcolvin
Copy link
Member

Sorry, as described on #516, this isn't the way we want to implement this feature.

Instead we'd like to introduce a new model that references multiple other models, e.g.:

@dataclass
class FallbackModel(Model):
    models: list[Model]

    ...

This should mean minimal changes to other parts of the system.

The hardest part is going to be raising an exception from models which we can detect relates to downtime - e.g. a HTTP response with code >=500 or unable to connect.

@samuelcolvin samuelcolvin marked this pull request as draft December 24, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fallback Model Support
2 participants