pyseekdb.utils.embedding_functions.TencentHunyuanEmbeddingFunction
- class pyseekdb.utils.embedding_functions.TencentHunyuanEmbeddingFunction(model_name: str = 'hunyuan-embedding', api_key_env: str | None = None, api_base: str | None = None, dimensions: int | None = None, **kwargs: Any)[source]
Bases:
OpenAIBaseEmbeddingFunctionA convenient embedding function for Tencent Hunyuan embedding models.
This class provides a simplified interface to Tencent Hunyuan embedding models using the OpenAI-compatible API. Tencent Hunyuan provides OpenAI-compatible API endpoints for embedding generation.
For more information about Tencent Hunyuan models, see https://cloud.tencent.com/document/product/1729/111007
Note: The embedding interface currently only supports input and model parameters. The model is fixed as hunyuan-embedding and dimensions are fixed at 1024.
Example
pip install pyseekdb openai
- __init__(model_name: str = 'hunyuan-embedding', api_key_env: str | None = None, api_base: str | None = None, dimensions: int | None = None, **kwargs: Any)[source]
Initialize TencentHunyuanEmbeddingFunction.
- Parameters:
model_name (str, optional) – Name of the Tencent Hunyuan embedding model. Defaults to “hunyuan-embedding”. Currently, this is the only supported model.
api_key_env (str, optional) – Name of the environment variable containing the Tencent Hunyuan API key. Defaults to “HUNYUAN_API_KEY” if not provided.
api_base (str, optional) – Base URL for the Tencent Hunyuan API endpoint. Defaults to “https://api.hunyuan.cloud.tencent.com/v1” if not provided.
dimensions (int, optional) – This parameter is not supported by the Tencent Hunyuan API. Dimensions are fixed at 1024. If provided, a warning will be issued and the parameter will be ignored.
**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 TencentHunyuanEmbeddingFunction.
build_from_config(config)Get the configuration dictionary for the OpenAIBaseEmbeddingFunction.
name()support_persistence(embedding_function)Check if the embedding function supports persistence.
Attributes
Get the dimension of embeddings produced by this function.
- 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 dimensions parameter is specified, that value is returned. Otherwise, the default dimension for the model is returned.
If the model is not in the known dimensions list, falls back to calling the parent’s dimension detection (which may make an API call).
- Returns:
The dimension of embeddings for this model.
- Return type:
int