-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[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
base: main
Are you sure you want to change the base?
Conversation
Add Morph Embeddings Provider (Python & TypeScript) with Integrations and Documentation This PR introduces full support for Morph code-optimized embeddings across Python and TypeScript SDKs in Chroma. It includes the implementation of MorphEmbeddingFunction for both ecosystems, schema and config management, package setup for JS, comprehensive test coverage, public documentation with usage/client guides, as well as integration into the embedding function registry and core Chroma documentation. Morph embeddings focus on code/syntax tree units and are powered via the OpenAI SDK pointed at Morph's API endpoint. Key Changes• Adds chromadb.utils.embedding_functions.morph_embedding_function.py (Python implementation) with configuration, validation, and API-key handling. Affected Areas• Python embedding functions (new provider registration and config logic) 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
name
property. defaultSpace()
andsupportedSpaces()
methods.- Static
buildFromConfig(config)
andvalidateConfig(config)
methods. getConfig()
andvalidateConfigUpdate(newConfig)
methods.- A call to
registerEmbeddingFunction
at 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.
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>
Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytest
for python,yarn test
for js,cargo test
for rustDocumentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?