ChatYandexGPT
This notebook goes over how to use Langchain with YandexGPT chat model.
To use, you should have the yandexcloud
python package installed.
%pip install yandexcloud
First, you should create service
account with
the ai.languageModels.user
role.
Next, you have two authentication options: - IAM
token.
You can specify the token in a constructor parameter iam_token
or in
an environment variable YC_IAM_TOKEN
.
- API
key
You can specify the key in a constructor parameter
api_key
or in an environment variableYC_API_KEY
.
In the model_uri
parameter, specify the model used, see the
documentation
for more details.
To specify the model you can use model_uri
parameter, see the
documentation
for more details.
By default, the latest version of yandexgpt-lite
is used from the
folder specified in the parameter folder_id
or YC_FOLDER_ID
environment variable.
from langchain.chat_models import ChatYandexGPT
from langchain.schema import HumanMessage, SystemMessage
chat_model = ChatYandexGPT()
answer = chat_model(
[
SystemMessage(
content="You are a helpful assistant that translates English to French."
),
HumanMessage(content="I love programming."),
]
)
answer
AIMessage(content='Je adore le programmement.')