跳至主要内容

GigaChat

此笔记本展示了如何将 LangChain 与GigaChat一起使用。要使用它,您需要安装 gigachat python 包。

%pip install --upgrade --quiet  gigachat

要获取 GigaChat 凭据,您需要创建帐户访问 API

示例

import os
from getpass import getpass

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

chat = GigaChat(verify_ssl_certs=False, scope="GIGACHAT_API_PERS")
API 参考: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)
The capital of Russia is Moscow.

此页面是否有帮助?


您还可以留下详细的反馈 在 GitHub 上.