pyseekdb.utils.embedding_functions.QwenEmbeddingFunction

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

Bases: OpenAIBaseEmbeddingFunction

A convenient embedding function for Qwen (Alibaba Cloud) embedding models.

This class provides a simplified interface to Qwen embedding models using the OpenAI-compatible API. Qwen provides OpenAI-compatible API endpoints for embedding generation.

Example

pip install pyseekdb openai

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

Initialize QwenEmbeddingFunction.

Parameters:
  • model_name (str) – Name of the Qwen embedding model. See Qwen documentation for available models.

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

  • api_base (str, optional) – Base URL for the Qwen API endpoint. Defaults to “https://dashscope.aliyuncs.com/compatible-mode/v1” if not provided.

  • dimensions (int, optional) – The number of dimensions the resulting embeddings should have. Can reduce dimensions from default. You can check the Qwen official documentation for details.

  • **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, ...])

Initialize QwenEmbeddingFunction.

build_from_config(config)

get_config()

Get the configuration dictionary for the QwenEmbeddingFunction.

name()

Get the unique name identifier for QwenEmbeddingFunction.

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 QwenEmbeddingFunction.

Returns:

Dictionary containing configuration needed to restore this embedding function

static name() str[source]

Get the unique name identifier for QwenEmbeddingFunction.

Returns:

The name identifier for this embedding function type