@soulcraft/brainy 0.11.0 → 0.13.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.
Files changed (38) hide show
  1. package/README.demo.md +1 -1
  2. package/README.md +8 -64
  3. package/dist/brainyData.d.ts +41 -0
  4. package/dist/patched-platform-node.d.ts +17 -0
  5. package/dist/setup.d.ts +16 -0
  6. package/dist/storage/fileSystemStorage.d.ts.map +1 -1
  7. package/dist/unified.d.ts +5 -3
  8. package/dist/unified.js +902 -294
  9. package/dist/unified.min.js +765 -749
  10. package/dist/utils/distance.d.ts.map +1 -1
  11. package/dist/utils/embedding.d.ts +68 -5
  12. package/dist/utils/embedding.d.ts.map +1 -1
  13. package/dist/utils/environment.d.ts.map +1 -1
  14. package/dist/utils/textEncoding.d.ts +13 -20
  15. package/dist/utils/textEncoding.d.ts.map +1 -1
  16. package/dist/utils/version.d.ts +1 -1
  17. package/package.json +32 -13
  18. package/dist/augmentations/huggingfaceActivation.d.ts +0 -57
  19. package/dist/augmentations/huggingfaceActivation.d.ts.map +0 -1
  20. package/dist/augmentations/huggingfaceActivationRegistration.d.ts +0 -6
  21. package/dist/augmentations/huggingfaceActivationRegistration.d.ts.map +0 -1
  22. package/dist/brainy.js +0 -87290
  23. package/dist/brainy.min.js +0 -12495
  24. package/dist/cli.d.ts +0 -7
  25. package/dist/utils/distance-js.d.ts +0 -38
  26. package/dist/utils/distance-js.d.ts.map +0 -1
  27. package/dist/utils/distance-wasm.d.ts +0 -36
  28. package/dist/utils/distance-wasm.d.ts.map +0 -1
  29. package/dist/utils/huggingfaceEmbedding.d.ts +0 -53
  30. package/dist/utils/huggingfaceEmbedding.d.ts.map +0 -1
  31. package/dist/utils/tensorflowBridge.d.ts +0 -14
  32. package/dist/utils/tensorflowBridge.d.ts.map +0 -1
  33. package/dist/utils/textEncoderPolyfill.d.ts +0 -6
  34. package/dist/utils/textEncoderPolyfill.d.ts.map +0 -1
  35. package/dist/utils/universalDebug.d.ts +0 -21
  36. package/dist/utils/universalDebug.d.ts.map +0 -1
  37. package/dist/utils/universalUuid.d.ts +0 -26
  38. package/dist/utils/universalUuid.d.ts.map +0 -1
package/dist/cli.d.ts DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Brainy CLI
4
- * A command-line interface for interacting with the Brainy vector database
5
- */
6
- export {};
7
- //# sourceMappingURL=cli.d.ts.map
@@ -1,38 +0,0 @@
1
- /**
2
- * JavaScript implementations of distance functions for vector similarity calculations
3
- * Used as fallbacks when WebAssembly is not available
4
- */
5
- import { DistanceFunction, Vector } from '../coreTypes.js';
6
- /**
7
- * Calculates the Euclidean distance between two vectors
8
- * Lower values indicate higher similarity
9
- */
10
- export declare const euclideanDistance: DistanceFunction;
11
- /**
12
- * Calculates the cosine distance between two vectors
13
- * Lower values indicate higher similarity
14
- * Range: 0 (identical) to 2 (opposite)
15
- */
16
- export declare const cosineDistance: DistanceFunction;
17
- /**
18
- * Calculates the Manhattan (L1) distance between two vectors
19
- * Lower values indicate higher similarity
20
- */
21
- export declare const manhattanDistance: DistanceFunction;
22
- /**
23
- * Calculates the dot product similarity between two vectors
24
- * Higher values indicate higher similarity
25
- * Converted to a distance metric (lower is better)
26
- */
27
- export declare const dotProductDistance: DistanceFunction;
28
- /**
29
- * Batch distance calculation
30
- * Calculates distances between a query vector and multiple vectors
31
- *
32
- * @param queryVector The query vector to compare against all vectors
33
- * @param vectors Array of vectors to compare against
34
- * @param distanceFunction The distance function to use
35
- * @returns Promise resolving to array of distances
36
- */
37
- export declare function calculateDistancesBatch(queryVector: Vector, vectors: Vector[], distanceFunction?: DistanceFunction): Promise<number[]>;
38
- //# sourceMappingURL=distance-js.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"distance-js.d.ts","sourceRoot":"","sources":["../../src/utils/distance-js.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAc/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,gBA4B5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAa/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAgBhC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,GAAE,gBAAoC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB"}
@@ -1,36 +0,0 @@
1
- /**
2
- * WebAssembly implementation of distance functions for vector similarity calculations
3
- * High-performance implementation with GPU acceleration when available
4
- */
5
- import { DistanceFunction, Vector } from '../coreTypes.js';
6
- /**
7
- * Load the WebAssembly module
8
- * @returns Promise that resolves when the module is loaded
9
- */
10
- export declare function loadWasmModule(): Promise<void>;
11
- /**
12
- * Calculates the Euclidean distance between two vectors
13
- * Uses WebAssembly implementation when available, falls back to JavaScript
14
- */
15
- export declare const euclideanDistance: DistanceFunction;
16
- /**
17
- * Calculates the cosine distance between two vectors
18
- * Uses WebAssembly implementation when available, falls back to JavaScript
19
- */
20
- export declare const cosineDistance: DistanceFunction;
21
- /**
22
- * Calculates the Manhattan distance between two vectors
23
- * Uses WebAssembly implementation when available, falls back to JavaScript
24
- */
25
- export declare const manhattanDistance: DistanceFunction;
26
- /**
27
- * Calculates the dot product distance between two vectors
28
- * Uses WebAssembly implementation when available, falls back to JavaScript
29
- */
30
- export declare const dotProductDistance: DistanceFunction;
31
- /**
32
- * Batch distance calculation
33
- * Uses WebAssembly implementation when available, falls back to JavaScript
34
- */
35
- export declare function calculateDistancesBatch(queryVector: Vector, vectors: Vector[], distanceFunction?: DistanceFunction): Promise<number[]>;
36
- //# sourceMappingURL=distance-wasm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"distance-wasm.d.ts","sourceRoot":"","sources":["../../src/utils/distance-wasm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAwC1D;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAiIpD;AAWD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAqB/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAqB5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAqB/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAqBhC,CAAA;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,GAAE,gBAAoC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CAiDnB"}
@@ -1,53 +0,0 @@
1
- /**
2
- * Embedding functions for converting data to vectors using Huggingface transformers
3
- */
4
- import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.js';
5
- /**
6
- * Huggingface Sentence Transformer embedding model
7
- * This model provides high-quality text embeddings using the all-MiniLM-L6-v2 model
8
- *
9
- * This implementation uses the @huggingface/inference library to generate embeddings.
10
- */
11
- export declare class HuggingfaceSentenceTransformer implements EmbeddingModel {
12
- private hfInference;
13
- private initialized;
14
- private modelName;
15
- /**
16
- * Initialize the embedding model
17
- */
18
- init(): Promise<void>;
19
- /**
20
- * Embed text into a vector using Huggingface Inference API
21
- * @param data Text to embed
22
- */
23
- embed(data: string | string[]): Promise<Vector>;
24
- /**
25
- * Embed multiple texts into vectors using Huggingface Inference API
26
- * This is more efficient than calling embed() multiple times
27
- * @param dataArray Array of texts to embed
28
- * @returns Array of embedding vectors
29
- */
30
- embedBatch(dataArray: string[]): Promise<Vector[]>;
31
- /**
32
- * Dispose of the model resources
33
- */
34
- dispose(): Promise<void>;
35
- }
36
- /**
37
- * Create an embedding function from an embedding model
38
- * @param model Embedding model to use
39
- */
40
- export declare function createEmbeddingFunction(model: EmbeddingModel): EmbeddingFunction;
41
- export declare function createHuggingfaceEmbeddingFunction(): EmbeddingFunction;
42
- /**
43
- * Default embedding function
44
- * Uses HuggingfaceSentenceTransformer for all text embeddings
45
- */
46
- export declare const defaultEmbeddingFunction: EmbeddingFunction;
47
- export declare const defaultBatchEmbeddingFunction: (dataArray: string[]) => Promise<Vector[]>;
48
- /**
49
- * Creates an embedding function that runs in a separate thread
50
- * This is a wrapper around createEmbeddingFunction that uses executeInThread
51
- * @param model Embedding model to use
52
- */
53
- export declare function createThreadedEmbeddingFunction(model: EmbeddingModel): EmbeddingFunction;
@@ -1 +0,0 @@
1
- {"version":3,"file":"huggingfaceEmbedding.d.ts","sourceRoot":"","sources":["../../src/utils/huggingfaceEmbedding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG3E;;;;;GAKG;AACH,qBAAa,8BAA+B,YAAW,cAAc;IACnE,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,SAAS,CAAmD;IAEpE;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBlC;;;OAGG;IACU,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAkD5D;;;;;OAKG;IACU,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA4D/D;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAatC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAInB;AAWD,wBAAgB,kCAAkC,IAAI,iBAAiB,CAiBtE;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBACD,CAAA;AAYtC,eAAO,MAAM,6BAA6B,EAAE,CAC1C,SAAS,EAAE,MAAM,EAAE,KAChB,OAAO,CAAC,MAAM,EAAE,CAepB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAUnB"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Bridge file for TensorFlow.js dependencies
3
- * This file imports the TensorFlow.js dependencies statically and exports them for use in other modules
4
- */
5
- import '@tensorflow/tfjs-backend-cpu';
6
- import '@tensorflow/tfjs-backend-webgl';
7
- import * as use from '@tensorflow-models/universal-sentence-encoder';
8
- interface TensorFlowCore {
9
- setBackend: (backendName: string) => Promise<boolean>;
10
- }
11
- export declare const tf: TensorFlowCore;
12
- export declare const universalSentenceEncoder: typeof use;
13
- export declare function initTensorFlow(backend?: string): Promise<void>;
14
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"tensorflowBridge.d.ts","sourceRoot":"","sources":["../../src/utils/tensorflowBridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,8BAA8B,CAAA;AACrC,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAA;AAGpE,UAAU,cAAc;IACtB,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACtD;AAGD,eAAO,MAAM,EAAE,EAAwB,cAAc,CAAA;AACrD,eAAO,MAAM,wBAAwB,YAAM,CAAA;AAG3C,wBAAsB,cAAc,CAAC,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3E"}
@@ -1,6 +0,0 @@
1
- /**
2
- * TextEncoder/TextDecoder Polyfill for Node.js and Browser environments
3
- * This module provides a consistent way to use TextEncoder/TextDecoder across all environments
4
- */
5
- export declare function ensureTextEncoderPolyfill(): boolean;
6
- //# sourceMappingURL=textEncoderPolyfill.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"textEncoderPolyfill.d.ts","sourceRoot":"","sources":["../../src/utils/textEncoderPolyfill.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+FH,wBAAgB,yBAAyB,YAGxC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Debug Implementation
3
- *
4
- * This module re-exports the standard 'debug' package functions.
5
- * It maintains the same interface as the previous custom implementation
6
- * for backward compatibility.
7
- */
8
- /**
9
- * Create a debug function with the given namespace
10
- * @param namespace - The debug namespace
11
- * @returns A debug function
12
- */
13
- export declare function createDebug(namespace: string): (...args: any[]) => void;
14
- /**
15
- * Export a function that can be used as a drop-in replacement for debug
16
- */
17
- export declare const debug: typeof createDebug;
18
- /**
19
- * Export the debug function as the default export
20
- */
21
- export default createDebug;
@@ -1 +0,0 @@
1
- {"version":3,"file":"universalDebug.d.ts","sourceRoot":"","sources":["../../src/utils/universalDebug.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAEvE;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,oBAAc,CAAC;AAEjC;;GAEG;AACH,eAAe,WAAW,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * UUID Implementation
3
- *
4
- * This module re-exports the standard 'uuid' package functions.
5
- * It maintains the same interface as the previous custom implementation
6
- * for backward compatibility.
7
- */
8
- /**
9
- * Generate a random UUID v4 string
10
- * @returns A UUID v4 string
11
- */
12
- export declare function generateUuidV4(): string;
13
- /**
14
- * Export a function that can be used as a drop-in replacement for uuid.v4
15
- */
16
- export declare const uuidv4: typeof generateUuidV4;
17
- /**
18
- * Export an object with a v4 property to match the structure of the uuid package
19
- */
20
- export declare const uuid: {
21
- v4: typeof generateUuidV4;
22
- };
23
- /**
24
- * Export a named export v4 to match the structure of the uuid package
25
- */
26
- export declare const v4: typeof generateUuidV4;
@@ -1 +0,0 @@
1
- {"version":3,"file":"universalUuid.d.ts","sourceRoot":"","sources":["../../src/utils/universalUuid.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,uBAAiB,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,IAAI;;CAEhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,EAAE,uBAAiB,CAAC"}