clients/new-js/packages/ai-embeddings/perplexity/README.md
This package provides a Perplexity AI embedding provider for Chroma.
npm install @chroma-core/perplexity
import { ChromaClient } from 'chromadb';
import { PerplexityEmbeddingFunction } from '@chroma-core/perplexity';
// Initialize the embedder
const embedder = new PerplexityEmbeddingFunction({
apiKey: 'your-api-key', // Or set PERPLEXITY_API_KEY env var
modelName: 'pplx-embed-v1-4b',
});
// 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,
});
Set your Perplexity API key as an environment variable:
export PERPLEXITY_API_KEY=your-api-key
Get your API key from Perplexity AI.
PERPLEXITY_API_KEY)pplx-embed-v1-0.6b)Perplexity offers high-quality embedding models:
pplx-embed-v1-0.6b - Lightweight model (default)pplx-embed-v1-4b - Larger model for maximum performanceCheck the Perplexity documentation for the complete list of available models.