@soulcraft/brainy 0.9.13 → 0.9.15
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.demo.md +9 -3
- package/README.md +3 -3
- package/dist/utils/distance-js.d.ts +38 -0
- package/dist/utils/distance-wasm.d.ts +36 -0
- package/dist/utils/version.d.ts +1 -1
- package/package.json +3 -2
package/README.demo.md
CHANGED
|
@@ -4,8 +4,8 @@ The Brainy interactive demo showcases the library's features in a web browser. F
|
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
- Make sure you have Node.js installed (version
|
|
8
|
-
- Ensure the project is built (`npm run build:
|
|
7
|
+
- Make sure you have Node.js installed (version 24.0.0 or higher)
|
|
8
|
+
- Ensure the project is built (run both `npm run build` and `npm run build:browser`)
|
|
9
9
|
|
|
10
10
|
## Running the Demo
|
|
11
11
|
|
|
@@ -51,7 +51,13 @@ The Brainy library uses a two-step build process:
|
|
|
51
51
|
You can run both steps together with:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
npm run build:
|
|
54
|
+
npm run build && npm run build:browser
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or simply use the demo script which does this for you:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run demo
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
The browser bundle is created from `src/unified.ts`, which provides environment detection and adapts to browser,
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](CONTRIBUTING.md)
|
|
9
|
-
[](https://www.npmjs.com/package/@soulcraft/brainy)
|
|
10
10
|
|
|
11
11
|
[//]: # ([](https://github.com/sodal-project/cartographer))
|
|
12
12
|
|
|
@@ -300,8 +300,8 @@ Brainy uses a modern build system that optimizes for both Node.js and browser en
|
|
|
300
300
|
5. **Build Scripts**
|
|
301
301
|
- `npm run build`: Builds the Node.js version
|
|
302
302
|
- `npm run build:browser`: Builds the browser-optimized version
|
|
303
|
-
- `npm run build:
|
|
304
|
-
- `npm run demo`: Builds
|
|
303
|
+
- `npm run build:cli`: Builds the CLI version
|
|
304
|
+
- `npm run demo`: Builds both Node.js and browser versions and starts a demo server
|
|
305
305
|
- GitHub Actions workflow: Automatically deploys the demo directory to GitHub Pages when pushing to the main branch
|
|
306
306
|
|
|
307
307
|
### Running the Pipeline
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
package/dist/utils/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15",
|
|
4
4
|
"description": "A vector graph database using HNSW indexing with Origin Private File System storage",
|
|
5
5
|
"main": "dist/unified.js",
|
|
6
6
|
"module": "dist/unified.js",
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
"prebuild": "node scripts/generate-version.js",
|
|
32
32
|
"build": "BUILD_TYPE=unified rollup -c rollup.config.js",
|
|
33
33
|
"build:browser": "BUILD_TYPE=browser rollup -c rollup.config.js",
|
|
34
|
+
"build:cli": "BUILD_TYPE=cli rollup -c rollup.config.js",
|
|
34
35
|
"start": "node dist/unified.js",
|
|
35
36
|
"demo": "npm run build && npm run build:browser && npx http-server -o /index.html",
|
|
36
|
-
"cli": "node ./cli-wrapper.js",
|
|
37
|
+
"cli": "npm run build:cli && node ./cli-wrapper.js",
|
|
37
38
|
"version": "node scripts/generate-version.js",
|
|
38
39
|
"version:patch": "npm version patch",
|
|
39
40
|
"version:minor": "npm version minor",
|