Skip to content

Conversation

bwook00
Copy link
Contributor

@bwook00 bwook00 commented Jul 24, 2025

Description

Add Google Embedding provider

@Pouyanpi,

I used langchain-google-genai.

However, if you're worried about the ‘langchain dependency’, I can change the method to directly use from google import genai.

Related Issue(s)

Fixes #1292

Checklist

  • I've read the CONTRIBUTING guidelines.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • @mentions of the person or team responsible for reviewing proposed changes.

Copy link
Contributor

Documentation preview

https://nvidia.github.io/NeMo-Guardrails/review/pr-1304

@Pouyanpi Pouyanpi requested review from Pouyanpi and Copilot July 29, 2025 12:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds Google embedding integration to the NeMo Guardrails project by implementing a new GoogleEmbeddingModel provider that uses the langchain-google-genai library.

  • Implements GoogleEmbeddingModel class with sync/async embedding capabilities
  • Adds comprehensive test suite for Google embeddings functionality
  • Updates documentation to include Google as a supported embedding provider

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
nemoguardrails/embeddings/providers/google.py Main implementation of GoogleEmbeddingModel class with encoding methods
nemoguardrails/embeddings/providers/init.py Registers the Google embedding provider in the system
tests/test_embeddings_google.py Comprehensive test suite including sync/async tests and live integration tests
tests/test_configs/with_google_embeddings/config.yml Test configuration for Google embeddings
tests/test_configs/with_google_embeddings/config.co Test flow configuration
docs/user-guides/configuration-guide.md Documentation update adding Google to supported providers table
Comments suppressed due to low confidence (1)

tests/test_embeddings_google.py:70

  • This function has the same name as the async function on line 52 but different signature. Consider renaming to 'test_sync_live_query' to differentiate from the async version.
def test_live_query(app):

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 40.90909% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.40%. Comparing base (bee719b) to head (4e0cd50).

Files with missing lines Patch % Lines
nemoguardrails/embeddings/providers/google.py 35.00% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1304      +/-   ##
===========================================
- Coverage    70.45%   70.40%   -0.05%     
===========================================
  Files          161      162       +1     
  Lines        16214    16235      +21     
===========================================
+ Hits         11423    11431       +8     
- Misses        4791     4804      +13     
Flag Coverage Δ
python 70.40% <40.90%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
nemoguardrails/embeddings/providers/__init__.py 96.42% <100.00%> (+0.13%) ⬆️
nemoguardrails/embeddings/providers/google.py 35.00% <35.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Pouyanpi Pouyanpi added this to the v0.16.0 milestone Aug 1, 2025
@Pouyanpi Pouyanpi removed this from the v0.16.0 milestone Aug 18, 2025
@Pouyanpi
Copy link
Collaborator

Hi @bwook00, once again thanks for your patience on this PR.

I have one request: could you please use the google-genai SDK directly instead of langchain-google-genai? This keeps our embedding providers consistent with how we handle other external APIs (OpenAI, Cohere, etc.).

How we'll proceed:
0. We'll merge #1446

  1. We'll merge feat: add Cohere embedding integration #1305 (Cohere) first
  2. Once merged, please rebase your PR onto develop
  3. Add mock-based tests following the pattern in tests/test_embeddings_providers_mock.py

In the meantime you can update your implementation to use google-genai directly.

The testing infrastructure is now in place, so once you rebase and make these changes, we should be able to merge quickly.
Definitely we'll include your PRs in 0.18.0 release.

Please let me know if you have any questions!

@Pouyanpi Pouyanpi added this to the v0.18.0 milestone Oct 10, 2025
@Pouyanpi Pouyanpi added the enhancement New feature or request label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Add Google embedding provider

3 participants