Skip to content

Conversation

@bhaktatejas922
Copy link
Contributor

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • ...
  • New functionality
    • ...

Test plan

How are these changes tested?

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

Documentation Changes

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

@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Jul 7, 2025

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.
• Full configuration/serialization methods and schema validation (Python and TypeScript).
• Comprehensive TypeScript provider implementation (new package: @chroma-core/morph) with registration, config schema, and batch embedding support.
• Adds Morph to the official list of embedding providers, schemas, and integration documentation in both Python and JS.
• Test suite for Morph embedding functionality and configuration roundtrips.
• Docs and README entries for Morph usage and best practices.
• Updates embedding function registries, schemas, package manifests, documentation tables, and codebase-wide embedding lists.

Affected Areas

• Embedding function system (Python and TypeScript)
• Test suites (Python)
• Chroma documentation (integration docs, embedding tables, usage guides)
• JS/TS package ecosystem and build system
• Schemas for config and validation

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

@github-actions
Copy link

github-actions bot commented Jul 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)

api_key_env_var?: string;
}

export class MorphEmbeddingFunction implements EmbeddingFunction {
Copy link
Contributor

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() and supportedSpaces() methods.
  • Static buildFromConfig(config) and validateConfig(config) methods.
  • getConfig() and validateConfigUpdate(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.

Comment on lines 54 to 56
} catch (error) {
throw new Error(`Morph embedding generation failed: ${error}`);
}
Copy link
Contributor

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.

Suggested change
} 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 jeffchuber self-requested a review July 27, 2025 03:29
Copy link
Contributor

@jeffchuber jeffchuber left a comment

Choose a reason for hiding this comment

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

thanks!

bhaktatejas922 and others added 2 commits July 26, 2025 20:31
Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com>
@jeffchuber jeffchuber changed the title Add Morph Embeddings Provider [ENH] Add Morph Embeddings Provider Jul 27, 2025
philipithomas added a commit that referenced this pull request Aug 1, 2025
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]>
@philipithomas
Copy link
Member

Merged in #5183

Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
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]>
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.

3 participants