Skip to main content

阿里巴巴统一

¥Alibaba Tongyi

AlibabaTongyiEmbeddings 类使用阿里巴巴统一 API 为给定文本生成嵌入向量。

¥The AlibabaTongyiEmbeddings class uses the Alibaba Tongyi API to generate embeddings for a given text.

设置

¥Setup

你需要注册一个阿里巴巴 API 密钥,并将其设置为名为 ALIBABA_API_KEY 的环境变量。

¥You'll need to sign up for an Alibaba API key and set it as an environment variable named ALIBABA_API_KEY.

然后,你需要安装 @langchain/community 包:

¥Then, you'll need to install the @langchain/community package:

npm install @langchain/community @langchain/core

用法

¥Usage

import { AlibabaTongyiEmbeddings } from "@langchain/community/embeddings/alibaba_tongyi";

const model = new AlibabaTongyiEmbeddings({});
const res = await model.embedQuery(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });

API Reference:

¥Related