@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
@@ -1 +1 @@
1
- {"version":3,"file":"distance.d.ts","sourceRoot":"","sources":["../../src/utils/distance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAe/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,gBA2B5B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAU/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAahC,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,CAmLnB"}
1
+ {"version":3,"file":"distance.d.ts","sourceRoot":"","sources":["../../src/utils/distance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAe/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,gBA2B5B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAU/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAahC,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,CAqMnB"}
@@ -16,11 +16,41 @@ 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
- * This addresses issues with TensorFlow.js in Node.js environments
29
+ * This addresses issues with TensorFlow.js across all server environments
30
+ * (Node.js, serverless, and other server environments)
31
+ *
32
+ * Note: The main TensorFlow.js patching is now centralized in textEncoding.ts
33
+ * and applied through setup.ts. This method only adds additional utility functions
34
+ * that might be needed by TensorFlow.js.
35
+ */
36
+ private addServerCompatibilityPolyfills;
37
+ /**
38
+ * Check if we're running in a test environment
39
+ */
40
+ private isTestEnvironment;
41
+ /**
42
+ * Log message only if verbose mode is enabled or if it's an error
43
+ * This helps suppress non-essential log messages
22
44
  */
23
- private addNodeCompatibilityPolyfills;
45
+ private logger;
46
+ /**
47
+ * Load the Universal Sentence Encoder model with retry logic
48
+ * This helps handle network failures and JSON parsing errors from TensorFlow Hub
49
+ * @param loadFunction The function to load the model
50
+ * @param maxRetries Maximum number of retry attempts
51
+ * @param baseDelay Base delay in milliseconds for exponential backoff
52
+ */
53
+ private loadModelWithRetry;
24
54
  /**
25
55
  * Initialize the embedding model
26
56
  */
@@ -44,17 +74,50 @@ export declare class UniversalSentenceEncoder implements EmbeddingModel {
44
74
  }
45
75
  /**
46
76
  * Create an embedding function from an embedding model
47
- * @param model Embedding model to use
77
+ * @param model Embedding model to use (optional, defaults to UniversalSentenceEncoder)
48
78
  */
49
- export declare function createEmbeddingFunction(model: EmbeddingModel): EmbeddingFunction;
50
- export declare function createTensorFlowEmbeddingFunction(): EmbeddingFunction;
79
+ export declare function createEmbeddingFunction(model?: EmbeddingModel): EmbeddingFunction;
80
+ export declare function createTensorFlowEmbeddingFunction(options?: {
81
+ verbose?: boolean;
82
+ }): EmbeddingFunction;
51
83
  /**
52
84
  * Default embedding function
53
85
  * Uses UniversalSentenceEncoder for all text embeddings
54
86
  * TensorFlow.js is required for this to work
55
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
56
99
  */
57
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
+ */
58
121
  export declare const defaultBatchEmbeddingFunction: (dataArray: string[]) => Promise<Vector[]>;
59
122
  /**
60
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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,CAAA;CAAO,GAAG,CACrF,SAAS,EAAE,MAAM,EAAE,KAChB,OAAO,CAAC,MAAM,EAAE,CAAC,CAErB;AAED;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,cAX7B,MAAM,EAAE,KAChB,OAAO,CAAC,MAAM,EAAE,CAU0D,CAAA;AAE/E;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAUnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAMhC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAMrC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAUlE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAKvD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAElE"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAYhC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAMrC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAUlE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAKvD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAElE"}
@@ -1,22 +1,15 @@
1
- /**
2
- * Unified Text Encoding Utilities
3
- *
4
- * This module provides a consistent way to handle text encoding/decoding across all environments
5
- * using the native TextEncoder/TextDecoder APIs.
6
- */
7
- /**
8
- * Get a text encoder that works in the current environment
9
- * @returns A TextEncoder instance
10
- */
1
+ declare global {
2
+ let _utilShim: any;
3
+ let __TextEncoder__: typeof TextEncoder;
4
+ let __TextDecoder__: typeof TextDecoder;
5
+ let __brainy_util__: any;
6
+ let __utilShim: any;
7
+ }
8
+ /**
9
+ * Apply the TensorFlow.js platform patch if it hasn't been applied already
10
+ * This is a safety measure in case the module-level patch didn't run
11
+ * Now works across all environments: browser, Node.js, and serverless/server
12
+ */
13
+ export declare function applyTensorFlowPatch(): Promise<void>;
11
14
  export declare function getTextEncoder(): TextEncoder;
12
- /**
13
- * Get a text decoder that works in the current environment
14
- * @returns A TextDecoder instance
15
- */
16
15
  export declare function getTextDecoder(): TextDecoder;
17
- /**
18
- * Apply the TensorFlow.js platform patch if needed
19
- * This function patches the global object to provide a PlatformNode class
20
- * that uses native TextEncoder/TextDecoder
21
- */
22
- export declare function applyTensorFlowPatch(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"textEncoding.d.ts","sourceRoot":"","sources":["../../src/utils/textEncoding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAiE3C"}
1
+ {"version":3,"file":"textEncoding.d.ts","sourceRoot":"","sources":["../../src/utils/textEncoding.ts"],"names":[],"mappings":"AAMA,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,SAAS,EAAE,GAAG,CAAA;IAClB,IAAI,eAAe,EAAE,OAAO,WAAW,CAAA;IACvC,IAAI,eAAe,EAAE,OAAO,WAAW,CAAA;IACvC,IAAI,eAAe,EAAE,GAAG,CAAA;IACxB,IAAI,UAAU,EAAE,GAAG,CAAA;CACpB;AAiPD;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAqE1D;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
@@ -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.11.0";
5
+ export declare const VERSION = "0.13.0";
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "0.11.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",
7
7
  "types": "dist/unified.d.ts",
8
8
  "type": "module",
9
- "sideEffects": false,
9
+ "sideEffects": [
10
+ "./dist/setup.js",
11
+ "./dist/utils/textEncoding.js",
12
+ "./src/setup.ts",
13
+ "./src/utils/textEncoding.ts"
14
+ ],
10
15
  "exports": {
11
16
  ".": {
12
17
  "import": "./dist/unified.js",
@@ -15,6 +20,10 @@
15
20
  "./min": {
16
21
  "import": "./dist/unified.min.js"
17
22
  },
23
+ "./setup": {
24
+ "import": "./dist/setup.js",
25
+ "types": "./dist/setup.d.ts"
26
+ },
18
27
  "./types/graphTypes": {
19
28
  "import": "./dist/types/graphTypes.js",
20
29
  "types": "./dist/types/graphTypes.d.ts"
@@ -30,6 +39,10 @@
30
39
  "./dist/utils/textEncoding.js": {
31
40
  "import": "./dist/utils/textEncoding.js",
32
41
  "types": "./dist/utils/textEncoding.d.ts"
42
+ },
43
+ "./dist/setup.js": {
44
+ "import": "./dist/setup.js",
45
+ "types": "./dist/setup.d.ts"
33
46
  }
34
47
  },
35
48
  "engines": {
@@ -41,7 +54,7 @@
41
54
  "build:browser": "BUILD_TYPE=browser rollup -c rollup.config.js",
42
55
  "build:cli": "cd cli-package && npm run build",
43
56
  "start": "node dist/unified.js",
44
- "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",
45
58
  "version": "node scripts/generate-version.js",
46
59
  "version:patch": "npm version patch",
47
60
  "version:minor": "npm version minor",
@@ -54,16 +67,16 @@
54
67
  "prepare": "npm run build",
55
68
  "deploy": "npm run build && npm publish && node scripts/create-github-release.js",
56
69
  "deploy:cli": "node scripts/generate-version.js && cd cli-package && npm run build && npm publish",
57
- "deploy:cloud:aws": "cd cloud-wrapper && npm run build && npm run deploy:aws",
58
- "deploy:cloud:gcp": "cd cloud-wrapper && npm run build && npm run deploy:gcp",
59
- "deploy:cloud:cloudflare": "cd cloud-wrapper && npm run build && npm run deploy:cloudflare",
60
- "deploy:cloud": "echo 'Please use one of the following commands to deploy to a specific cloud provider:' && echo ' npm run deploy:cloud:aws' && echo ' npm run deploy:cloud:gcp' && echo ' npm run deploy:cloud:cloudflare'",
61
- "postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
62
70
  "dry-run": "npm pack --dry-run",
63
- "test:cli": "node scripts/test-cli-locally.js",
64
- "test:tensorflow": "node test-tensorflow-textencoder.js",
65
- "test:all": "node scripts/test-all-environments.js",
66
- "test": "npm run test:all"
71
+ "test": "vitest run",
72
+ "test:watch": "vitest",
73
+ "test:ui": "vitest --ui",
74
+ "test:node": "vitest run tests/environment.node.test.ts tests/core.test.ts tests/vector-operations.test.ts tests/tensorflow-patch.test.ts",
75
+ "test:browser": "vitest run tests/environment.browser.test.ts --environment jsdom",
76
+ "test:core": "vitest run tests/core.test.ts",
77
+ "test:coverage": "vitest run --coverage",
78
+ "test:size": "vitest run tests/package-size-limit.test.ts",
79
+ "test:all": "npm run build && vitest run"
67
80
  },
68
81
  "keywords": [
69
82
  "vector-database",
@@ -111,16 +124,22 @@
111
124
  "@rollup/plugin-node-resolve": "^15.2.3",
112
125
  "@rollup/plugin-replace": "^5.0.5",
113
126
  "@rollup/plugin-typescript": "^11.1.6",
127
+ "@types/jsdom": "^21.1.7",
114
128
  "@types/node": "^20.11.30",
115
129
  "@types/uuid": "^10.0.0",
116
130
  "@typescript-eslint/eslint-plugin": "^7.4.0",
117
131
  "@typescript-eslint/parser": "^7.4.0",
132
+ "@vitest/ui": "^3.2.4",
118
133
  "eslint": "^8.57.0",
134
+ "happy-dom": "^18.0.1",
135
+ "jsdom": "^26.1.0",
119
136
  "puppeteer": "^22.5.0",
120
137
  "rollup": "^4.13.0",
121
138
  "rollup-plugin-terser": "^7.0.2",
122
139
  "tslib": "^2.6.2",
123
- "typescript": "^5.4.5"
140
+ "typescript": "^5.4.5",
141
+ "vitest": "^3.2.4",
142
+ "@vitest/coverage-v8": "^3.2.4"
124
143
  },
125
144
  "dependencies": {
126
145
  "@aws-sdk/client-s3": "^3.540.0",
@@ -1,57 +0,0 @@
1
- /**
2
- * Huggingface Activation Augmentation
3
- *
4
- * This augmentation provides embedding and text generation capabilities using Huggingface models.
5
- * It implements the IActivationAugmentation interface to make it pluggable with other solutions.
6
- */
7
- import { AugmentationResponse, IActivationAugmentation } from '../types/augmentations.js';
8
- /**
9
- * Huggingface Activation Augmentation
10
- *
11
- * This augmentation uses Huggingface transformers and sentence_transformers (specifically all-MiniLM-L6-v2)
12
- * for embedding and text generation capabilities.
13
- */
14
- export declare class HuggingfaceActivation implements IActivationAugmentation {
15
- readonly name: string;
16
- readonly description: string;
17
- enabled: boolean;
18
- private embeddingModel;
19
- private embeddingFunction;
20
- private initialized;
21
- private hfInference;
22
- constructor();
23
- /**
24
- * Initializes the augmentation
25
- */
26
- initialize(): Promise<void>;
27
- /**
28
- * Shuts down the augmentation
29
- */
30
- shutDown(): Promise<void>;
31
- /**
32
- * Gets the status of the augmentation
33
- */
34
- getStatus(): Promise<'active' | 'inactive' | 'error'>;
35
- /**
36
- * Triggers an action based on a processed command or internal state
37
- * @param actionName The name of the action to trigger
38
- * @param parameters Optional parameters for the action
39
- */
40
- triggerAction(actionName: string, parameters?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
41
- /**
42
- * Generates an expressive output or response from Brainy
43
- * @param knowledgeId The identifier of the knowledge to express
44
- * @param format The desired output format (e.g., 'text', 'json')
45
- */
46
- generateOutput(knowledgeId: string, format: string): Promise<AugmentationResponse<string | Record<string, unknown>>>;
47
- /**
48
- * Interacts with an external system or API
49
- * @param systemId The identifier of the external system
50
- * @param payload The data to send to the external system
51
- */
52
- interactExternal(systemId: string, payload: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
53
- }
54
- /**
55
- * Creates a new instance of the Huggingface Activation Augmentation
56
- */
57
- export declare function createHuggingfaceActivation(): IActivationAugmentation;
@@ -1 +0,0 @@
1
- {"version":3,"file":"huggingfaceActivation.d.ts","sourceRoot":"","sources":["../../src/augmentations/huggingfaceActivation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAoB,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAI3G;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,uBAAuB;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA2B;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA2F;IACvH,OAAO,EAAE,OAAO,CAAO;IAEvB,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,iBAAiB,CAAgC;IACzD,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,WAAW,CAAY;;IAO/B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BjC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB/B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAI3D;;;;OAIG;IACG,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAsEzC;;;;OAIG;IACG,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IA+ClE;;;;OAIG;IACG,gBAAgB,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAoD1C;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,uBAAuB,CAErE"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Registration file for Huggingface Activation Augmentation
3
- *
4
- * This file registers the Huggingface Activation Augmentation with the augmentation registry.
5
- */
6
- export declare function registerHuggingfaceActivation(): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"huggingfaceActivationRegistration.d.ts","sourceRoot":"","sources":["../../src/augmentations/huggingfaceActivationRegistration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}