Skip to main content

GigaChat

This notebook shows how to use LangChain with GigaChat. To use you need to install gigachat python package.

%pip install --upgrade --quiet  gigachat

To get GigaChat credentials you need to create account and get access to API

Exampleโ€‹

import os
from getpass import getpass

if "GIGACHAT_CREDENTIALS" not in os.environ:
os.environ["GIGACHAT_CREDENTIALS"] = getpass()
from langchain_community.chat_models import GigaChat

chat = GigaChat(verify_ssl_certs=False, scope="GIGACHAT_API_PERS")
API Reference:GigaChat
from langchain_core.messages import HumanMessage, SystemMessage

messages = [
SystemMessage(
content="You are a helpful AI that shares everything you know. Talk in English."
),
HumanMessage(content="What is capital of Russia?"),
]

print(chat.invoke(messages).content)
API Reference:HumanMessage | SystemMessage
The capital of Russia is Moscow.

Was this page helpful?


You can also leave detailed feedback on GitHub.