clients/new-js/packages/ai-embeddings/jina/README.md
This package provides a Jina AI embedding provider for Chroma.
npm install @chroma-core/jina
import { ChromaClient } from 'chromadb';
import { JinaEmbeddingFunction } from '@chroma-core/jina';
// Initialize the embedder
const embedder = new JinaEmbeddingFunction({
apiKey: 'your-api-key', // Or set JINA_API_KEY env var
modelName: 'jina-embeddings-v2-base-en',
// Optional configuration
task: 'retrieval.passage',
dimensions: 768,
lateChunking: false,
truncate: true,
normalized: true,
embeddingType: 'float'
});
// 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 Jina API key as an environment variable:
export JINA_API_KEY=your-api-key
Get your API key from Jina AI.
JINA_API_KEY)retrieval.passage, retrieval.query)float, base64, binary)jina-embeddings-v2-base-enjina-embeddings-v2-small-enjina-clip-v1Check the Jina AI documentation for the complete list of available models and their capabilities.