-
Notifications
You must be signed in to change notification settings - Fork 2k
[ENH] Add google genai embedding function #5836
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
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
|
Introduce Adds first-class support for Google GenAI text embeddings by implementing Key Changes• Implemented new class Affected Areas• This summary was automatically generated by @propel-code-bot |
chromadb/utils/embedding_functions/google_embedding_function.py
Outdated
Show resolved
Hide resolved
chromadb/utils/embedding_functions/google_embedding_function.py
Outdated
Show resolved
Hide resolved
af19fee to
2b175da
Compare
| 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 |
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.
[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
| 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
chromadb/utils/embedding_functions/google_embedding_function.py
Outdated
Show resolved
Hide resolved
2b175da to
828afb4
Compare

Description of changes
Summarize the changes made by this PR.
fixes [Bug]: Gemini wrapper in Python relies on deprecated library #5177
Test plan
How are these changes tested?
pytestfor python,yarn testfor js,cargo testfor rustMigration 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?