0.1.7 • Published 5 months ago
@chroma-core/voyageai v0.1.7
Voyage AI Embedding Function for Chroma
This package provides a Voyage AI embedding provider for Chroma.
Installation
npm install @chroma-core/voyageaiUsage
import { ChromaClient } from 'chromadb';
import { VoyageAIEmbeddingFunction } from '@chroma-core/voyageai';
// Initialize the embedder
const embedder = new VoyageAIEmbeddingFunction({
apiKey: 'your-api-key', // Or set VOYAGE_API_KEY env var
modelName: 'voyage-2',
});
// Create a new ChromaClient
const client = new ChromaClient({
path: 'http://localhost:8000',
});
// Create a collection with the embedder
const collection = await client.createCollection({
name: 'my-collection',
embeddingFunction: embedder,
});
// Add documents
await collection.add({
ids: ["1", "2", "3"],
documents: ["Document 1", "Document 2", "Document 3"],
});
// Query documents
const results = await collection.query({
queryTexts: ["Sample query"],
nResults: 2,
});Configuration
Set your Voyage AI API key as an environment variable:
export VOYAGE_API_KEY=your-api-keyGet your API key from Voyage AI.
Configuration Options
- apiKey: Your Voyage AI API key (or set via environment variable)
- apiKeyEnvVar: Environment variable name for API key (default:
VOYAGE_API_KEY) - modelName: Model to use for embeddings (required)
Supported Models
Voyage AI offers high-quality embedding models:
voyage-2- Latest and most capable modelvoyage-large-2- Larger model for maximum performancevoyage-code-2- Optimized for code and technical contentvoyage-lite-02-instruct- Lightweight instruction-following model
Check the Voyage AI documentation for the complete list of available models and their specifications.
Features
- State-of-the-Art Quality: High-performance embedding models optimized for retrieval
- Domain-Specific Models: Specialized models for code, legal, and other domains
- Efficient: Competitive pricing and fast inference times