ChatYandexGPT 통합

ChatYandexGPT 통합

LangChain JavaScript로 ChatYandexGPT 채팅 모델과 통합하는 방법을 안내할게요.

출처: 문서

본문

LangChain.js는 YandexGPT 채팅 모델 호출을 지원해요.

설정

먼저 ai.languageModels.user 역할을 가진 서비스 계정을 생성해야 해요.

다음으로 두 가지 인증 옵션이 있어요:

  • IAM 토큰. 생성자 매개변수에서 iam_token으로 토큰을 지정하거나 환경 변수 YC_IAM_TOKEN으로 지정할 수 있어요.
  • API 키 생성자 매개변수에서 api_key로 키를 지정하거나 환경 변수 YC_API_KEY로 지정할 수 있어요.

사용법

See [this section for general instructions on installing LangChain packages](/oss/javascript/langchain/install).
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: {}
}
 */

관련 자료


[Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers. [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/chat/yandex.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).

더 알아보기