Prem AI
PremEmbeddings
类使用 Prem AI API 为给定文本生成嵌入向量。
¥The PremEmbeddings
class uses the Prem AI API to generate embeddings for a given text.
设置
¥Setup
为了使用 Prem API,你需要一个 API 密钥。你可以注册一个 Prem 账户并创建 API 密钥 此处。
¥In order to use the Prem API you'll need an API key. You can sign up for a Prem account and create an API key here.
你首先需要安装 @langchain/community
软件包:
¥You'll first need to install the @langchain/community
package:
tip
- npm
- Yarn
- pnpm
npm install @langchain/community @langchain/core
yarn add @langchain/community @langchain/core
pnpm add @langchain/community @langchain/core
用法
¥Usage
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 Reference:
- PremEmbeddings from
@langchain/community/embeddings/premai
相关
¥Related
嵌入模型 概念指南
¥Embedding model conceptual guide
嵌入模型 操作指南
¥Embedding model how-to guides