-
Notifications
You must be signed in to change notification settings - Fork 6.6k
docs(generative_ai): Update Chat Completions API samples #13088
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
Conversation
holtskinner
commented
Jan 22, 2025
- Fix imports (tests were failing)
- Add authentication sample
- Combine credentials refresher region tags
- Add samples for self-hosted models
- Fix imports (tests were failing) - Add authentication sample - Combine credentials refresher region tags - Add samples for self-hosted models
Here is the summary of changes. You are about to add 5 region tags.
You are about to delete 2 region tags.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team,
I'm currently reviewing this pull request and will have a full review in a few minutes. In the meantime, here's a quick summary for you and other reviewers to get up to speed:
This pull request, authored by holtskinner, aims to update the Chat Completions API samples within the python-docs-samples
repository. The key changes include:
- Fixes: Resolved failing tests related to imports.
- New Authentication Sample: Added a comprehensive sample demonstrating authentication using the OpenAI client.
- Credentials Refresher Consolidation: Streamlined the region tags for the credentials refresher.
- Self-Hosted Model Support: Introduced new samples specifically designed for interacting with self-hosted models.
The following files were modified:
File Name | Description |
---|---|
generative_ai/chat_completions/chat_completions_authentication.py |
Added a new sample for authentication using the OpenAI client. |
generative_ai/chat_completions/chat_completions_credentials_refresher.py |
Updated the credentials refresher, consolidating region tags and improving the code clarity. |
generative_ai/chat_completions/chat_completions_non_streaming_image.py |
Removed unnecessary imports (vertexai and openai). Updated to use google.auth.transport.requests for authentication |
generative_ai/chat_completions/chat_completions_non_streaming_text.py |
Removed unnecessary imports (vertexai and openai). Updated to use google.auth.transport.requests for authentication |
generative_ai/chat_completions/chat_completions_non_streaming_text_self_deployed.py |
Added a new sample for non-streaming text with self-deployed models. |
generative_ai/chat_completions/chat_completions_streaming_image.py |
Removed unnecessary imports (vertexai and openai). Updated to use google.auth.transport.requests for authentication |
generative_ai/chat_completions/chat_completions_streaming_text.py |
Removed unnecessary imports (vertexai and openai). Updated to use google.auth.transport.requests for authentication |
generative_ai/chat_completions/chat_completions_streaming_text_self_deployed.py |
Added a new sample for streaming text with self-deployed models. |
generative_ai/chat_completions/chat_completions_test.py |
Added tests for new samples and updated existing tests to reflect changes. |
generative_ai/chat_completions/requirements-test.txt |
Updated google-api-core version to 2.24.0 . |
generative_ai/chat_completions/requirements.txt |
Updated dependencies: google-cloud-aiplatform , google-auth , and openai . |
Specific changes within the files include updates to imports, authentication methods, and the addition of new functions for self-hosted models. The test suite has also been updated to ensure comprehensive coverage of the new features.
Here's a little something to brighten your day:
Code flows like a river,
Tests ensure the waters run clear,
Bugs are swept away.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request updates the Chat Completions API samples, including fixing imports, adding authentication and self-hosted model samples, and combining credentials refresher region tags. The changes are well-structured and address important aspects of using the API. Here's a summary of the elements I referenced from the style guide:
- Folder Location: Samples demonstrating the use of the
openai
library are correctly placed within thegenerative_ai/chat_completions
directory. - Python Versions: The samples and tests appear to be compatible with the supported Python versions.
- License Header: The new files include the Apache 2.0 license header.
- Descriptive Function Names: Function names are generally descriptive (e.g.,
generate_text
,test_authentication
). - Type Hinting: Type hints are used appropriately.
- README File: The changes necessitate updates to the relevant READMEs.
- Dependencies: The changes to the requirements files are appropriate.
- Region Tags: Region tags are used correctly to delimit code snippets.
- Testing: Unit tests are provided to verify the functionality of the code changes.