跳到主要内容
ZhipuAIEmbeddings 类使用智谱AI API 为给定文本生成嵌入。

设置

您需要注册一个智谱AI API 密钥,并将其设置为名为 ZHIPUAI_API_KEY 的环境变量。 https://open.bigmodel.cn 然后,您需要安装 @langchain/community 包:
有关安装 LangChain 软件包的一般说明,请参阅此部分
npm
npm install @langchain/community @langchain/core jsonwebtoken

用法

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 });

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.