@sprucelabs/chroma-data-store 0.2.3 → 0.3.0
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
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Chroma Data Store
|
|
2
|
+
|
|
3
|
+
Give your skill the ability to store and retrieve data from a Chroma database.
|
|
4
|
+
|
|
5
|
+
## Running Chroma
|
|
2
6
|
|
|
3
7
|
1. Clone this rep
|
|
4
8
|
2. Run `yarn start.chroma.docker`
|
|
5
9
|
|
|
10
|
+
## Setting an embedding model
|
|
11
|
+
|
|
12
|
+
By default , the ChromaDabatase class will use llama3.2 hosted through Ollama to generate embeddings
|
|
13
|
+
|
|
14
|
+
### Installing Ollama
|
|
15
|
+
|
|
16
|
+
1. Visit https://ollama.com
|
|
17
|
+
2. Click "Download"
|
|
18
|
+
3. Select your OS
|
|
19
|
+
|
|
20
|
+
### Installing Llama3.2
|
|
21
|
+
|
|
22
|
+
Llama 3.2 is the newest version of Llama (as of this writing) that supports embeddings.
|
|
23
|
+
|
|
24
|
+
1. Inside of terminal, run `ollama run llama3.2`
|
|
25
|
+
2. You should be able to visit http://localhost:11434/api/embeddings and get a 404 response (this is because the route only accepts POST requests)
|
|
26
|
+
|
|
27
|
+
## Improving embeddings with `nomic-embed-text`
|
|
28
|
+
|
|
29
|
+
We have seen significantly better search performance when using `nomic-embed-text` to generate embeddings.
|
|
30
|
+
|
|
6
31
|
|
|
7
|
-
|
|
32
|
+
## Connecting to Chroma
|
|
8
33
|
|
|
9
|
-
Use the connection string: `chromadb://localhost:8000`
|
|
34
|
+
Use the connection string: `chromadb://localhost:8000` is your skill.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CreateOptions, Database, DatabaseInternalOptions, Index, IndexWithFilter, QueryOptions } from '@sprucelabs/data-stores';
|
|
2
|
+
import { OllamaEmbeddingFunction } from 'chromadb';
|
|
2
3
|
export default class ChromaDatabase implements Database {
|
|
3
4
|
static Class?: new (connectionString: string) => Database;
|
|
5
|
+
static EmbeddingFunction: typeof OllamaEmbeddingFunction;
|
|
4
6
|
private static embeddingFields?;
|
|
5
7
|
private connectionString;
|
|
6
8
|
private client;
|
package/build/ChromaDatabase.js
CHANGED
|
@@ -13,8 +13,8 @@ class ChromaDatabase {
|
|
|
13
13
|
this._isConnected = false;
|
|
14
14
|
this.collections = {};
|
|
15
15
|
(0, schema_1.assertOptions)({ connectionString }, ['connectionString']);
|
|
16
|
-
this.embeddings = new
|
|
17
|
-
model: 'llama3.2',
|
|
16
|
+
this.embeddings = new ChromaDatabase.EmbeddingFunction({
|
|
17
|
+
model: process.env.CHROMA_EMBEDDING_MODEL ?? 'llama3.2',
|
|
18
18
|
url: 'http://localhost:11434/api/embeddings',
|
|
19
19
|
});
|
|
20
20
|
if (!connectionString.startsWith('chroma://')) {
|
|
@@ -394,4 +394,5 @@ class ChromaDatabase {
|
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
+
ChromaDatabase.EmbeddingFunction = chromadb_1.OllamaEmbeddingFunction;
|
|
397
398
|
exports.default = ChromaDatabase;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CreateOptions, Database, DatabaseInternalOptions, Index, IndexWithFilter, QueryOptions } from '@sprucelabs/data-stores';
|
|
2
|
+
import { OllamaEmbeddingFunction } from 'chromadb';
|
|
2
3
|
export default class ChromaDatabase implements Database {
|
|
3
4
|
static Class?: new (connectionString: string) => Database;
|
|
5
|
+
static EmbeddingFunction: typeof OllamaEmbeddingFunction;
|
|
4
6
|
private static embeddingFields?;
|
|
5
7
|
private connectionString;
|
|
6
8
|
private client;
|
|
@@ -23,13 +23,14 @@ import { assertOptions, flattenValues, expandValues } from '@sprucelabs/schema';
|
|
|
23
23
|
import { NULL_PLACEHOLDER } from '@sprucelabs/test-utils';
|
|
24
24
|
import { ChromaClient, OllamaEmbeddingFunction, } from 'chromadb';
|
|
25
25
|
import SpruceError from './errors/SpruceError.js';
|
|
26
|
-
|
|
26
|
+
class ChromaDatabase {
|
|
27
27
|
constructor(connectionString) {
|
|
28
|
+
var _a;
|
|
28
29
|
this._isConnected = false;
|
|
29
30
|
this.collections = {};
|
|
30
31
|
assertOptions({ connectionString }, ['connectionString']);
|
|
31
|
-
this.embeddings = new
|
|
32
|
-
model: 'llama3.2',
|
|
32
|
+
this.embeddings = new ChromaDatabase.EmbeddingFunction({
|
|
33
|
+
model: (_a = process.env.CHROMA_EMBEDDING_MODEL) !== null && _a !== void 0 ? _a : 'llama3.2',
|
|
33
34
|
url: 'http://localhost:11434/api/embeddings',
|
|
34
35
|
});
|
|
35
36
|
if (!connectionString.startsWith('chroma://')) {
|
|
@@ -456,3 +457,5 @@ export default class ChromaDatabase {
|
|
|
456
457
|
});
|
|
457
458
|
}
|
|
458
459
|
}
|
|
460
|
+
ChromaDatabase.EmbeddingFunction = OllamaEmbeddingFunction;
|
|
461
|
+
export default ChromaDatabase;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"sprucebot",
|
|
14
14
|
"sprucelabs"
|
|
15
15
|
],
|
|
16
|
-
"version": "0.
|
|
16
|
+
"version": "0.3.0",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build.ci": "yarn run build.tsc && yarn run build.resolve-paths && yarn run lint",
|
|
19
19
|
"build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
|