Cohere
The CohereEmbeddings
class uses the Cohere API to generate embeddings for a given text.
Usage
- npm
- Yarn
- pnpm
npm install cohere-ai @langchain/cohere
yarn add cohere-ai @langchain/cohere
pnpm add cohere-ai @langchain/cohere
import { CohereEmbeddings } from "@langchain/cohere";
/* Embed queries */
const embeddings = new CohereEmbeddings({
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.COHERE_API_KEY
batchSize: 48, // Default value if omitted is 48. Max value is 96
model: "embed-english-v3.0",
});
const res = await embeddings.embedQuery("Hello world");
console.log(res);
/* Embed documents */
const documentRes = await embeddings.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });
API Reference:
- CohereEmbeddings from
@langchain/cohere