@sprucelabs/chroma-data-store 0.2.3 → 0.3.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 CHANGED
@@ -1,9 +1,34 @@
1
- # Running Chroma
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
- # Connecting to Chroma
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;
@@ -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 chromadb_1.OllamaEmbeddingFunction({
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
- export default class ChromaDatabase {
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 OllamaEmbeddingFunction({
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.2.3",
16
+ "version": "0.3.1",
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/",
@@ -43,15 +43,15 @@
43
43
  "generate.embeddings": "./support/generate_embeddings.sh"
44
44
  },
45
45
  "devDependencies": {
46
- "@sprucelabs/esm-postbuild": "^6.0.540",
47
- "@sprucelabs/jest-json-reporter": "^8.0.567",
48
- "@sprucelabs/resolve-path-aliases": "^2.0.527",
46
+ "@sprucelabs/esm-postbuild": "^6.0.541",
47
+ "@sprucelabs/jest-json-reporter": "^8.0.568",
48
+ "@sprucelabs/resolve-path-aliases": "^2.0.528",
49
49
  "@sprucelabs/semantic-release": "^5.0.2",
50
- "@sprucelabs/test": "^9.0.67",
51
- "@sprucelabs/test-utils": "^5.1.546",
52
- "@types/node": "^22.10.7",
50
+ "@sprucelabs/test": "^9.0.68",
51
+ "@sprucelabs/test-utils": "^5.1.547",
52
+ "@types/node": "^22.12.0",
53
53
  "chokidar-cli": "^3.0.0",
54
- "eslint": "^9.18.0",
54
+ "eslint": "^9.19.0",
55
55
  "eslint-config-spruce": "^11.2.26",
56
56
  "jest": "^29.7.0",
57
57
  "jest-circus": "^29.7.0",
@@ -83,12 +83,12 @@
83
83
  }
84
84
  },
85
85
  "dependencies": {
86
- "@sprucelabs/data-stores": "^28.5.25",
87
- "@sprucelabs/error": "^6.0.566",
86
+ "@sprucelabs/data-stores": "^28.5.28",
87
+ "@sprucelabs/error": "^6.0.567",
88
88
  "@sprucelabs/schema": "^31.0.19",
89
- "@sprucelabs/spruce-core-schemas": "^40.1.605",
90
- "@sprucelabs/spruce-skill-utils": "^31.2.18",
91
- "chromadb": "^1.10.3",
89
+ "@sprucelabs/spruce-core-schemas": "^40.1.606",
90
+ "@sprucelabs/spruce-skill-utils": "^31.2.20",
91
+ "chromadb": "^1.10.4",
92
92
  "chromadb-default-embed": "^2.13.2"
93
93
  }
94
94
  }