-
Notifications
You must be signed in to change notification settings - Fork 51
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
Use LiteLLM in place of ChatOpenAI #84
Open
morganmcg1
wants to merge
19
commits into
main
Choose a base branch
from
add-model-fallback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add model-agnostic fallback system in base ChatModel - Implement error handling with retryable errors - Add model tracking in responses - Add comprehensive test suite for fallback behavior - Update Gemini model to use new error handling system
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
- Remove temp files - Update OpenAI model to use 'developer' role - Keep existing prompt logic
- Use LiteLLM for provider-agnostic interface - Handle OpenAI 'developer' role conversion - Simple error handling with retryable errors - Add comprehensive tests
- Use LiteLLM for provider-agnostic interface - Support latest models: * OpenAI GPT-4 Turbo Mini (128K) * Gemini 2.0 Flash (1M) * Claude 3 Haiku (200K) - Add comprehensive tests for: * Context window limits * Message format validation * Temperature validation * Error handling * Provider-specific message formats
- Remove custom fallback/retry logic - Use litellm.completion fallbacks parameter - Configure fallbacks in constructor - Update tests to match LiteLLM behavior
- Remove custom message format handling (LiteLLM handles it) - Remove custom retry/fallback logic (use LiteLLM's fallbacks param) - Update tests to match LiteLLM behavior
- Remove custom error type handling - Remove retryable flag (LiteLLM handles retries) - Update tests to match simpler error handling
- Remove provider-specific model files (LiteLLM handles it) - Remove token count tracking (not needed) - Update tests to match simpler response format
- Match original ChatModel descriptor pattern - Keep LiteLLM's provider-agnostic features - Update tests to match descriptor pattern
- Keep RESPONSE_SYNTHESIS_SYSTEM_PROMPT and RESPONSE_SYNTHESIS_PROMPT_MESSAGES - Update imports to use BaseChatModel - Keep LangChain interface compatibility
- Remove BaseChatModel import (not needed) - Update _load_chain to use ChatModel type hint
- Remove protobuf warning filters (not needed) - Keep pytest import
- No longer needed since we're using MagicMock - Provider-specific models have been removed - Mock functionality handled in test files
- No longer needed after removing warning filters - Only contained import pytest - No fixtures or test configuration needed
- Replace OpenAI client with ChatModel - Keep same model name (gpt-4o-2024-08-06) - Keep same temperature (0) - Add retries for reliability
- Move LiteLLM-based ChatModel to utils.py - Remove old ChatOpenAI-based ChatModel - Remove chat_model.py (no longer needed) - Update imports to use ChatModel from utils.py
morganmcg1
changed the title
Add cross-model fallback support and error handling
Use LiteLLM in place of ChatOpenAI
Dec 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a model-agnostic fallback system that allows using any model as a fallback for another model, with comprehensive error handling and testing.
Changes
Features
Example Usage