@quarry-systems/drift-vector-chroma 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# @quarry-systems/drift-vector-chroma
|
|
2
|
+
|
|
3
|
+
 
|
|
4
|
+
|
|
5
|
+
Chroma vector store adapter for Drift RAG pipelines.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Local-first**: Ideal for development and indie-tier deployments
|
|
10
|
+
- **Semantic search**: Vector similarity with cosine/L2/IP distance metrics
|
|
11
|
+
- **Metadata filtering**: Filter results by document metadata
|
|
12
|
+
- **Provider-agnostic**: Implements `VectorAdapter` contract
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @quarry-systems/drift-vector-chroma
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
Chroma requires a running Chroma server. You can start one with Docker:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
docker run -p 8000:8000 chromadb/chroma
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or install and run Chroma locally:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install chromadb
|
|
32
|
+
chroma run --host localhost --port 8000
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { createChromaVector } from '@quarry-systems/drift-vector-chroma';
|
|
39
|
+
import { getOpenAIEmbeddingAdapter } from '@quarry-systems/drift-openai';
|
|
40
|
+
|
|
41
|
+
// Create vector store
|
|
42
|
+
const vectors = await createChromaVector({
|
|
43
|
+
collection: 'my_docs',
|
|
44
|
+
url: 'http://localhost:8000',
|
|
45
|
+
distanceMetric: 'cosine'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Get embeddings
|
|
49
|
+
const embedder = getOpenAIEmbeddingAdapter();
|
|
50
|
+
const result = await embedder.embed({
|
|
51
|
+
model: 'text-embedding-3-small',
|
|
52
|
+
input: ['Hello world', 'How are you?']
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Index vectors
|
|
56
|
+
await vectors.upsert([
|
|
57
|
+
{
|
|
58
|
+
id: 'doc-1-chunk-0',
|
|
59
|
+
vector: result.embeddings[0],
|
|
60
|
+
metadata: { docId: 'doc-1', sequence: 0 },
|
|
61
|
+
document: 'Hello world'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'doc-1-chunk-1',
|
|
65
|
+
vector: result.embeddings[1],
|
|
66
|
+
metadata: { docId: 'doc-1', sequence: 1 },
|
|
67
|
+
document: 'How are you?'
|
|
68
|
+
}
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
// Query by vector
|
|
72
|
+
const queryResult = await embedder.embed({
|
|
73
|
+
model: 'text-embedding-3-small',
|
|
74
|
+
input: 'greeting'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const matches = await vectors.query({
|
|
78
|
+
vector: queryResult.embeddings[0],
|
|
79
|
+
topK: 5,
|
|
80
|
+
filter: { docId: 'doc-1' }
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log(matches);
|
|
84
|
+
// [
|
|
85
|
+
// {
|
|
86
|
+
// id: 'doc-1-chunk-0',
|
|
87
|
+
// score: 0.95,
|
|
88
|
+
// metadata: { docId: 'doc-1', sequence: 0 },
|
|
89
|
+
// document: 'Hello world'
|
|
90
|
+
// },
|
|
91
|
+
// ...
|
|
92
|
+
// ]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Configuration
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
interface ChromaVectorConfig {
|
|
99
|
+
/** Collection name (default: 'mcg_vectors') */
|
|
100
|
+
collection?: string;
|
|
101
|
+
|
|
102
|
+
/** Chroma server URL (default: 'http://localhost:8000') */
|
|
103
|
+
url?: string;
|
|
104
|
+
|
|
105
|
+
/** Distance metric (default: 'cosine') */
|
|
106
|
+
distanceMetric?: 'cosine' | 'l2' | 'ip';
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Testing
|
|
111
|
+
|
|
112
|
+
Tests require a running Chroma server:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Start Chroma
|
|
116
|
+
docker run -p 8000:8000 chromadb/chroma
|
|
117
|
+
|
|
118
|
+
# Run tests
|
|
119
|
+
export CHROMA_URL=http://localhost:8000
|
|
120
|
+
npm test
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Tests are automatically skipped if `CHROMA_URL` is not set.
|
|
124
|
+
|
|
125
|
+
## API
|
|
126
|
+
|
|
127
|
+
### `createChromaVector(config?)`
|
|
128
|
+
|
|
129
|
+
Creates a Chroma vector adapter.
|
|
130
|
+
|
|
131
|
+
### `VectorAdapter` Methods
|
|
132
|
+
|
|
133
|
+
- `upsert(items: VectorItem[]): Promise<void>` - Insert or update vectors
|
|
134
|
+
- `query(options: VectorQueryOptions): Promise<VectorMatch[]>` - Search by vector
|
|
135
|
+
- `get(id: string): Promise<VectorItem | null>` - Get vector by ID
|
|
136
|
+
- `delete(ids: string[]): Promise<void>` - Delete vectors
|
|
137
|
+
- `count(): Promise<number>` - Count total vectors
|
|
138
|
+
|
|
139
|
+
## Production Deployment
|
|
140
|
+
|
|
141
|
+
For production, consider:
|
|
142
|
+
|
|
143
|
+
1. **Managed Chroma Cloud** - Hosted service with automatic scaling
|
|
144
|
+
2. **Self-hosted Chroma** - Run Chroma server with persistent storage
|
|
145
|
+
3. **Alternative adapters** - Use `drift-vector-pgvector` for Postgres or `drift-vector-pinecone` for managed service
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quarry-systems/drift-vector-chroma",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Chroma vector store adapter for Drift RAG pipelines",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p .",
|
|
9
|
+
"test": "vitest run",
|
|
10
|
+
"test:watch": "vitest"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"drift",
|
|
14
|
+
"vector",
|
|
15
|
+
"chroma",
|
|
16
|
+
"embeddings",
|
|
17
|
+
"rag",
|
|
18
|
+
"similarity-search"
|
|
19
|
+
],
|
|
20
|
+
"author": "Quarry Systems",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"chromadb": "^1.9.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^5.0.0",
|
|
30
|
+
"vitest": "^2.1.0"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE.md",
|
|
36
|
+
"CHANGELOG.md"
|
|
37
|
+
],
|
|
38
|
+
"type": "commonjs"
|
|
39
|
+
}
|