Skip to content

feat: add Morph embedding function support#143

Merged
hnwyllmm merged 2 commits into
oceanbase:developfrom
chakkk309:add-Morph-embedding-function-support
Jan 31, 2026
Merged

feat: add Morph embedding function support#143
hnwyllmm merged 2 commits into
oceanbase:developfrom
chakkk309:add-Morph-embedding-function-support

Conversation

@chakkk309

@chakkk309 chakkk309 commented Jan 26, 2026

Copy link
Copy Markdown

Summary

Fix #136.

Support Morph embedding platform based on OpenAI.

Solution Description

Morph provides an OpenAI-compatible Embedding API and morph-embedding-v4 as the default model (1536 dimensions).

Morph test result:

 .venv/bin/python -m pytest tests/unit_tests/test_morph_embedding_function.py -vv
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.11.13, pytest-9.0.2, pluggy-1.6.0 -- /pyseekdb/.venv/bin/python
cachedir: .pytest_cache
rootdir: /pyseekdb
configfile: pyproject.toml
plugins: anyio-4.12.1
collected 22 items                                                                                                                                                                                         

tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_morph_env PASSED                                                                                                 [  4%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_initialization_with_model_name PASSED                                                                            [  9%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_initialization_with_custom_api_key_env PASSED                                                                    [ 13%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_initialization_with_custom_api_base PASSED                                                                       [ 18%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_initialization_with_kwargs PASSED                                                                                [ 22%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_initialization_missing_api_key PASSED                                                                            [ 27%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_initialization_missing_model_name PASSED                                                                         [ 31%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_dimension_property_known_model PASSED                                                                            [ 36%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_call_single_document PASSED                                                                                      [ 40%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_call_multiple_documents PASSED                                                                                   [ 45%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_call_empty_input PASSED                                                                                          [ 50%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_dimension_of_function PASSED                                                                                     [ 54%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_get_default_api_base PASSED                                                                                      [ 59%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_get_default_api_key_env PASSED                                                                                   [ 63%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunction::test_get_model_dimensions PASSED                                                                                      [ 68%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_name PASSED                                                                                           [ 72%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_get_config_with_defaults PASSED                                                                       [ 77%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_get_config_with_custom_values PASSED                                                                  [ 81%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_build_from_config_with_defaults PASSED                                                                [ 86%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_build_from_config_with_custom_values PASSED                                                           [ 90%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_build_from_config_with_dimensions_ignored PASSED                                                      [ 95%]
tests/unit_tests/test_morph_embedding_function.py::TestMorphEmbeddingFunctionPersistence::test_persistence_roundtrip PASSED                                                                          [100%]

============================================================================================ 22 passed in 3.97s ============================================================================================

Summary by CodeRabbit

  • New Features

    • Added Morph embedding function ("morph") with support for morph-embedding-v4, discoverable via the embedding registry
    • Configurable via environment variables and custom API endpoints
  • Tests

    • Added comprehensive unit tests covering initialization, configuration, dimensions, embedding calls, and persistence round-trips

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a MorphEmbeddingFunction implementation, registers it under the name "morph", exposes it in the public embedding_functions package, and introduces comprehensive unit tests for configuration and runtime behavior.

Changes

Cohort / File(s) Summary
Registry & Public API
src/pyseekdb/client/embedding_function.py, src/pyseekdb/utils/embedding_functions/__init__.py
Register MorphEmbeddingFunction in the embedding function registry ("morph") and export it via the package __all__.
Core Implementation
src/pyseekdb/utils/embedding_functions/morph_embedding_function.py
New MorphEmbeddingFunction subclass of OpenAIBaseEmbeddingFunction with model-dimension mapping, default API base/key methods, name(), get_config(), and build_from_config() including validation and warnings.
Tests
tests/unit_tests/test_morph_embedding_function.py
New comprehensive unit tests covering initialization, error conditions, dimensions, embedding calls (single/multiple/empty), config persistence, and default/custom API env/base behavior (skipped unless MORPH_API_KEY/OpenAI available).
Metadata / Packaging
manifest_file, requirements.txt, pyproject.toml
Small metadata/requirements lines added (+2 lines across manifests).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

"I'm a rabbit in the code, with a Morph in my paw,
I hop through registries, without a single flaw.
New embeddings I bring, with tests in a line,
Tiny paws, big changes — the registry's mine! 🐇✨"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: adding support for Morph embedding functions.
Linked Issues check ✅ Passed All coding objectives from issue #136 are met: MorphEmbeddingFunction implemented with OpenAI-compatible API, morph-embedding-v4 as default model with 1536 dimensions, and configuration/persistence support added.
Out of Scope Changes check ✅ Passed All changes are directly in-scope: MorphEmbeddingFunction implementation, registry integration, module exports, and corresponding unit tests align with issue #136 objectives.
Docstring Coverage ✅ Passed Docstring coverage is 93.55% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hnwyllmm hnwyllmm merged commit 35491a2 into oceanbase:develop Jan 31, 2026
7 checks passed
@chakkk309 chakkk309 deleted the add-Morph-embedding-function-support branch January 31, 2026 06:29
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.

[Enhancement]: Integrate morphllm embedding function

2 participants