Skip to main content

YandexGPT

LangChain.js 支持调用 YandexGPT LLM。

¥LangChain.js supports calling YandexGPT LLMs.

设置

¥Setup

首先,你需要使用 ai.languageModels.user 角色登录 创建服务账户

¥First, you should create service account with the ai.languageModels.user role.

接下来,你有两个身份验证选项:

¥Next, you have two authentication options:

  • IAM 令牌。你可以在构造函数参数中将令牌指定为 iam_token,也可以在环境变量 YC_IAM_TOKEN 中指定令牌。

    ¥IAM token. You can specify the token in a constructor parameter iam_token or in an environment variable YC_IAM_TOKEN.

  • API 密钥 你可以在构造函数参数 api_key 或环境变量 YC_API_KEY 中指定键。

    ¥API key You can specify the key in a constructor parameter api_key or in an environment variable YC_API_KEY.

用法

¥Usage

npm install @langchain/yandex @langchain/core
import { YandexGPT } from "@langchain/yandex/llms";

const model = new YandexGPT();
const res = await model.invoke(['Translate "I love programming" into French.']);
console.log({ res });

API Reference:

¥Related