pyseekdb.utils.embedding_functions.MorphEmbeddingFunction

class pyseekdb.utils.embedding_functions.MorphEmbeddingFunction(model_name: str, api_key_env: str | None = None, api_base: str | None = None, **kwargs: Any)[source]

Bases: OpenAIBaseEmbeddingFunction

A convenient embedding function for Morph embedding models.

This class provides a simplified interface to Morph embedding models using the OpenAI-compatible API.

Example

pip install pyseekdb openai

__init__(model_name: str, api_key_env: str | None = None, api_base: str | None = None, **kwargs: Any)[source]

Initialize MorphEmbeddingFunction.

Parameters:
  • model_name (str) – Name of the Morph embedding model.

  • api_key_env (str, optional) – Name of the environment variable containing the Morph API key. Defaults to “MORPH_API_KEY” if not provided.

  • api_base (str, optional) – Base URL for the Morph API endpoint. Defaults to “https://api.morphllm.com/v1” if not provided.

  • **kwargs – Additional arguments to pass to the OpenAI client. Common options include: - timeout: Request timeout in seconds - max_retries: Maximum number of retries - See https://github.com/openai/openai-python for more options

Methods

__init__(model_name[, api_key_env, api_base])

Initialize MorphEmbeddingFunction.

build_from_config(config)

get_config()

Get the configuration dictionary for the OpenAIBaseEmbeddingFunction.

name()

Get the unique name identifier for MorphEmbeddingFunction.

support_persistence(embedding_function)

Check if the embedding function supports persistence.

Attributes

dimension

Get the dimension of embeddings produced by this function.

get_config() dict[str, Any][source]

Get the configuration dictionary for the OpenAIBaseEmbeddingFunction.

Subclasses should override the name() method to provide the correct name for routing.

Returns:

Dictionary containing configuration needed to restore this embedding function

static name() str[source]

Get the unique name identifier for MorphEmbeddingFunction.

Returns:

The name identifier for this embedding function type