pyseekdb.utils.embedding_functions.SiliconflowEmbeddingFunction
- class pyseekdb.utils.embedding_functions.SiliconflowEmbeddingFunction(model_name: str = 'BAAI/bge-large-zh-v1.5', api_key_env: str | None = None, api_base: str | None = None, dimensions: int | None = None, **kwargs: Any)[source]
Bases:
OpenAIBaseEmbeddingFunctionA convenient embedding function for SiliconFlow embedding models.
This class provides a simplified interface to SiliconFlow embedding models using the OpenAI-compatible API. SiliconFlow provides OpenAI-compatible API endpoints for embedding generation.
For more information about SiliconFlow models, see https://docs.siliconflow.cn/en/api-reference/embeddings/create-embeddings
Example
pip install pyseekdb openai
- __init__(model_name: str = 'BAAI/bge-large-zh-v1.5', api_key_env: str | None = None, api_base: str | None = None, dimensions: int | None = None, **kwargs: Any)[source]
Initialize SiliconflowEmbeddingFunction.
- Parameters:
model_name (str, optional) – Name of the SiliconFlow embedding model. Defaults to “BAAI/bge-large-zh-v1.5”. See SiliconFlow documentation for available models: https://docs.siliconflow.cn/en/api-reference/embeddings/create-embeddings
api_key_env (str, optional) – Name of the environment variable containing the SiliconFlow API key. Defaults to “SILICONFLOW_API_KEY” if not provided.
api_base (str, optional) – Base URL for the SiliconFlow API endpoint. Defaults to “https://api.siliconflow.cn/v1” if not provided.
dimensions (int, optional) – The number of dimensions the resulting embeddings should have. See SiliconFlow documentation for available models: https://docs.siliconflow.cn/en/api-reference/embeddings/create-embeddings
**kwargs – Additional arguments to pass to the OpenAI client. See https://github.com/openai/openai-python for more information.
Methods
__init__([model_name, api_key_env, ...])Initialize SiliconflowEmbeddingFunction.
build_from_config(config)Get the configuration dictionary for the OpenAIBaseEmbeddingFunction.
name()support_persistence(embedding_function)Check if the embedding function supports persistence.
Attributes
dimensionGet the dimension of embeddings produced by this function.