-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[ENH] Add Morph Embeddings Provider #5043
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
|
Add Morph Embeddings Provider to Chroma (Python & TypeScript) This PR adds the Morph embedding function integration across both Python and TypeScript clients, enabling users to generate code-optimized embeddings via Morph's remote API. The implementation includes full support for configuration, serialization, validation, and documentation, as well as tests and JS packaging updates for seamless usage and distribution. Key Changes• Introduces MorphEmbeddingFunction in Python (chromadb.utils.embedding_functions) with OpenAI-client-based Morph API interaction. Affected Areas• Embedding function system (Python and TypeScript) This summary was automatically generated by @propel-code-bot |
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
| api_key_env_var?: string; | ||
| } | ||
|
|
||
| export class MorphEmbeddingFunction implements EmbeddingFunction { |
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.
[CompanyBestPractice]
The TypeScript implementation for MorphEmbeddingFunction is missing several important methods for full integration with Chroma, such as configuration management and space information. This is inconsistent with both the Python implementation in this PR and other TypeScript embedding functions in the codebase.
To ensure consistency and full functionality (like config serialization), please implement the following:
- A
nameproperty. defaultSpace()andsupportedSpaces()methods.- Static
buildFromConfig(config)andvalidateConfig(config)methods. getConfig()andvalidateConfigUpdate(newConfig)methods.- A call to
registerEmbeddingFunctionat the end of the file.
You can use clients/new-js/packages/ai-embeddings/mistral/src/index.ts as a reference for a complete implementation.
| } catch (error) { | ||
| throw new Error(`Morph embedding generation failed: ${error}`); | ||
| } |
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]
The error handling here could be more robust by checking the type of the error and providing a more informative message.
| } catch (error) { | |
| throw new Error(`Morph embedding generation failed: ${error}`); | |
| } | |
| } catch (error) { | |
| if (error instanceof Error) { | |
| throw new Error(`Morph embedding generation failed: ${error.message}`); | |
| } | |
| throw new Error(`Morph embedding generation failed: ${String(error)}`); | |
| } |
⚡ 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.
jeffchuber
left a comment
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.
thanks!
Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com>
Supersedes #5043 --------- Co-authored-by: bhaktatejas922 <[email protected]> Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com> Co-authored-by: Jeffrey Huber <[email protected]>
|
Merged in #5183 |
Supersedes chroma-core#5043 --------- Co-authored-by: bhaktatejas922 <[email protected]> Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com> Co-authored-by: Jeffrey Huber <[email protected]>
Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytestfor python,yarn testfor js,cargo testfor rustDocumentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?