pyseekdb.utils.embedding_functions.VoyageaiEmbeddingFunction

class pyseekdb.utils.embedding_functions.VoyageaiEmbeddingFunction(model_name: str = 'voyage-4-large', api_key_env: str | None = None, input_type: str | None = None, truncation: bool | None = None, output_dimension: int | None = None, **kwargs: Any)[source]

Bases: EmbeddingFunction[str | list[str]]

A convenient embedding function for Voyage AI embedding models.

This class provides a simplified interface to Voyage AI embedding models using the voyageai package.

For more information about Voyage AI models, see https://docs.voyageai.com/docs/embeddings

Example

pip install pyseekdb voyageai

__init__(model_name: str = 'voyage-4-large', api_key_env: str | None = None, input_type: str | None = None, truncation: bool | None = None, output_dimension: int | None = None, **kwargs: Any)[source]

Initialize VoyageaiEmbeddingFunction.

Parameters:
  • model_name (str, optional) – Name of the Voyage AI embedding model. Defaults to “voyage-4-large”. See Voyage AI documentation for all available models

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

  • input_type (str, optional) – Type of the input text. Options: None, “query”, “document”. When set to “query” or “document”, Voyage AI prepends a prompt to optimize embeddings for retrieval/search tasks. Defaults to None.

  • truncation (bool, optional) – Whether to truncate input texts to fit within context length. If True, over-length texts will be truncated. If False, an error will be raised for over-length texts. Defaults to None (uses Voyage AI default, which is True).

  • output_dimension (int, optional) – The number of dimensions for resulting embeddings. Supported values depend on the model. For voyage-4 series, voyage-3-large, voyage-3.5, voyage-3.5-lite, and voyage-code-3: 256, 512, 1024 (default), 2048. If None, uses the model’s default dimension.

  • **kwargs – Additional arguments (currently not used, reserved for future use).

Methods

__init__([model_name, api_key_env, ...])

Initialize VoyageaiEmbeddingFunction.

build_from_config(config)

get_config()

Get the configuration dictionary for the embedding function.

name()

support_persistence(embedding_function)

Check if the embedding function supports persistence.

Attributes

dimension

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

Get the configuration dictionary for the embedding function.

This method should return a dictionary that contains all the information needed to restore the embedding function after restart.

Returns:

Dictionary containing the embedding function’s configuration. Note: The ‘name’ field is not included as it’s handled by the upper layer for routing.