@soulcraft/brainy 0.12.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.
@@ -16,6 +16,14 @@ export declare class UniversalSentenceEncoder implements EmbeddingModel {
16
16
  private tf;
17
17
  private use;
18
18
  private backend;
19
+ private verbose;
20
+ /**
21
+ * Create a new UniversalSentenceEncoder instance
22
+ * @param options Configuration options
23
+ */
24
+ constructor(options?: {
25
+ verbose?: boolean;
26
+ });
19
27
  /**
20
28
  * Add polyfills and patches for TensorFlow.js compatibility
21
29
  * This addresses issues with TensorFlow.js across all server environments
@@ -31,9 +39,10 @@ export declare class UniversalSentenceEncoder implements EmbeddingModel {
31
39
  */
32
40
  private isTestEnvironment;
33
41
  /**
34
- * Log message only if not in test environment
42
+ * Log message only if verbose mode is enabled or if it's an error
43
+ * This helps suppress non-essential log messages
35
44
  */
36
- private logIfNotTest;
45
+ private logger;
37
46
  /**
38
47
  * Load the Universal Sentence Encoder model with retry logic
39
48
  * This helps handle network failures and JSON parsing errors from TensorFlow Hub
@@ -68,14 +77,47 @@ export declare class UniversalSentenceEncoder implements EmbeddingModel {
68
77
  * @param model Embedding model to use (optional, defaults to UniversalSentenceEncoder)
69
78
  */
70
79
  export declare function createEmbeddingFunction(model?: EmbeddingModel): EmbeddingFunction;
71
- export declare function createTensorFlowEmbeddingFunction(): EmbeddingFunction;
80
+ export declare function createTensorFlowEmbeddingFunction(options?: {
81
+ verbose?: boolean;
82
+ }): EmbeddingFunction;
72
83
  /**
73
84
  * Default embedding function
74
85
  * Uses UniversalSentenceEncoder for all text embeddings
75
86
  * TensorFlow.js is required for this to work
76
87
  * Uses CPU for compatibility
88
+ * @param options Configuration options
89
+ * @param options.verbose Whether to log non-essential messages (default: true)
90
+ */
91
+ export declare function getDefaultEmbeddingFunction(options?: {
92
+ verbose?: boolean;
93
+ }): EmbeddingFunction;
94
+ /**
95
+ * Default embedding function with default options
96
+ * Uses UniversalSentenceEncoder for all text embeddings
97
+ * TensorFlow.js is required for this to work
98
+ * Uses CPU for compatibility
77
99
  */
78
100
  export declare const defaultEmbeddingFunction: EmbeddingFunction;
101
+ export declare function createBatchEmbeddingFunction(options?: {
102
+ verbose?: boolean;
103
+ }): (dataArray: string[]) => Promise<Vector[]>;
104
+ /**
105
+ * Get a batch embedding function with custom options
106
+ * Uses UniversalSentenceEncoder for all text embeddings
107
+ * TensorFlow.js is required for this to work
108
+ * Processes all items in a single batch operation
109
+ * @param options Configuration options
110
+ * @param options.verbose Whether to log non-essential messages (default: true)
111
+ */
112
+ export declare function getDefaultBatchEmbeddingFunction(options?: {
113
+ verbose?: boolean;
114
+ }): (dataArray: string[]) => Promise<Vector[]>;
115
+ /**
116
+ * Default batch embedding function with default options
117
+ * Uses UniversalSentenceEncoder for all text embeddings
118
+ * TensorFlow.js is required for this to work
119
+ * Processes all items in a single batch operation
120
+ */
79
121
  export declare const defaultBatchEmbeddingFunction: (dataArray: string[]) => Promise<Vector[]>;
80
122
  /**
81
123
  * Creates an embedding function that runs in a separate thread
@@ -1 +1 @@
1
- {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/utils/embedding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG3E;;;;;;;GAOG;AACH,qBAAa,wBAAyB,YAAW,cAAc;IAC7D,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;;;;;OAQG;IACH,OAAO,CAAC,+BAA+B;IA6CvC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;;;;;OAMG;YACW,kBAAkB;IAsEhC;;OAEG;IACU,IAAI,IAA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AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAUnB"}
@@ -2,4 +2,4 @@
2
2
  * This file is auto-generated during the build process.
3
3
  * Do not modify this file directly.
4
4
  */
5
- export declare const VERSION = "0.12.0";
5
+ export declare const VERSION = "0.13.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
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",
@@ -54,7 +54,7 @@
54
54
  "build:browser": "BUILD_TYPE=browser rollup -c rollup.config.js",
55
55
  "build:cli": "cd cli-package && npm run build",
56
56
  "start": "node dist/unified.js",
57
- "demo": "npm run build && npm run build:browser && npx http-server -o /index.html",
57
+ "demo": "npm run build && npm run build:browser && npx http-server -o /demo/index.html",
58
58
  "version": "node scripts/generate-version.js",
59
59
  "version:patch": "npm version patch",
60
60
  "version:minor": "npm version minor",
@@ -67,7 +67,6 @@
67
67
  "prepare": "npm run build",
68
68
  "deploy": "npm run build && npm publish && node scripts/create-github-release.js",
69
69
  "deploy:cli": "node scripts/generate-version.js && cd cli-package && npm run build && npm publish",
70
- "postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
71
70
  "dry-run": "npm pack --dry-run",
72
71
  "test": "vitest run",
73
72
  "test:watch": "vitest",
@@ -76,6 +75,7 @@
76
75
  "test:browser": "vitest run tests/environment.browser.test.ts --environment jsdom",
77
76
  "test:core": "vitest run tests/core.test.ts",
78
77
  "test:coverage": "vitest run --coverage",
78
+ "test:size": "vitest run tests/package-size-limit.test.ts",
79
79
  "test:all": "npm run build && vitest run"
80
80
  },
81
81
  "keywords": [