Skip to content

[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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bhaktatejas922
Copy link

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?

Copy link
Contributor

propel-code-bot bot commented Jul 7, 2025

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.
• Implements MorphEmbeddingFunction for JS/TS with config management, schema validation, OpenAI-compatible Morph API integration, and proper registration.
• Introduces new JSON schema (schemas/embedding_functions/morph.json) for robust config validation.
• Comprehensive pytest suite in chromadb/test/ef/test_morph_ef.py.
• JS package @chroma-core/morph: code, README, package.json, and tsconfig.
• Public documentation: markdoc and raw markdown for docs site and integrations table updates.
• Updates embedding function registry and boilerplate (Python & JS) to support Morph integration out-of-the-box.
• Enhances documentation tables and features lists to include Morph as a supported embedding function.
• Extends schema-utils.ts and embedding function registry for Morph.
• Refactors and expands testef.py and all/package.json to include Morph.

Affected Areas

• Python embedding functions (new provider registration and config logic)
• TypeScript/JS embedding function packages (new package and registry lines)
• Schemas/validation for embedding functions
• Public documentation (usage guides, tutorials, integrations tables, features lists)
• Readme, tests, and registry bootstrap code for embedding functions in both Python and JS
• Test harness

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

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
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.

2 participants