Skip to content

Conversation

@jairad26
Copy link
Contributor

@jairad26 jairad26 commented Nov 7, 2025

Description of changes

Summarize the changes made by this PR.

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

jairad26 commented Nov 7, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jairad26 jairad26 marked this pull request as ready for review November 7, 2025 23:12
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Nov 7, 2025

Introduce GoogleGenaiEmbeddingFunction and supporting artifacts

Adds first-class support for Google GenAI text embeddings by implementing GoogleGenaiEmbeddingFunction, supplying a JSON-schema for config validation, wiring it into the embedding-function registry, and extending the builtin test set. The change replaces soon-to-be-deprecated PaLM endpoints and keeps API surface consistent with existing embedding providers while enforcing config-schema validation and runtime input checks.

Key Changes

• Implemented new class GoogleGenaiEmbeddingFunction in chromadb/utils/embedding_functions/google_embedding_function.py (≈150 LoC) with constructor, __call__, schema driven config helpers, and safety checks
• Created config schema file schemas/embedding_functions/google_genai.json for JSON-schema validation of GenAI parameters (model_name, vertexai, project, location)
• Registered the new provider in chromadb/utils/embedding_functions/__init__.py (known_embedding_functions, __all__, built-ins set, test expectations)
• Updated unit test chromadb/test/ef/test_ef.py to assert presence of GoogleGenaiEmbeddingFunction in built-ins

Affected Areas

chromadb/utils/embedding_functions/google_embedding_function.py
chromadb/utils/embedding_functions/__init__.py
schemas/embedding_functions/google_genai.json
chromadb/test/ef/test_ef.py

This summary was automatically generated by @propel-code-bot

@jairad26 jairad26 force-pushed the jai/update-gemini-ef branch from af19fee to 2b175da Compare November 7, 2025 23:39
Comment on lines +66 to +71
try:
response = self.client.models.embed_content(
model=self.model_name, contents=input
)
except Exception as e:
raise ValueError(f"Failed to generate embeddings: {str(e)}") from e
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

Generic exception handling swallows all errors: Catching Exception on line 70 masks important error types like authentication failures, network issues, or API quota exceeded. This makes debugging difficult and hides actionable error information from users.

Suggested Change
Suggested change
try:
response = self.client.models.embed_content(
model=self.model_name, contents=input
)
except Exception as e:
raise ValueError(f"Failed to generate embeddings: {str(e)}") from e
try:
response = self.client.models.embed_content(
model=self.model_name, contents=input
)
except ImportError as e:
raise ValueError(f"Missing dependency: {str(e)}") from e
except ConnectionError as e:
raise ValueError(f"Network connection failed: {str(e)}") from e
except Exception as e:
raise ValueError(f"Failed to generate embeddings: {str(e)}") from e

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Context for Agents
[**BestPractice**]

Generic exception handling swallows all errors: Catching `Exception` on line 70 masks important error types like authentication failures, network issues, or API quota exceeded. This makes debugging difficult and hides actionable error information from users.

<details>
<summary>Suggested Change</summary>

```suggestion
        try:
            response = self.client.models.embed_content(
                model=self.model_name, contents=input
            )
        except ImportError as e:
            raise ValueError(f"Missing dependency: {str(e)}") from e
        except ConnectionError as e:
            raise ValueError(f"Network connection failed: {str(e)}") from e
        except Exception as e:
            raise ValueError(f"Failed to generate embeddings: {str(e)}") from e
```

⚡ **Committable suggestion**

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

</details>

File: chromadb/utils/embedding_functions/google_embedding_function.py
Line: 71

@jairad26 jairad26 force-pushed the jai/update-gemini-ef branch from 2b175da to 828afb4 Compare November 10, 2025 16:35
@jairad26 jairad26 enabled auto-merge (squash) November 10, 2025 16:36
@jairad26 jairad26 merged commit 833a982 into main Nov 10, 2025
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gemini wrapper in Python relies on deprecated library

3 participants