ZhipuAI
ZhipuAIEmbeddings
类使用 ZhipuAI API 为给定文本生成嵌入向量。
¥The ZhipuAIEmbeddings
class uses the ZhipuAI API to generate embeddings for a given text.
设置
¥Setup
你需要注册一个智普 AI API 密钥,并将其设置为名为 ZHIPUAI_API_KEY
的环境变量。
¥You'll need to sign up for an ZhipuAI API key and set it as an environment variable named ZHIPUAI_API_KEY
.
然后,你需要安装 @langchain/community
包:
¥Then, you'll need to install the @langchain/community
package:
tip
- npm
- Yarn
- pnpm
npm install @langchain/community @langchain/core jsonwebtoken
yarn add @langchain/community @langchain/core jsonwebtoken
pnpm add @langchain/community @langchain/core jsonwebtoken
用法
¥Usage
import { ZhipuAIEmbeddings } from "@langchain/community/embeddings/zhipuai";
const model = new ZhipuAIEmbeddings({});
const res = await model.embedQuery(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });
API Reference:
- ZhipuAIEmbeddings from
@langchain/community/embeddings/zhipuai
相关
¥Related
嵌入模型 概念指南
¥Embedding model conceptual guide
嵌入模型 操作指南
¥Embedding model how-to guides