pyseekdb.utils.embedding_functions.LiteLLMBaseEmbeddingFunction
- class pyseekdb.utils.embedding_functions.LiteLLMBaseEmbeddingFunction(model_name: str, api_key_env: str | None = None, **kwargs: Any)[source]
Bases:
EmbeddingFunction[str|list[str]]A custom embedding function using LiteLLM to access various embedding models.
LiteLLM provides a unified interface to access embedding models from multiple providers including OpenAI, Hugging Face, Cohere, and many others.
You can extend this class to create your own embedding function by overriding the __call__ method. See https://docs.litellm.ai/docs/embedding/supported_embedding for more information.
Example
pip install pyseekdb litellm
- __init__(model_name: str, api_key_env: str | None = None, **kwargs: Any)[source]
Initialize.
- Parameters:
model_name (str) – Identifier of the embedding model. See https://docs.litellm.ai/docs/embedding/supported_embedding for full list.
api_key_env (str, optional) – Name of the environment variable containing the API key. If not provided, LiteLLM will try to use default environment variables based on the provider. For example, “OPENAI_API_KEY” for OpenAI, “HUGGINGFACE_API_KEY” for Hugging Face. See https://docs.litellm.ai/docs/set_keys for a complete list of default environment variable names.
**kwargs – Additional arguments to pass to the LiteLLM embedding function. See https://docs.litellm.ai/docs/embedding/supported_embedding for more information.
Methods
__init__(model_name[, api_key_env])Initialize.
get_config()Get the configuration dictionary for the embedding function.
support_persistence(embedding_function)Check if the embedding function supports persistence.