-
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 google #37
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
**google.py** * Added `generation_config` parameter when calling `chat_session.send_message()` to allow setting the temperature. **test_google_openai.py** * Included a test case for Google Chat Completions that sets the temperature.
…ts encoding The simple_encode_sse function supports encoding bytes, text, Pydantic models, dictionaries, and lists into the SSE format. It handles unknown data types gracefully by encoding them as strings with a warning log. Add tests/utils/test_sse.py with test cases for simple_encode_sse The test cases cover encoding bytes, text, dictionaries, lists, and Pydantic models, ensuring the correctness of the simple_encode_sse function.
- Add `stream` method to `GoogleChatCompletions` class - Validate `messages` input - Convert messages to Google PaLM API format - Start chat session and send latest message - Return a streaming response of `ChatCompletionChunk`s - Add `generator_generate_content_chunks` method to generate chat completion chunks - Yield chunks for each generated content part - Yield final chunk with `finish_reason` - End the stream - Add `rand_chat_completion_id` utility function to generate random chat completion IDs
- Add new test `test_google_openai_chat_completion_create_stream` to verify streaming functionality - Import `Stream` and `ChatCompletionChunk` types for type hinting and casting - Iterate over the stream, checking for `finish_reason` and `delta.content` in the response
- Add GoogleModels class to support retrieving and listing Google models - Implement GoogleModels.retrieve() to get a specific model by name - Implement GoogleModels.list() to list all available Google models - Add GoogleModels to the GoogleOpenAI class - Add tests for GoogleModels.retrieve() and GoogleModels.list() - Handle GoogleNotFound exception in GoogleModels.retrieve() - Rename test methods for consistency
- Add GoogleEmbeddings class to handle embeddings API requests - Implement create() method in GoogleEmbeddings to call genai.embed_content() - Add embeddings attribute to GoogleOpenAI class - Add test case for GoogleOpenAI embeddings create API
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #37 +/- ##
==========================================
+ Coverage 78.81% 79.20% +0.38%
==========================================
Files 67 69 +2
Lines 2998 3078 +80
==========================================
+ Hits 2363 2438 +75
- Misses 635 640 +5 ☔ 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.
OpenAI Plugin Clients
GoogleOpenAI
client that wraps the Google GenAI API to provide an interface similar to the OpenAI APIGoogleChatCompletions
for creating chat completions and streaming chat completion chunksGoogleModels
for retrieving and listing available modelsGoogleEmbeddings
for creating embeddingslanguru/openai_plugins/clients/utils.py
for OpenAI client initialization parametersUtilities
languru/utils/openai_utils.py
with a helper functionrand_chat_completion_id()
to generate random chat completion IDslanguru/utils/prompt.py
with a helper functionensure_chat_completion_message_params()
to validate chat completion message parameterslanguru/utils/sse.py
with a helper functionsimple_encode_sse()
for simple Server-Sent Events (SSE) encodingTests
GoogleOpenAI
client intests/openai_plugins/test_google_openai.py
simple_encode_sse()
utility function intests/utils/test_sse.py