Prem AI
PremEmbeddings
类使用 Prem AI API 为给定的文本生成嵌入。
设置
为了使用 Prem API,您需要一个 API 密钥。您可以注册 Prem 帐户并创建 API 密钥此处。
首先,您需要安装@langchain/community
包
提示
- npm
- Yarn
- pnpm
npm install @langchain/community
yarn add @langchain/community
pnpm add @langchain/community
用法
import { PremEmbeddings } from "@langchain/community/embeddings/premai";
const embeddings = new PremEmbeddings({
// In Node.js defaults to process.env.PREM_API_KEY
apiKey: "YOUR-API-KEY",
// In Node.js defaults to process.env.PREM_PROJECT_ID
project_id: "YOUR-PROJECT_ID",
model: "@cf/baai/bge-small-en-v1.5", // The model to generate the embeddings
});
const res = await embeddings.embedQuery(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });
API 参考
- PremEmbeddings 来自
@langchain/community/embeddings/premai