Morph
Morph lets you run and manage open-source models locally and provides an OpenAI-compatible API for generating embeddings. seekdb exposes MorphEmbeddingFunction, which calls Morph embedding models through an OpenAI-compatible interface.
Using OpenAI services requires you to follow OpenAI's pricing rules and may incur corresponding fees. Before proceeding, visit the official website or read the relevant documentation to confirm and accept their pricing. If you do not agree, do not continue.
Dependencies and environment
MorphEmbeddingFunction calls Morph embedding models through an OpenAI-compatible interface. You typically need:
The pyseekdb and openai packages installed in your Python environment.
pip install pyseekdb openai
Example: create a Morph embedding function
-
Use a Morph text embedding model
import pyseekdb
from pyseekdb.utils.embedding_functions import MorphEmbeddingFunction
ef = MorphEmbeddingFunction(
model_name="morph-embedding-v4"
) -
Use a custom
api_key_envimport pyseekdb
from pyseekdb.utils.embedding_functions import MorphEmbeddingFunction
ef = MorphEmbeddingFunction(
model_name="morph-embedding-v4",
api_key_env="MORPH_API_KEY"
)
Parameters:
-
model_name(str, optional): Morph embedding model name. -
api_key_env(str, optional): Environment variable name that holds the Morph API key. If omitted, defaults toMORPH_API_KEY. -
api_base(str, optional): Base URL for the Morph API endpoint. If omitted, defaults tohttps://api.morphllm.com/v1. -
kwargs: Additional arguments passed to the OpenAI client.Common options:
timeout: Request timeout in seconds.max_retries: Maximum number of retries.