Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.langchain.com/llms.txt

Use this file to discover all available pages before exploring further.

This notebook goes over how to use LangChain with YandexGPT. To use, you should have the yandexcloud python package installed.
pip install -qU  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 variable YC_API_KEY.
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_classic.chains import LLMChain
from langchain_community.llms import YandexGPT
from langchain_core.prompts import PromptTemplate
template = "What is the capital of {country}?"
prompt = PromptTemplate.from_template(template)
llm = YandexGPT()
llm_chain = LLMChain(prompt=prompt, llm=llm)
country = "Russia"

llm_chain.invoke(country)
'The capital of Russia is Moscow.'