pyseekdb.utils.embedding_functions.JinaEmbeddingFunction

class pyseekdb.utils.embedding_functions.JinaEmbeddingFunction(model_name: str = 'jina-embeddings-v3', api_key_env: str | None = None, **kwargs: Any)[source]

Bases: LiteLLMBaseEmbeddingFunction

A convenient embedding function for Jina AI embedding models.

This class provides a simplified interface to Jina AI embedding models using LiteLLM.

For more information about Jina AI models, see https://jina.ai/embeddings

For LiteLLM documentation, see https://docs.litellm.ai/docs/embedding/supported_embedding

Example

pip install pyseekdb litellm

__init__(model_name: str = 'jina-embeddings-v3', api_key_env: str | None = None, **kwargs: Any)[source]

Initialize JinaEmbeddingFunction.

Parameters:
  • model_name (str, optional) – Name of the Jina AI embedding model. Defaults to “jina-embeddings-v3”. See Jina AI documentation for all available models: https://jina.ai/embeddings

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

  • **kwargs – Additional arguments to pass to LiteLLM.

  • https (See) – //docs.litellm.ai/docs/providers/jina_ai#sample-usage—embedding for more information.

Methods

__init__([model_name, api_key_env])

Initialize JinaEmbeddingFunction.

build_from_config(config)

Build a JinaEmbeddingFunction from its configuration dictionary.

get_config()

Get the configuration dictionary for the JinaEmbeddingFunction.

name()

Get the unique name identifier for JinaEmbeddingFunction.

support_persistence(embedding_function)

Check if the embedding function supports persistence.

Attributes

dimension

Get the dimension of embeddings produced by this function.

static build_from_config(config: dict[str, Any]) JinaEmbeddingFunction[source]

Build a JinaEmbeddingFunction from its configuration dictionary.

Parameters:

config – Dictionary containing the embedding function’s configuration

Returns:

Restored JinaEmbeddingFunction instance

Raises:

ValueError – If the configuration is invalid or missing required fields

property dimension: int

Get the dimension of embeddings produced by this function.

Returns the known dimension for models without making an API call. If the model is in the known dimensions list, that value is returned.

If the model is not in the known dimensions list, falls back to making an API call to get the embedding and infer the dimension.

Returns:

The dimension of embeddings for this model.

Return type:

int

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

Get the configuration dictionary for the JinaEmbeddingFunction.

Returns:

Dictionary containing configuration needed to restore this embedding function

static name() str[source]

Get the unique name identifier for JinaEmbeddingFunction.

Returns:

The name identifier for this embedding function type