YandexGPTConfigManagerBase#

class yandex_gpt.YandexGPTConfigManagerBase(model_type: str | None = None, catalog_id: str | None = None, iam_token: str | None = None, api_key: str | None = None)#

Bases: object

Base class for YaGPT configuration management. It handles configurations related to model type, catalog ID, IAM token, and API key for authorization when making requests to the completion endpoint.

Attributes#

model_typeOptional[str]

The model type to use. Supported values include ‘yandexgpt’, ‘yandexgpt-lite’, ‘summarization’.

catalog_idOptional[str]

The Catalog ID on YandexCloud to be used.

iam_tokenOptional[str]

The IAM token for authorization. Either iam_token or api_key is used for authorization. If both are provided, iam_token will be preferred. More details on getting an IAM token can be found here: https://yandex.cloud/ru/docs/iam/operations/iam-token/create-for-sa

api_keyOptional[str]

The API key for authorization. More details on getting an API key can be found here: https://yandex.cloud/ru/docs/iam/operations/api-key/create

property completion_request_authorization_field: str#

Returns the authorization field for the completion request header based on the IAM token or API key.

Raises#

ValueError

If neither IAM token nor API key is set.

Returns#

str

The authorization field for the completion request header in the form of “Bearer {iam_token}” or “Api-Key {api_key}”.

property completion_request_catalog_id_field: str#

Returns the catalog ID field for the completion request header.

Raises#

ValueError

If catalog_id is not set.

Returns#

str

The catalog ID field for the completion request header.

property completion_request_model_type_uri_field: str#

Returns the model type URI field for the completion request payload.

Raises#

ValueError

If model_type or catalog_id is not set or if model_type is not in the available models.

Returns#

str

The model type URI field for the completion request header in the URI format.