Skip to content

feat(genai/embeddings): migrate code retrieval and model tuning examples to genai - #14475

Draft
XrossFox wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
XrossFox:vertex-to-genai-language-models
Draft

feat(genai/embeddings): migrate code retrieval and model tuning examples to genai#14475
XrossFox wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
XrossFox:vertex-to-genai-language-models

Conversation

@XrossFox

@XrossFox XrossFox commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR migrates and introduces new code examples for Vertex AI and GenAI embeddings.

Changes:

  • feat: Added model_tuning_example.py to demonstrate text embedding model tuning using Vertex AI pipelines (aiplatform).
  • feat: Added code_retrieval_example.py to demonstrate source code indexing and code retrieval queries using the google-genai SDK.
  • test: Created test cases for the new examples in test_embeddings_examples.py.
  • chore: Updated dependencies in requirements.txt and requirements-test.txt (bumped google-genai, pytest,
    google-api-core, and added google-cloud-aiplatform).

Fixes b/540948638

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Aug 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new example script, code_retrieval_example.py, demonstrating how to use the Google GenAI SDK for code retrieval embeddings. The feedback highlights a few areas for improvement: correcting the return type annotation of the embed_test function to return response objects instead of config objects, removing an unused and unsupported DIMENSIONALITY constant, and ensuring consistent usage of the imported types module instead of referencing genai.types directly.

Comment thread genai/embeddings/code_retrieval_example.py Outdated
Comment thread genai/embeddings/code_retrieval_example.py Outdated
Comment thread genai/embeddings/code_retrieval_example.py Outdated
Comment thread genai/embeddings/code_retrieval_example.py Outdated
implementation of embedded model tuning.
- Added missing python doc.
- Updated requirements files.
- created tests for migrated samples.
@XrossFox XrossFox changed the title PLACEHOLDER: Migrate code retrieval example for embeddings to genai. feat(genai/embeddings): migrate code retrieval and model tuning examples to genai Aug 6, 2026
@XrossFox

XrossFox commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two new embedding examples: code_retrieval_example.py for indexing and searching source code using the Gemini API, and model_tuning_example.py for tuning text embedding models via Vertex AI Pipelines. It also updates dependencies and adds corresponding unit tests. Feedback highlights several improvement opportunities, including mocking the Vertex AI Pipeline job in tests to prevent executing expensive live jobs, removing unused constants in both example files, correcting an incorrect return type hint in the code retrieval example, and fixing a typo in a test function name.

Comment thread genai/embeddings/test_embeddings_examples.py
Comment thread genai/embeddings/code_retrieval_example.py Outdated
Comment thread genai/embeddings/code_retrieval_example.py
Comment thread genai/embeddings/model_tuning_example.py Outdated
Comment thread genai/embeddings/test_embeddings_examples.py Outdated
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.

1 participant