Cohere
Cohere provides embedding models for semantic search, clustering, and recommendation. seekdb provides CohereEmbeddingFunction so you can generate Cohere embeddings and use them with seekdb collections.
tip
Using Cohere service requires you to follow Cohere's pricing rules and may incur corresponding fees. Before proceeding, please visit their official website or refer to relevant documentation to confirm and accept their pricing standards. If you do not agree, please do not proceed.
Dependencies and authentication
- Have a Cohere API key with access to the embedding models you plan to use.
- You can pass the key in code or set it in an environment variable (default:
COHERE_API_KEY). UseapiKeyEnvVarif you use a different variable name.
Installation
npm i seekdb @seekdb/cohere
Example: create a Cohere embedding function
import { CohereEmbeddingFunction } from "@seekdb/cohere";
const ef = new CohereEmbeddingFunction({
modelName: "embed-english-v3.0",
inputType: "search_document",
});
Configurations:
- apiKey: Cohere API key (optional; if omitted, read from the environment).
- apiKeyEnvVar: Environment variable name for the API key (default:
"COHERE_API_KEY"). - modelName: Embedding model name (default:
"embed-english-v3.0"). - inputType: Hint for retrieval; one of
"search_document"|"search_query"|"classification"|"clustering"|"image"(default:"search_document"). - truncate: How to truncate long input:
"NONE"|"START"|"END"(optional). - embeddingType: Output vector type:
"float"|"int8"|"uint8"|"binary"|"ubinary"(optional).