Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 10 commits into from
Jan 27, 2025

Conversation

holtskinner
Copy link
Contributor

  • 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
@holtskinner holtskinner requested review from a team as code owners January 22, 2025 19:25
Copy link

snippet-bot bot commented Jan 22, 2025

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.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 22, 2025
Copy link

@ghost ghost left a 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!

Copy link

@ghost ghost left a 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 the generative_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.

generative_ai/chat_completions/chat_completions_test.py Outdated Show resolved Hide resolved
@holtskinner holtskinner added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 22, 2025
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 23, 2025
@holtskinner holtskinner added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 23, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 23, 2025
@holtskinner holtskinner added snippet-bot:force-run Force snippet-bot runs its logic and removed snippet-bot:force-run Force snippet-bot runs its logic labels Jan 27, 2025
@davidcavazos davidcavazos merged commit a0caa62 into main Jan 27, 2025
14 checks passed
@davidcavazos davidcavazos deleted the chat-completions branch January 27, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.