YandexGPTEmbeddings#
- class langchain_community.embeddings.yandex.YandexGPTEmbeddings[source]#
Bases:
BaseModel
,Embeddings
YandexGPT Embeddings models.
To use, you should have the
yandexcloud
python package installed.There are two authentication options for the service account with the
ai.languageModels.user
role:You can specify the token in a constructor parameter iam_token
or in an environment variable YC_IAM_TOKEN. - You can specify the key in a constructor parameter api_key or in an environment variable YC_API_KEY.
To use the default model specify the folder ID in a parameter folder_id or in an environment variable YC_FOLDER_ID.
Example
from langchain_community.embeddings.yandex import YandexGPTEmbeddings embeddings = YandexGPTEmbeddings(iam_token="t1.9eu...", folder_id=<folder-id>)
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param api_key: SecretStr = ''#
Yandex Cloud Api Key for service account with the ai.languageModels.user role
- param disable_request_logging: bool = False#
YandexGPT API logs all request data by default. If you provide personal data, confidential information, disable logging.
- param doc_model_name: str = 'text-search-doc'#
Doc model name to use.
- param doc_model_uri: str = ''#
Doc model uri to use.
- param folder_id: str = ''#
Yandex Cloud folder ID
- param grpc_metadata: Sequence [Required]#
- param iam_token: SecretStr = ''#
Yandex Cloud IAM token for service account with the ai.languageModels.user role
- param max_retries: int = 6#
Maximum number of retries to make when generating.
- param model_name: str = 'text-search-query' (alias 'query_model_name')#
Query model name to use.
- param model_uri: str = '' (alias 'query_model_uri')#
Query model uri to use.
- param model_version: str = 'latest'#
Model version to use.
- param sleep_interval: float = 0.0#
Delay between API requests
- param url: str = 'llm.api.cloud.yandex.net:443'#
The url of the API.
- async aembed_documents(texts: list[str]) list[list[float]] #
Asynchronous Embed search docs.
- Parameters:
texts (list[str]) – List of text to embed.
- Returns:
List of embeddings.
- Return type:
list[list[float]]
- async aembed_query(text: str) list[float] #
Asynchronous Embed query text.
- Parameters:
text (str) – Text to embed.
- Returns:
Embedding.
- Return type:
list[float]
- embed_documents(texts: List[str]) List[List[float]] [source]#
Embed documents using a YandexGPT embeddings models.
- Parameters:
texts (List[str]) – The list of texts to embed.
- Returns:
List of embeddings, one for each text.
- Return type:
List[List[float]]
Examples using YandexGPTEmbeddings