-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/openai plugins anthropic #39
Merged
Merged
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 OPENAI_API_KEY as a fallback API key for GoogleOpenAI and PerplexityOpenAI clients - This allows using the OPENAI_API_KEY env var if provider-specific env vars are not set - Improves flexibility and ease of configuration for users of these OpenAI client classes
- Add `AnthropicChatCompletions` class to support chat completions using Anthropic API - Implement `create` and `_create_stream` methods (streaming not supported) - Validate `messages` parameter is non-empty - Add `AnthropicChat` class extending `OpenAIResources.Chat` - Use `AnthropicChatCompletions` for chat completions - Add `AnthropicModels` class extending `OpenAIResources.Models` - Support retrieving and listing a fixed set of Anthropic models - Add top-level `AnthropicOpenAI` class - Initialize `AnthropicChat` and `AnthropicModels` - Require Anthropic API key - Add tests for retrieving and listing Anthropic models
- Rename test_google_openai_chat_completions_create to test_pplx_openai_chat_completions_create - Rename test_google_openai_chat_completions_create_stream to test_pplx_openai_chat_completions_create_stream - Rename test_google_openai_models_retrieve to test_pplx_openai_models_retrieve - Rename test_google_openai_models_list to test_pplx_openai_models_list
- Remove unused imports (uuid, google.generativeai, GoogleNotFound, generation_types, ContentDict) - Add imports for Anthropic API (AnthropicMessageStream, AnthropicChatCompletionRequest) - Update AnthropicChatCompletions to use Anthropic API for create and _create_stream methods - Convert OpenAI chat completion request to Anthropic request format - Send request using Anthropic client and process response - Stream response using generator_generate_content_chunks method - Add anthropic_client attribute to AnthropicOpenAI class - Update AnthropicChatCompletionRequest to convert from OpenAI to Anthropic format - Handle system, user, and assistant roles - Set default max_tokens, temperature, and stream values
- Import necessary types: Stream, ChatCompletion, ChatCompletionChunk - Import ensure_chat_completion_message_params utility function - Add test_claude_openai_chat_completions_create to test creating a chat completion - Use ensure_chat_completion_message_params to format messages - Specify test_chat_model_name and temperature - Assert the response contains choices with a message - Add commented out test_claude_openai_chat_completions_create_stream (WIP) to test streaming chat completions
- Refactor `AnthropicChatCompletions.create` to extract the message stream from the context manager - Add docstring for `generator_generate_content_chunks` method - Enable and fix test for chat completion streaming
…nks method The generate_chat_completion_response_chunks method in the GoogleChatCompletions class now has a detailed docstring explaining its parameters, return value, and functionality. This improves code readability and maintainability.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #39 +/- ##
==========================================
+ Coverage 79.33% 79.52% +0.18%
==========================================
Files 70 71 +1
Lines 3112 3213 +101
==========================================
+ Hits 2469 2555 +86
- Misses 643 658 +15 ☔ View full report in Codecov by Sentry. |
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.
Anthropic API Client
AnthropicOpenAI
client class that integrates with the Anthropic API to access Claude modelsAnthropicChatCompletions
class to support chat completions and streaming with Anthropic modelsAnthropicChat
andAnthropicModels
classes to provide a consistent interface with the OpenAI APIAnthropicChatCompletionRequest
type to convert OpenAI chat completion requests to the Anthropic formatGoogle GenAI and Perplexity API Clients
OPENAI_API_KEY
environment variable if their specific API key env vars are not setgenerator_generate_content_chunks
method in the Google GenAI clientTests
AnthropicOpenAI
client, covering model retrieval, listing, and chat completions (both regular and streaming)test_pplx_openai
instead oftest_google_openai
)