ChatYandexGPT 통합
ChatYandexGPT 통합
LangChain JavaScript로 ChatYandexGPT 채팅 모델과 통합하는 방법을 안내할게요.
출처: 문서
본문
LangChain.js는 YandexGPT 채팅 모델 호출을 지원해요.
설정
먼저 ai.languageModels.user 역할을 가진 서비스 계정을 생성해야 해요.
다음으로 두 가지 인증 옵션이 있어요:
- IAM 토큰.
생성자 매개변수에서
iam_token으로 토큰을 지정하거나 환경 변수YC_IAM_TOKEN으로 지정할 수 있어요. - API 키
생성자 매개변수에서
api_key로 키를 지정하거나 환경 변수YC_API_KEY로 지정할 수 있어요.
사용법
npm install @langchain/yandex @langchain/core
import { ChatYandexGPT } from "@langchain/yandex/chat_models";
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
const chat = new ChatYandexGPT();
const res = await chat.invoke([
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage("I love programming."),
]);
console.log(res);
/*
AIMessage {
lc_serializable: true,
lc_kwargs: { content: "Je t'aime programmer.", additional_kwargs: {} },
lc_namespace: [ 'langchain', 'schema' ],
content: "Je t'aime programmer.",
name: undefined,
additional_kwargs: {}
}
*/
관련 자료
- 채팅 모델 개념 가이드
- 채팅 모델 how-to 가이드
더 알아보기
- 이 문서를 MCP로 연결하면 Claude, VSCode 등에서 실시간 답변을 받을 수 있어요.
- GitHub에서 이 페이지 편집하기 또는 이슈 제출하기.