@sprucelabs/chroma-data-store 0.1.24 → 0.2.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 ADDED
@@ -0,0 +1,9 @@
1
+ # Running Chroma
2
+
3
+ 1. Clone this rep
4
+ 2. Run `yarn start.chroma.docker`
5
+
6
+
7
+ # Connecting to Chroma
8
+
9
+ Use the connection string: `chromadb://localhost:8000`
@@ -189,13 +189,16 @@ class ChromaDatabase {
189
189
  async find(collection, query, options, _dbOptions) {
190
190
  let { ids, where, skipIds } = this.buildQuery(query);
191
191
  let matches;
192
- const { limit, includeFields } = options ?? {};
192
+ let { limit, includeFields } = options ?? {};
193
193
  const col = await this.getCollection(collection);
194
+ if (!limit && where?.$prompt) {
195
+ limit = 10;
196
+ }
194
197
  if (where?.$prompt) {
195
198
  const { $prompt, ...rest } = where;
196
199
  const queryResults = await col.query({
197
200
  queryTexts: [$prompt],
198
- nResults: 1,
201
+ nResults: limit,
199
202
  where: Object.keys(rest).length > 0 ? rest : undefined,
200
203
  });
201
204
  matches = {
@@ -3,4 +3,6 @@ export default class MockChromaDatabase extends NeDbDatabase {
3
3
  private connectionString;
4
4
  constructor(connectionString: string);
5
5
  assertConnectionStringEquals(connectionString: string): void;
6
+ connect(): Promise<void>;
7
+ assertIsConnected(): void;
6
8
  }
@@ -10,5 +10,11 @@ class MockChromaDatabase extends data_stores_1.NeDbDatabase {
10
10
  assertConnectionStringEquals(connectionString) {
11
11
  test_utils_1.assert.isEqual(this.connectionString, connectionString, 'The connection string you passed to your ChromaDb does not equal what I expected!');
12
12
  }
13
+ async connect() {
14
+ await super.connect();
15
+ }
16
+ assertIsConnected() {
17
+ test_utils_1.assert.isTrue(this.isConnected(), 'Database is not connected! Try calling db.connect()');
18
+ }
13
19
  }
14
20
  exports.default = MockChromaDatabase;
@@ -234,13 +234,16 @@ export default class ChromaDatabase {
234
234
  return __awaiter(this, void 0, void 0, function* () {
235
235
  let { ids, where, skipIds } = this.buildQuery(query);
236
236
  let matches;
237
- const { limit, includeFields } = options !== null && options !== void 0 ? options : {};
237
+ let { limit, includeFields } = options !== null && options !== void 0 ? options : {};
238
238
  const col = yield this.getCollection(collection);
239
+ if (!limit && (where === null || where === void 0 ? void 0 : where.$prompt)) {
240
+ limit = 10;
241
+ }
239
242
  if (where === null || where === void 0 ? void 0 : where.$prompt) {
240
243
  const { $prompt } = where, rest = __rest(where, ["$prompt"]);
241
244
  const queryResults = yield col.query({
242
245
  queryTexts: [$prompt],
243
- nResults: 1,
246
+ nResults: limit,
244
247
  where: Object.keys(rest).length > 0 ? rest : undefined,
245
248
  });
246
249
  matches = {
@@ -3,4 +3,6 @@ export default class MockChromaDatabase extends NeDbDatabase {
3
3
  private connectionString;
4
4
  constructor(connectionString: string);
5
5
  assertConnectionStringEquals(connectionString: string): void;
6
+ connect(): Promise<void>;
7
+ assertIsConnected(): void;
6
8
  }
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { NeDbDatabase } from '@sprucelabs/data-stores';
2
11
  import { assert } from '@sprucelabs/test-utils';
3
12
  export default class MockChromaDatabase extends NeDbDatabase {
@@ -8,4 +17,15 @@ export default class MockChromaDatabase extends NeDbDatabase {
8
17
  assertConnectionStringEquals(connectionString) {
9
18
  assert.isEqual(this.connectionString, connectionString, 'The connection string you passed to your ChromaDb does not equal what I expected!');
10
19
  }
20
+ connect() {
21
+ const _super = Object.create(null, {
22
+ connect: { get: () => super.connect }
23
+ });
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ yield _super.connect.call(this);
26
+ });
27
+ }
28
+ assertIsConnected() {
29
+ assert.isTrue(this.isConnected(), 'Database is not connected! Try calling db.connect()');
30
+ }
11
31
  }
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "sprucebot",
14
14
  "sprucelabs"
15
15
  ],
16
- "version": "0.1.24",
16
+ "version": "0.2.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/",