rag-lite-ts 2.1.1 → 2.3.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.
- package/README.md +88 -5
- package/dist/{cli → cjs/cli}/indexer.js +73 -15
- package/dist/cjs/cli/ui-server.d.ts +5 -0
- package/dist/cjs/cli/ui-server.js +152 -0
- package/dist/{cli.js → cjs/cli.js} +25 -6
- package/dist/{core → cjs/core}/binary-index-format.js +6 -3
- package/dist/{core → cjs/core}/db.d.ts +56 -0
- package/dist/{core → cjs/core}/db.js +105 -0
- package/dist/{core → cjs/core}/ingestion.js +3 -0
- package/dist/cjs/core/knowledge-base-manager.d.ts +109 -0
- package/dist/cjs/core/knowledge-base-manager.js +256 -0
- package/dist/{core → cjs/core}/model-validator.js +1 -1
- package/dist/{core → cjs/core}/search-pipeline.js +1 -1
- package/dist/{core → cjs/core}/search.js +1 -1
- package/dist/cjs/core/vector-index-messages.d.ts +52 -0
- package/dist/cjs/core/vector-index-messages.js +5 -0
- package/dist/cjs/core/vector-index-worker.d.ts +6 -0
- package/dist/cjs/core/vector-index-worker.js +304 -0
- package/dist/cjs/core/vector-index.d.ts +107 -0
- package/dist/cjs/core/vector-index.js +344 -0
- package/dist/{factories → cjs/factories}/ingestion-factory.js +3 -7
- package/dist/{factories → cjs/factories}/search-factory.js +11 -0
- package/dist/{index-manager.d.ts → cjs/index-manager.d.ts} +23 -3
- package/dist/{index-manager.js → cjs/index-manager.js} +84 -15
- package/dist/{index.d.ts → cjs/index.d.ts} +2 -1
- package/dist/{index.js → cjs/index.js} +3 -1
- package/dist/esm/api-errors.d.ts +90 -0
- package/dist/esm/api-errors.js +320 -0
- package/dist/esm/cli/indexer.d.ts +11 -0
- package/dist/esm/cli/indexer.js +529 -0
- package/dist/esm/cli/search.d.ts +7 -0
- package/dist/esm/cli/search.js +332 -0
- package/dist/esm/cli/ui-server.d.ts +5 -0
- package/dist/esm/cli/ui-server.js +152 -0
- package/dist/esm/cli.d.ts +3 -0
- package/dist/esm/cli.js +548 -0
- package/dist/esm/config.d.ts +51 -0
- package/dist/esm/config.js +79 -0
- package/dist/esm/core/abstract-embedder.d.ts +125 -0
- package/dist/esm/core/abstract-embedder.js +264 -0
- package/dist/esm/core/actionable-error-messages.d.ts +60 -0
- package/dist/esm/core/actionable-error-messages.js +397 -0
- package/dist/esm/core/adapters.d.ts +93 -0
- package/dist/esm/core/adapters.js +139 -0
- package/dist/esm/core/batch-processing-optimizer.d.ts +155 -0
- package/dist/esm/core/batch-processing-optimizer.js +536 -0
- package/dist/esm/core/binary-index-format.d.ts +78 -0
- package/dist/esm/core/binary-index-format.js +294 -0
- package/dist/esm/core/chunker.d.ts +119 -0
- package/dist/esm/core/chunker.js +73 -0
- package/dist/esm/core/cli-database-utils.d.ts +53 -0
- package/dist/esm/core/cli-database-utils.js +239 -0
- package/dist/esm/core/config.d.ts +102 -0
- package/dist/esm/core/config.js +247 -0
- package/dist/esm/core/content-errors.d.ts +111 -0
- package/dist/esm/core/content-errors.js +362 -0
- package/dist/esm/core/content-manager.d.ts +335 -0
- package/dist/esm/core/content-manager.js +1476 -0
- package/dist/esm/core/content-performance-optimizer.d.ts +150 -0
- package/dist/esm/core/content-performance-optimizer.js +516 -0
- package/dist/esm/core/content-resolver.d.ts +104 -0
- package/dist/esm/core/content-resolver.js +285 -0
- package/dist/esm/core/cross-modal-search.d.ts +164 -0
- package/dist/esm/core/cross-modal-search.js +342 -0
- package/dist/esm/core/database-connection-manager.d.ts +109 -0
- package/dist/esm/core/database-connection-manager.js +310 -0
- package/dist/esm/core/db.d.ts +269 -0
- package/dist/esm/core/db.js +1000 -0
- package/dist/esm/core/embedder-factory.d.ts +154 -0
- package/dist/esm/core/embedder-factory.js +311 -0
- package/dist/esm/core/error-handler.d.ts +112 -0
- package/dist/esm/core/error-handler.js +239 -0
- package/dist/esm/core/index.d.ts +59 -0
- package/dist/esm/core/index.js +69 -0
- package/dist/esm/core/ingestion.d.ts +202 -0
- package/dist/esm/core/ingestion.js +904 -0
- package/dist/esm/core/interfaces.d.ts +408 -0
- package/dist/esm/core/interfaces.js +106 -0
- package/dist/esm/core/knowledge-base-manager.d.ts +109 -0
- package/dist/esm/core/knowledge-base-manager.js +256 -0
- package/dist/esm/core/lazy-dependency-loader.d.ts +147 -0
- package/dist/esm/core/lazy-dependency-loader.js +435 -0
- package/dist/esm/core/mode-detection-service.d.ts +150 -0
- package/dist/esm/core/mode-detection-service.js +565 -0
- package/dist/esm/core/mode-model-validator.d.ts +92 -0
- package/dist/esm/core/mode-model-validator.js +203 -0
- package/dist/esm/core/model-registry.d.ts +116 -0
- package/dist/esm/core/model-registry.js +411 -0
- package/dist/esm/core/model-validator.d.ts +217 -0
- package/dist/esm/core/model-validator.js +782 -0
- package/dist/esm/core/path-manager.d.ts +47 -0
- package/dist/esm/core/path-manager.js +71 -0
- package/dist/esm/core/raglite-paths.d.ts +121 -0
- package/dist/esm/core/raglite-paths.js +145 -0
- package/dist/esm/core/reranking-config.d.ts +42 -0
- package/dist/esm/core/reranking-config.js +147 -0
- package/dist/esm/core/reranking-factory.d.ts +92 -0
- package/dist/esm/core/reranking-factory.js +410 -0
- package/dist/esm/core/reranking-strategies.d.ts +310 -0
- package/dist/esm/core/reranking-strategies.js +650 -0
- package/dist/esm/core/resource-cleanup.d.ts +163 -0
- package/dist/esm/core/resource-cleanup.js +371 -0
- package/dist/esm/core/resource-manager.d.ts +212 -0
- package/dist/esm/core/resource-manager.js +564 -0
- package/dist/esm/core/search-pipeline.d.ts +111 -0
- package/dist/esm/core/search-pipeline.js +287 -0
- package/dist/esm/core/search.d.ts +141 -0
- package/dist/esm/core/search.js +320 -0
- package/dist/esm/core/streaming-operations.d.ts +145 -0
- package/dist/esm/core/streaming-operations.js +409 -0
- package/dist/esm/core/types.d.ts +66 -0
- package/dist/esm/core/types.js +6 -0
- package/dist/esm/core/universal-embedder.d.ts +177 -0
- package/dist/esm/core/universal-embedder.js +139 -0
- package/dist/esm/core/validation-messages.d.ts +99 -0
- package/dist/esm/core/validation-messages.js +334 -0
- package/dist/esm/core/vector-index-messages.d.ts +52 -0
- package/dist/esm/core/vector-index-messages.js +5 -0
- package/dist/esm/core/vector-index-worker.d.ts +6 -0
- package/dist/esm/core/vector-index-worker.js +304 -0
- package/dist/esm/core/vector-index.d.ts +107 -0
- package/dist/esm/core/vector-index.js +344 -0
- package/dist/esm/dom-polyfills.d.ts +6 -0
- package/dist/esm/dom-polyfills.js +37 -0
- package/dist/esm/factories/index.d.ts +27 -0
- package/dist/esm/factories/index.js +29 -0
- package/dist/esm/factories/ingestion-factory.d.ts +200 -0
- package/dist/esm/factories/ingestion-factory.js +473 -0
- package/dist/esm/factories/search-factory.d.ts +154 -0
- package/dist/esm/factories/search-factory.js +355 -0
- package/dist/esm/file-processor.d.ts +147 -0
- package/dist/esm/file-processor.js +963 -0
- package/dist/esm/index-manager.d.ts +136 -0
- package/dist/esm/index-manager.js +667 -0
- package/dist/esm/index.d.ts +76 -0
- package/dist/esm/index.js +112 -0
- package/dist/esm/indexer.d.ts +7 -0
- package/dist/esm/indexer.js +54 -0
- package/dist/esm/ingestion.d.ts +63 -0
- package/dist/esm/ingestion.js +124 -0
- package/dist/esm/mcp-server.d.ts +46 -0
- package/dist/esm/mcp-server.js +1820 -0
- package/dist/esm/multimodal/clip-embedder.d.ts +327 -0
- package/dist/esm/multimodal/clip-embedder.js +996 -0
- package/dist/esm/multimodal/index.d.ts +6 -0
- package/dist/esm/multimodal/index.js +6 -0
- package/dist/esm/preprocess.d.ts +19 -0
- package/dist/esm/preprocess.js +203 -0
- package/dist/esm/preprocessors/index.d.ts +17 -0
- package/dist/esm/preprocessors/index.js +38 -0
- package/dist/esm/preprocessors/mdx.d.ts +25 -0
- package/dist/esm/preprocessors/mdx.js +101 -0
- package/dist/esm/preprocessors/mermaid.d.ts +68 -0
- package/dist/esm/preprocessors/mermaid.js +329 -0
- package/dist/esm/preprocessors/registry.d.ts +56 -0
- package/dist/esm/preprocessors/registry.js +179 -0
- package/dist/esm/run-error-recovery-tests.d.ts +7 -0
- package/dist/esm/run-error-recovery-tests.js +101 -0
- package/dist/esm/search-standalone.d.ts +7 -0
- package/dist/esm/search-standalone.js +117 -0
- package/dist/esm/search.d.ts +99 -0
- package/dist/esm/search.js +177 -0
- package/dist/esm/test-utils.d.ts +18 -0
- package/dist/esm/test-utils.js +27 -0
- package/dist/esm/text/chunker.d.ts +33 -0
- package/dist/esm/text/chunker.js +279 -0
- package/dist/esm/text/embedder.d.ts +111 -0
- package/dist/esm/text/embedder.js +386 -0
- package/dist/esm/text/index.d.ts +8 -0
- package/dist/esm/text/index.js +9 -0
- package/dist/esm/text/preprocessors/index.d.ts +17 -0
- package/dist/esm/text/preprocessors/index.js +38 -0
- package/dist/esm/text/preprocessors/mdx.d.ts +25 -0
- package/dist/esm/text/preprocessors/mdx.js +101 -0
- package/dist/esm/text/preprocessors/mermaid.d.ts +68 -0
- package/dist/esm/text/preprocessors/mermaid.js +330 -0
- package/dist/esm/text/preprocessors/registry.d.ts +56 -0
- package/dist/esm/text/preprocessors/registry.js +180 -0
- package/dist/esm/text/reranker.d.ts +49 -0
- package/dist/esm/text/reranker.js +274 -0
- package/dist/esm/text/sentence-transformer-embedder.d.ts +96 -0
- package/dist/esm/text/sentence-transformer-embedder.js +340 -0
- package/dist/esm/text/tokenizer.d.ts +22 -0
- package/dist/esm/text/tokenizer.js +64 -0
- package/dist/esm/types.d.ts +83 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/utils/vector-math.d.ts +31 -0
- package/dist/esm/utils/vector-math.js +70 -0
- package/package.json +39 -14
- package/dist/core/vector-index.d.ts +0 -72
- package/dist/core/vector-index.js +0 -331
- /package/dist/{api-errors.d.ts → cjs/api-errors.d.ts} +0 -0
- /package/dist/{api-errors.js → cjs/api-errors.js} +0 -0
- /package/dist/{cli → cjs/cli}/indexer.d.ts +0 -0
- /package/dist/{cli → cjs/cli}/search.d.ts +0 -0
- /package/dist/{cli → cjs/cli}/search.js +0 -0
- /package/dist/{cli.d.ts → cjs/cli.d.ts} +0 -0
- /package/dist/{config.d.ts → cjs/config.d.ts} +0 -0
- /package/dist/{config.js → cjs/config.js} +0 -0
- /package/dist/{core → cjs/core}/abstract-embedder.d.ts +0 -0
- /package/dist/{core → cjs/core}/abstract-embedder.js +0 -0
- /package/dist/{core → cjs/core}/actionable-error-messages.d.ts +0 -0
- /package/dist/{core → cjs/core}/actionable-error-messages.js +0 -0
- /package/dist/{core → cjs/core}/adapters.d.ts +0 -0
- /package/dist/{core → cjs/core}/adapters.js +0 -0
- /package/dist/{core → cjs/core}/batch-processing-optimizer.d.ts +0 -0
- /package/dist/{core → cjs/core}/batch-processing-optimizer.js +0 -0
- /package/dist/{core → cjs/core}/binary-index-format.d.ts +0 -0
- /package/dist/{core → cjs/core}/chunker.d.ts +0 -0
- /package/dist/{core → cjs/core}/chunker.js +0 -0
- /package/dist/{core → cjs/core}/cli-database-utils.d.ts +0 -0
- /package/dist/{core → cjs/core}/cli-database-utils.js +0 -0
- /package/dist/{core → cjs/core}/config.d.ts +0 -0
- /package/dist/{core → cjs/core}/config.js +0 -0
- /package/dist/{core → cjs/core}/content-errors.d.ts +0 -0
- /package/dist/{core → cjs/core}/content-errors.js +0 -0
- /package/dist/{core → cjs/core}/content-manager.d.ts +0 -0
- /package/dist/{core → cjs/core}/content-manager.js +0 -0
- /package/dist/{core → cjs/core}/content-performance-optimizer.d.ts +0 -0
- /package/dist/{core → cjs/core}/content-performance-optimizer.js +0 -0
- /package/dist/{core → cjs/core}/content-resolver.d.ts +0 -0
- /package/dist/{core → cjs/core}/content-resolver.js +0 -0
- /package/dist/{core → cjs/core}/cross-modal-search.d.ts +0 -0
- /package/dist/{core → cjs/core}/cross-modal-search.js +0 -0
- /package/dist/{core → cjs/core}/database-connection-manager.d.ts +0 -0
- /package/dist/{core → cjs/core}/database-connection-manager.js +0 -0
- /package/dist/{core → cjs/core}/embedder-factory.d.ts +0 -0
- /package/dist/{core → cjs/core}/embedder-factory.js +0 -0
- /package/dist/{core → cjs/core}/error-handler.d.ts +0 -0
- /package/dist/{core → cjs/core}/error-handler.js +0 -0
- /package/dist/{core → cjs/core}/index.d.ts +0 -0
- /package/dist/{core → cjs/core}/index.js +0 -0
- /package/dist/{core → cjs/core}/ingestion.d.ts +0 -0
- /package/dist/{core → cjs/core}/interfaces.d.ts +0 -0
- /package/dist/{core → cjs/core}/interfaces.js +0 -0
- /package/dist/{core → cjs/core}/lazy-dependency-loader.d.ts +0 -0
- /package/dist/{core → cjs/core}/lazy-dependency-loader.js +0 -0
- /package/dist/{core → cjs/core}/mode-detection-service.d.ts +0 -0
- /package/dist/{core → cjs/core}/mode-detection-service.js +0 -0
- /package/dist/{core → cjs/core}/mode-model-validator.d.ts +0 -0
- /package/dist/{core → cjs/core}/mode-model-validator.js +0 -0
- /package/dist/{core → cjs/core}/model-registry.d.ts +0 -0
- /package/dist/{core → cjs/core}/model-registry.js +0 -0
- /package/dist/{core → cjs/core}/model-validator.d.ts +0 -0
- /package/dist/{core → cjs/core}/path-manager.d.ts +0 -0
- /package/dist/{core → cjs/core}/path-manager.js +0 -0
- /package/dist/{core → cjs/core}/raglite-paths.d.ts +0 -0
- /package/dist/{core → cjs/core}/raglite-paths.js +0 -0
- /package/dist/{core → cjs/core}/reranking-config.d.ts +0 -0
- /package/dist/{core → cjs/core}/reranking-config.js +0 -0
- /package/dist/{core → cjs/core}/reranking-factory.d.ts +0 -0
- /package/dist/{core → cjs/core}/reranking-factory.js +0 -0
- /package/dist/{core → cjs/core}/reranking-strategies.d.ts +0 -0
- /package/dist/{core → cjs/core}/reranking-strategies.js +0 -0
- /package/dist/{core → cjs/core}/resource-cleanup.d.ts +0 -0
- /package/dist/{core → cjs/core}/resource-cleanup.js +0 -0
- /package/dist/{core → cjs/core}/resource-manager.d.ts +0 -0
- /package/dist/{core → cjs/core}/resource-manager.js +0 -0
- /package/dist/{core → cjs/core}/search-pipeline.d.ts +0 -0
- /package/dist/{core → cjs/core}/search.d.ts +0 -0
- /package/dist/{core → cjs/core}/streaming-operations.d.ts +0 -0
- /package/dist/{core → cjs/core}/streaming-operations.js +0 -0
- /package/dist/{core → cjs/core}/types.d.ts +0 -0
- /package/dist/{core → cjs/core}/types.js +0 -0
- /package/dist/{core → cjs/core}/universal-embedder.d.ts +0 -0
- /package/dist/{core → cjs/core}/universal-embedder.js +0 -0
- /package/dist/{core → cjs/core}/validation-messages.d.ts +0 -0
- /package/dist/{core → cjs/core}/validation-messages.js +0 -0
- /package/dist/{dom-polyfills.d.ts → cjs/dom-polyfills.d.ts} +0 -0
- /package/dist/{dom-polyfills.js → cjs/dom-polyfills.js} +0 -0
- /package/dist/{factories → cjs/factories}/index.d.ts +0 -0
- /package/dist/{factories → cjs/factories}/index.js +0 -0
- /package/dist/{factories → cjs/factories}/ingestion-factory.d.ts +0 -0
- /package/dist/{factories → cjs/factories}/search-factory.d.ts +0 -0
- /package/dist/{file-processor.d.ts → cjs/file-processor.d.ts} +0 -0
- /package/dist/{file-processor.js → cjs/file-processor.js} +0 -0
- /package/dist/{indexer.d.ts → cjs/indexer.d.ts} +0 -0
- /package/dist/{indexer.js → cjs/indexer.js} +0 -0
- /package/dist/{ingestion.d.ts → cjs/ingestion.d.ts} +0 -0
- /package/dist/{ingestion.js → cjs/ingestion.js} +0 -0
- /package/dist/{mcp-server.d.ts → cjs/mcp-server.d.ts} +0 -0
- /package/dist/{mcp-server.js → cjs/mcp-server.js} +0 -0
- /package/dist/{multimodal → cjs/multimodal}/clip-embedder.d.ts +0 -0
- /package/dist/{multimodal → cjs/multimodal}/clip-embedder.js +0 -0
- /package/dist/{multimodal → cjs/multimodal}/index.d.ts +0 -0
- /package/dist/{multimodal → cjs/multimodal}/index.js +0 -0
- /package/dist/{preprocess.d.ts → cjs/preprocess.d.ts} +0 -0
- /package/dist/{preprocess.js → cjs/preprocess.js} +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/index.d.ts +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/index.js +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/mdx.d.ts +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/mdx.js +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/mermaid.d.ts +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/mermaid.js +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/registry.d.ts +0 -0
- /package/dist/{preprocessors → cjs/preprocessors}/registry.js +0 -0
- /package/dist/{run-error-recovery-tests.d.ts → cjs/run-error-recovery-tests.d.ts} +0 -0
- /package/dist/{run-error-recovery-tests.js → cjs/run-error-recovery-tests.js} +0 -0
- /package/dist/{search-standalone.d.ts → cjs/search-standalone.d.ts} +0 -0
- /package/dist/{search-standalone.js → cjs/search-standalone.js} +0 -0
- /package/dist/{search.d.ts → cjs/search.d.ts} +0 -0
- /package/dist/{search.js → cjs/search.js} +0 -0
- /package/dist/{test-utils.d.ts → cjs/test-utils.d.ts} +0 -0
- /package/dist/{test-utils.js → cjs/test-utils.js} +0 -0
- /package/dist/{text → cjs/text}/chunker.d.ts +0 -0
- /package/dist/{text → cjs/text}/chunker.js +0 -0
- /package/dist/{text → cjs/text}/embedder.d.ts +0 -0
- /package/dist/{text → cjs/text}/embedder.js +0 -0
- /package/dist/{text → cjs/text}/index.d.ts +0 -0
- /package/dist/{text → cjs/text}/index.js +0 -0
- /package/dist/{text → cjs/text}/preprocessors/index.d.ts +0 -0
- /package/dist/{text → cjs/text}/preprocessors/index.js +0 -0
- /package/dist/{text → cjs/text}/preprocessors/mdx.d.ts +0 -0
- /package/dist/{text → cjs/text}/preprocessors/mdx.js +0 -0
- /package/dist/{text → cjs/text}/preprocessors/mermaid.d.ts +0 -0
- /package/dist/{text → cjs/text}/preprocessors/mermaid.js +0 -0
- /package/dist/{text → cjs/text}/preprocessors/registry.d.ts +0 -0
- /package/dist/{text → cjs/text}/preprocessors/registry.js +0 -0
- /package/dist/{text → cjs/text}/reranker.d.ts +0 -0
- /package/dist/{text → cjs/text}/reranker.js +0 -0
- /package/dist/{text → cjs/text}/sentence-transformer-embedder.d.ts +0 -0
- /package/dist/{text → cjs/text}/sentence-transformer-embedder.js +0 -0
- /package/dist/{text → cjs/text}/tokenizer.d.ts +0 -0
- /package/dist/{text → cjs/text}/tokenizer.js +0 -0
- /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
- /package/dist/{types.js → cjs/types.js} +0 -0
- /package/dist/{utils → cjs/utils}/vector-math.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/vector-math.js +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE MODULE — Universal Embedder Interface for Chameleon Architecture
|
|
3
|
+
*
|
|
4
|
+
* Model-agnostic interfaces supporting both text and multimodal models.
|
|
5
|
+
* Designed for runtime polymorphism and extensibility.
|
|
6
|
+
*
|
|
7
|
+
* ARCHITECTURAL ROLE:
|
|
8
|
+
* This file contains ONLY interfaces, types, and utility functions - no implementation logic.
|
|
9
|
+
* It defines the contract that all embedder implementations must follow.
|
|
10
|
+
*
|
|
11
|
+
* CONTENTS:
|
|
12
|
+
* - UniversalEmbedder interface: Core contract for all embedders
|
|
13
|
+
* - Type definitions: ModelType, ContentType, etc.
|
|
14
|
+
* - Error classes: ModelValidationError, ContentTypeError, etc.
|
|
15
|
+
* - Utility functions: Type guards and validation helpers
|
|
16
|
+
* - Constants: Default capabilities and content types
|
|
17
|
+
*
|
|
18
|
+
* USAGE:
|
|
19
|
+
* - Implementation layers (text, multimodal) implement these interfaces
|
|
20
|
+
* - Core layer uses these types for dependency injection
|
|
21
|
+
* - Public API exports these types for external use
|
|
22
|
+
*/
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// ERROR TYPES
|
|
25
|
+
// =============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Model validation error for unsupported or incompatible models
|
|
28
|
+
*/
|
|
29
|
+
export class ModelValidationError extends Error {
|
|
30
|
+
modelName;
|
|
31
|
+
availableModels;
|
|
32
|
+
constructor(modelName, availableModels, message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.modelName = modelName;
|
|
35
|
+
this.availableModels = availableModels;
|
|
36
|
+
this.name = 'ModelValidationError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Transformers.js compatibility error for version mismatches
|
|
41
|
+
*/
|
|
42
|
+
export class TransformersCompatibilityError extends Error {
|
|
43
|
+
modelName;
|
|
44
|
+
requiredVersion;
|
|
45
|
+
currentVersion;
|
|
46
|
+
constructor(modelName, requiredVersion, currentVersion, message) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.modelName = modelName;
|
|
49
|
+
this.requiredVersion = requiredVersion;
|
|
50
|
+
this.currentVersion = currentVersion;
|
|
51
|
+
this.name = 'TransformersCompatibilityError';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Content type error for unsupported content types
|
|
56
|
+
*/
|
|
57
|
+
export class ContentTypeError extends Error {
|
|
58
|
+
contentType;
|
|
59
|
+
supportedTypes;
|
|
60
|
+
constructor(contentType, supportedTypes, message) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.contentType = contentType;
|
|
63
|
+
this.supportedTypes = supportedTypes;
|
|
64
|
+
this.name = 'ContentTypeError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// =============================================================================
|
|
68
|
+
// UTILITY TYPES
|
|
69
|
+
// =============================================================================
|
|
70
|
+
/**
|
|
71
|
+
* Type guard for checking if an embedder supports images
|
|
72
|
+
*/
|
|
73
|
+
export function supportsImages(embedder) {
|
|
74
|
+
return embedder.supportedContentTypes.includes('image') &&
|
|
75
|
+
typeof embedder.embedImage === 'function';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Type guard for checking if an embedder supports a specific content type
|
|
79
|
+
*/
|
|
80
|
+
export function supportsContentType(embedder, contentType) {
|
|
81
|
+
return embedder.supportedContentTypes.includes(contentType);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Utility function to create enhanced embedding results
|
|
85
|
+
*/
|
|
86
|
+
export function createEnhancedEmbeddingResult(embeddingId, vector, contentType, metadata) {
|
|
87
|
+
return {
|
|
88
|
+
embedding_id: embeddingId,
|
|
89
|
+
vector,
|
|
90
|
+
contentType,
|
|
91
|
+
metadata
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Utility function to validate content type against supported types
|
|
96
|
+
*/
|
|
97
|
+
export function validateContentType(contentType, supportedTypes) {
|
|
98
|
+
if (!supportedTypes.includes(contentType)) {
|
|
99
|
+
throw new ContentTypeError(contentType, supportedTypes, `Content type '${contentType}' is not supported. Supported types: ${supportedTypes.join(', ')}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// =============================================================================
|
|
103
|
+
// CONSTANTS
|
|
104
|
+
// =============================================================================
|
|
105
|
+
/**
|
|
106
|
+
* Default supported content types for different model types
|
|
107
|
+
*/
|
|
108
|
+
export const DEFAULT_CONTENT_TYPES = {
|
|
109
|
+
'sentence-transformer': ['text'],
|
|
110
|
+
'clip': ['text', 'image']
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Default model capabilities for different model types
|
|
114
|
+
*/
|
|
115
|
+
export const DEFAULT_CAPABILITIES = {
|
|
116
|
+
'sentence-transformer': {
|
|
117
|
+
supportsText: true,
|
|
118
|
+
supportsImages: false,
|
|
119
|
+
supportsBatchProcessing: true,
|
|
120
|
+
supportsMetadata: true,
|
|
121
|
+
maxBatchSize: 32,
|
|
122
|
+
maxTextLength: 512
|
|
123
|
+
},
|
|
124
|
+
'clip': {
|
|
125
|
+
supportsText: true,
|
|
126
|
+
supportsImages: true,
|
|
127
|
+
supportsBatchProcessing: true,
|
|
128
|
+
supportsMetadata: true,
|
|
129
|
+
maxBatchSize: 16,
|
|
130
|
+
maxTextLength: 77,
|
|
131
|
+
supportedImageFormats: ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
|
132
|
+
// Enhanced capabilities for fixed CLIP implementation
|
|
133
|
+
supportsMultimodal: true,
|
|
134
|
+
supportsCrossModalSearch: true,
|
|
135
|
+
unifiedEmbeddingSpace: true,
|
|
136
|
+
reliableImplementation: true
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=universal-embedder.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE MODULE — Validation Messages and Error Descriptions
|
|
3
|
+
* Comprehensive error messages and user guidance for model validation
|
|
4
|
+
* Provides helpful, actionable error messages with troubleshooting steps
|
|
5
|
+
*/
|
|
6
|
+
import type { ModelType } from './universal-embedder.js';
|
|
7
|
+
/**
|
|
8
|
+
* Error message templates for different validation scenarios
|
|
9
|
+
*/
|
|
10
|
+
export declare const ERROR_MESSAGES: {
|
|
11
|
+
readonly MODEL_NOT_FOUND: (modelName: string, suggestions: string[]) => {
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
details: string[];
|
|
15
|
+
suggestions: string[];
|
|
16
|
+
actions: string[];
|
|
17
|
+
};
|
|
18
|
+
readonly TRANSFORMERS_VERSION_INCOMPATIBLE: (modelName: string, required: string, current: string) => {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
details: string[];
|
|
22
|
+
suggestions: string[];
|
|
23
|
+
actions: string[];
|
|
24
|
+
};
|
|
25
|
+
readonly INSUFFICIENT_MEMORY: (modelName: string, required: number, available: number) => {
|
|
26
|
+
title: string;
|
|
27
|
+
description: string;
|
|
28
|
+
details: string[];
|
|
29
|
+
suggestions: string[];
|
|
30
|
+
actions: string[];
|
|
31
|
+
};
|
|
32
|
+
readonly PLATFORM_UNSUPPORTED: (modelName: string, currentPlatform: string, supportedPlatforms: string[]) => {
|
|
33
|
+
title: string;
|
|
34
|
+
description: string;
|
|
35
|
+
details: string[];
|
|
36
|
+
suggestions: string[];
|
|
37
|
+
actions: string[];
|
|
38
|
+
};
|
|
39
|
+
readonly FEATURES_MISSING: (modelName: string, missingFeatures: string[]) => {
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
details: string[];
|
|
43
|
+
suggestions: string[];
|
|
44
|
+
actions: string[];
|
|
45
|
+
};
|
|
46
|
+
readonly CONTENT_TYPE_UNSUPPORTED: (contentType: string, modelName: string, supportedTypes: string[]) => {
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
details: string[];
|
|
50
|
+
suggestions: string[];
|
|
51
|
+
actions: string[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Warning message templates for non-critical issues
|
|
56
|
+
*/
|
|
57
|
+
export declare const WARNING_MESSAGES: {
|
|
58
|
+
readonly HIGH_MEMORY_USAGE: (modelName: string, memoryMB: number) => {
|
|
59
|
+
title: string;
|
|
60
|
+
message: string;
|
|
61
|
+
suggestions: string[];
|
|
62
|
+
};
|
|
63
|
+
readonly LIMITED_BATCH_SIZE: (modelName: string, maxBatchSize: number) => {
|
|
64
|
+
title: string;
|
|
65
|
+
message: string;
|
|
66
|
+
suggestions: string[];
|
|
67
|
+
};
|
|
68
|
+
readonly EXPERIMENTAL_FEATURES: (modelName: string, features: string[]) => {
|
|
69
|
+
title: string;
|
|
70
|
+
message: string;
|
|
71
|
+
suggestions: string[];
|
|
72
|
+
};
|
|
73
|
+
readonly PERFORMANCE_IMPACT: (modelName: string, reason: string) => {
|
|
74
|
+
title: string;
|
|
75
|
+
message: string;
|
|
76
|
+
suggestions: string[];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Format an error message for console output
|
|
81
|
+
*/
|
|
82
|
+
export declare function formatErrorMessage(error: ReturnType<typeof ERROR_MESSAGES[keyof typeof ERROR_MESSAGES]>): string;
|
|
83
|
+
/**
|
|
84
|
+
* Format a warning message for console output
|
|
85
|
+
*/
|
|
86
|
+
export declare function formatWarningMessage(warning: ReturnType<typeof WARNING_MESSAGES[keyof typeof WARNING_MESSAGES]>): string;
|
|
87
|
+
/**
|
|
88
|
+
* Create a comprehensive error message for model validation failure
|
|
89
|
+
*/
|
|
90
|
+
export declare function createValidationErrorMessage(modelName: string, errorType: 'not_found' | 'version_incompatible' | 'insufficient_memory' | 'platform_unsupported' | 'features_missing' | 'content_type_unsupported', context?: Record<string, any>): string;
|
|
91
|
+
/**
|
|
92
|
+
* Create helpful suggestions based on model type and use case
|
|
93
|
+
*/
|
|
94
|
+
export declare function createModelSuggestions(modelType?: ModelType, contentTypes?: string[], memoryLimit?: number): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Get troubleshooting steps for common issues
|
|
97
|
+
*/
|
|
98
|
+
export declare function getTroubleshootingSteps(issue: string): string[];
|
|
99
|
+
//# sourceMappingURL=validation-messages.d.ts.map
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE MODULE — Validation Messages and Error Descriptions
|
|
3
|
+
* Comprehensive error messages and user guidance for model validation
|
|
4
|
+
* Provides helpful, actionable error messages with troubleshooting steps
|
|
5
|
+
*/
|
|
6
|
+
import { ModelRegistry } from './model-registry.js';
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// ERROR MESSAGE TEMPLATES
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Error message templates for different validation scenarios
|
|
12
|
+
*/
|
|
13
|
+
export const ERROR_MESSAGES = {
|
|
14
|
+
MODEL_NOT_FOUND: (modelName, suggestions) => ({
|
|
15
|
+
title: `Model '${modelName}' not found`,
|
|
16
|
+
description: `The specified model is not supported by the Chameleon architecture.`,
|
|
17
|
+
details: [
|
|
18
|
+
`Model '${modelName}' is not in the supported models registry.`,
|
|
19
|
+
`This could be due to a typo in the model name or the model not being compatible with transformers.js.`
|
|
20
|
+
],
|
|
21
|
+
suggestions: suggestions.length > 0 ? [
|
|
22
|
+
`Did you mean one of these models?`,
|
|
23
|
+
...suggestions.map(s => ` • ${s}`)
|
|
24
|
+
] : [
|
|
25
|
+
`Available models:`,
|
|
26
|
+
...ModelRegistry.getSupportedModels().map(s => ` • ${s}`)
|
|
27
|
+
],
|
|
28
|
+
actions: [
|
|
29
|
+
`Check the model name for typos`,
|
|
30
|
+
`Use 'ModelRegistry.getSupportedModels()' to see all available models`,
|
|
31
|
+
`Visit the documentation for the latest supported models list`
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
TRANSFORMERS_VERSION_INCOMPATIBLE: (modelName, required, current) => ({
|
|
35
|
+
title: `Transformers.js version incompatible`,
|
|
36
|
+
description: `Model '${modelName}' requires a newer version of transformers.js.`,
|
|
37
|
+
details: [
|
|
38
|
+
`Required version: ${required}`,
|
|
39
|
+
`Current version: ${current}`,
|
|
40
|
+
`The model uses features not available in the current transformers.js version.`
|
|
41
|
+
],
|
|
42
|
+
suggestions: [
|
|
43
|
+
`Upgrade transformers.js to the latest version:`,
|
|
44
|
+
` npm install @huggingface/transformers@latest`,
|
|
45
|
+
``,
|
|
46
|
+
`Or install a specific compatible version:`,
|
|
47
|
+
` npm install @huggingface/transformers@${required.replace(/[>=<~^]/g, '')}`
|
|
48
|
+
],
|
|
49
|
+
actions: [
|
|
50
|
+
`Update your package.json dependencies`,
|
|
51
|
+
`Run npm install to update transformers.js`,
|
|
52
|
+
`Restart your application after updating`
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
INSUFFICIENT_MEMORY: (modelName, required, available) => ({
|
|
56
|
+
title: `Insufficient memory for model`,
|
|
57
|
+
description: `Model '${modelName}' requires more memory than available.`,
|
|
58
|
+
details: [
|
|
59
|
+
`Required memory: ${required}MB`,
|
|
60
|
+
`Available memory: ${available}MB`,
|
|
61
|
+
`Shortfall: ${required - available}MB`
|
|
62
|
+
],
|
|
63
|
+
suggestions: [
|
|
64
|
+
`Consider using a smaller model variant:`,
|
|
65
|
+
...ModelRegistry.getSupportedModels().filter(name => {
|
|
66
|
+
const info = ModelRegistry.getModelInfo(name);
|
|
67
|
+
return info &&
|
|
68
|
+
info.requirements.minimumMemory &&
|
|
69
|
+
info.requirements.minimumMemory <= available;
|
|
70
|
+
}).map(name => ` • ${name}`),
|
|
71
|
+
``,
|
|
72
|
+
`Or increase available memory by:`,
|
|
73
|
+
` • Closing other applications`,
|
|
74
|
+
` • Increasing Node.js memory limit: --max-old-space-size=${required + 512}`,
|
|
75
|
+
` • Using a machine with more RAM`
|
|
76
|
+
],
|
|
77
|
+
actions: [
|
|
78
|
+
`Free up system memory`,
|
|
79
|
+
`Choose a more memory-efficient model`,
|
|
80
|
+
`Consider using model quantization if available`
|
|
81
|
+
]
|
|
82
|
+
}),
|
|
83
|
+
PLATFORM_UNSUPPORTED: (modelName, currentPlatform, supportedPlatforms) => ({
|
|
84
|
+
title: `Platform not supported`,
|
|
85
|
+
description: `Model '${modelName}' is not supported on ${currentPlatform}.`,
|
|
86
|
+
details: [
|
|
87
|
+
`Current platform: ${currentPlatform}`,
|
|
88
|
+
`Supported platforms: ${supportedPlatforms.join(', ')}`,
|
|
89
|
+
`The model may use platform-specific features or optimizations.`
|
|
90
|
+
],
|
|
91
|
+
suggestions: [
|
|
92
|
+
`Try running on a supported platform:`,
|
|
93
|
+
...supportedPlatforms.map(platform => ` • ${platform}`),
|
|
94
|
+
``,
|
|
95
|
+
`Or use a platform-agnostic model:`,
|
|
96
|
+
...ModelRegistry.getSupportedModels().filter(name => {
|
|
97
|
+
const info = ModelRegistry.getModelInfo(name);
|
|
98
|
+
return info &&
|
|
99
|
+
info.requirements.platformSupport &&
|
|
100
|
+
info.requirements.platformSupport.includes(currentPlatform);
|
|
101
|
+
}).slice(0, 3).map(name => ` • ${name}`)
|
|
102
|
+
],
|
|
103
|
+
actions: [
|
|
104
|
+
`Switch to a supported platform`,
|
|
105
|
+
`Use a different model that supports your platform`,
|
|
106
|
+
`Check if there are platform-specific installation instructions`
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
FEATURES_MISSING: (modelName, missingFeatures) => ({
|
|
110
|
+
title: `Required features not available`,
|
|
111
|
+
description: `Model '${modelName}' requires features not available in current transformers.js version.`,
|
|
112
|
+
details: [
|
|
113
|
+
`Missing features: ${missingFeatures.join(', ')}`,
|
|
114
|
+
`These features are required for the model to function properly.`
|
|
115
|
+
],
|
|
116
|
+
suggestions: [
|
|
117
|
+
`Upgrade transformers.js to get missing features:`,
|
|
118
|
+
` npm install @huggingface/transformers@latest`,
|
|
119
|
+
``,
|
|
120
|
+
`Or use a model that doesn't require these features:`,
|
|
121
|
+
...ModelRegistry.getSupportedModels().filter(name => {
|
|
122
|
+
const info = ModelRegistry.getModelInfo(name);
|
|
123
|
+
return info &&
|
|
124
|
+
(!info.requirements.requiredFeatures ||
|
|
125
|
+
info.requirements.requiredFeatures.every(f => !missingFeatures.includes(f)));
|
|
126
|
+
}).slice(0, 3).map(name => ` • ${name}`)
|
|
127
|
+
],
|
|
128
|
+
actions: [
|
|
129
|
+
`Update transformers.js to the latest version`,
|
|
130
|
+
`Check the transformers.js changelog for feature availability`,
|
|
131
|
+
`Use an alternative model with fewer feature requirements`
|
|
132
|
+
]
|
|
133
|
+
}),
|
|
134
|
+
CONTENT_TYPE_UNSUPPORTED: (contentType, modelName, supportedTypes) => ({
|
|
135
|
+
title: `Content type not supported`,
|
|
136
|
+
description: `Model '${modelName}' does not support '${contentType}' content.`,
|
|
137
|
+
details: [
|
|
138
|
+
`Requested content type: ${contentType}`,
|
|
139
|
+
`Supported content types: ${supportedTypes.join(', ')}`,
|
|
140
|
+
`The model was not trained to handle this type of content.`
|
|
141
|
+
],
|
|
142
|
+
suggestions: [
|
|
143
|
+
`Use a model that supports '${contentType}' content:`,
|
|
144
|
+
...ModelRegistry.getModelsByContentType(contentType).slice(0, 3).map(name => ` • ${name}`),
|
|
145
|
+
``,
|
|
146
|
+
`Or convert your content to a supported type:`,
|
|
147
|
+
...supportedTypes.map(type => ` • Convert to ${type}`)
|
|
148
|
+
],
|
|
149
|
+
actions: [
|
|
150
|
+
`Choose a multimodal model for mixed content types`,
|
|
151
|
+
`Preprocess your content to match supported types`,
|
|
152
|
+
`Use separate models for different content types`
|
|
153
|
+
]
|
|
154
|
+
})
|
|
155
|
+
};
|
|
156
|
+
// =============================================================================
|
|
157
|
+
// WARNING MESSAGE TEMPLATES
|
|
158
|
+
// =============================================================================
|
|
159
|
+
/**
|
|
160
|
+
* Warning message templates for non-critical issues
|
|
161
|
+
*/
|
|
162
|
+
export const WARNING_MESSAGES = {
|
|
163
|
+
HIGH_MEMORY_USAGE: (modelName, memoryMB) => ({
|
|
164
|
+
title: `High memory usage`,
|
|
165
|
+
message: `Model '${modelName}' requires ${memoryMB}MB of memory, which may impact performance.`,
|
|
166
|
+
suggestions: [
|
|
167
|
+
`Monitor system memory usage during operation`,
|
|
168
|
+
`Consider using a smaller model variant if performance is affected`,
|
|
169
|
+
`Ensure sufficient swap space is available`
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
172
|
+
LIMITED_BATCH_SIZE: (modelName, maxBatchSize) => ({
|
|
173
|
+
title: `Limited batch processing`,
|
|
174
|
+
message: `Model '${modelName}' supports maximum batch size of ${maxBatchSize}.`,
|
|
175
|
+
suggestions: [
|
|
176
|
+
`Use smaller batch sizes for optimal performance`,
|
|
177
|
+
`Process large datasets in smaller chunks`,
|
|
178
|
+
`Consider parallel processing with multiple model instances`
|
|
179
|
+
]
|
|
180
|
+
}),
|
|
181
|
+
EXPERIMENTAL_FEATURES: (modelName, features) => ({
|
|
182
|
+
title: `Experimental features in use`,
|
|
183
|
+
message: `Model '${modelName}' uses experimental features: ${features.join(', ')}.`,
|
|
184
|
+
suggestions: [
|
|
185
|
+
`Test thoroughly before using in production`,
|
|
186
|
+
`Monitor for unexpected behavior or errors`,
|
|
187
|
+
`Have fallback options ready`,
|
|
188
|
+
`Check for updates that may stabilize these features`
|
|
189
|
+
]
|
|
190
|
+
}),
|
|
191
|
+
PERFORMANCE_IMPACT: (modelName, reason) => ({
|
|
192
|
+
title: `Potential performance impact`,
|
|
193
|
+
message: `Model '${modelName}' may have reduced performance: ${reason}.`,
|
|
194
|
+
suggestions: [
|
|
195
|
+
`Monitor processing times and resource usage`,
|
|
196
|
+
`Consider using GPU acceleration if available`,
|
|
197
|
+
`Optimize batch sizes for your use case`,
|
|
198
|
+
`Profile your application to identify bottlenecks`
|
|
199
|
+
]
|
|
200
|
+
})
|
|
201
|
+
};
|
|
202
|
+
// =============================================================================
|
|
203
|
+
// MESSAGE FORMATTING UTILITIES
|
|
204
|
+
// =============================================================================
|
|
205
|
+
/**
|
|
206
|
+
* Format an error message for console output
|
|
207
|
+
*/
|
|
208
|
+
export function formatErrorMessage(error) {
|
|
209
|
+
const lines = [];
|
|
210
|
+
lines.push(`❌ ${error.title}`);
|
|
211
|
+
lines.push('');
|
|
212
|
+
lines.push(error.description);
|
|
213
|
+
if (error.details.length > 0) {
|
|
214
|
+
lines.push('');
|
|
215
|
+
lines.push('Details:');
|
|
216
|
+
error.details.forEach(detail => lines.push(` ${detail}`));
|
|
217
|
+
}
|
|
218
|
+
if (error.suggestions.length > 0) {
|
|
219
|
+
lines.push('');
|
|
220
|
+
lines.push('Suggestions:');
|
|
221
|
+
error.suggestions.forEach(suggestion => lines.push(` ${suggestion}`));
|
|
222
|
+
}
|
|
223
|
+
if (error.actions.length > 0) {
|
|
224
|
+
lines.push('');
|
|
225
|
+
lines.push('Actions:');
|
|
226
|
+
error.actions.forEach((action, index) => lines.push(` ${index + 1}. ${action}`));
|
|
227
|
+
}
|
|
228
|
+
return lines.join('\n');
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Format a warning message for console output
|
|
232
|
+
*/
|
|
233
|
+
export function formatWarningMessage(warning) {
|
|
234
|
+
const lines = [];
|
|
235
|
+
lines.push(`⚠️ ${warning.title}`);
|
|
236
|
+
lines.push('');
|
|
237
|
+
lines.push(warning.message);
|
|
238
|
+
if (warning.suggestions.length > 0) {
|
|
239
|
+
lines.push('');
|
|
240
|
+
lines.push('Suggestions:');
|
|
241
|
+
warning.suggestions.forEach(suggestion => lines.push(` • ${suggestion}`));
|
|
242
|
+
}
|
|
243
|
+
return lines.join('\n');
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create a comprehensive error message for model validation failure
|
|
247
|
+
*/
|
|
248
|
+
export function createValidationErrorMessage(modelName, errorType, context = {}) {
|
|
249
|
+
switch (errorType) {
|
|
250
|
+
case 'not_found':
|
|
251
|
+
return formatErrorMessage(ERROR_MESSAGES.MODEL_NOT_FOUND(modelName, context.suggestions || []));
|
|
252
|
+
case 'version_incompatible':
|
|
253
|
+
return formatErrorMessage(ERROR_MESSAGES.TRANSFORMERS_VERSION_INCOMPATIBLE(modelName, context.required || 'unknown', context.current || 'unknown'));
|
|
254
|
+
case 'insufficient_memory':
|
|
255
|
+
return formatErrorMessage(ERROR_MESSAGES.INSUFFICIENT_MEMORY(modelName, context.required || 0, context.available || 0));
|
|
256
|
+
case 'platform_unsupported':
|
|
257
|
+
return formatErrorMessage(ERROR_MESSAGES.PLATFORM_UNSUPPORTED(modelName, context.currentPlatform || 'unknown', context.supportedPlatforms || []));
|
|
258
|
+
case 'features_missing':
|
|
259
|
+
return formatErrorMessage(ERROR_MESSAGES.FEATURES_MISSING(modelName, context.missingFeatures || []));
|
|
260
|
+
case 'content_type_unsupported':
|
|
261
|
+
return formatErrorMessage(ERROR_MESSAGES.CONTENT_TYPE_UNSUPPORTED(context.contentType || 'unknown', modelName, context.supportedTypes || []));
|
|
262
|
+
default:
|
|
263
|
+
return `❌ Validation failed for model '${modelName}': ${errorType}`;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Create helpful suggestions based on model type and use case
|
|
268
|
+
*/
|
|
269
|
+
export function createModelSuggestions(modelType, contentTypes, memoryLimit) {
|
|
270
|
+
const suggestions = [];
|
|
271
|
+
if (modelType === 'sentence-transformer') {
|
|
272
|
+
suggestions.push('For text-only tasks, sentence-transformers are most efficient');
|
|
273
|
+
suggestions.push('all-MiniLM-L6-v2 offers the best balance of speed and accuracy');
|
|
274
|
+
suggestions.push('all-mpnet-base-v2 provides higher accuracy but uses more memory');
|
|
275
|
+
}
|
|
276
|
+
if (modelType === 'clip') {
|
|
277
|
+
suggestions.push('CLIP models support both text and image content');
|
|
278
|
+
suggestions.push('clip-vit-base-patch32 is recommended for most use cases');
|
|
279
|
+
suggestions.push('patch16 variants are more accurate but slower');
|
|
280
|
+
}
|
|
281
|
+
if (contentTypes?.includes('image')) {
|
|
282
|
+
suggestions.push('Multimodal content requires CLIP models');
|
|
283
|
+
suggestions.push('Ensure images are in supported formats (jpg, png, webp)');
|
|
284
|
+
suggestions.push('Consider image preprocessing for better results');
|
|
285
|
+
}
|
|
286
|
+
if (memoryLimit && memoryLimit < 1024) {
|
|
287
|
+
suggestions.push('Low memory environments should use smaller models');
|
|
288
|
+
suggestions.push('Consider model quantization to reduce memory usage');
|
|
289
|
+
suggestions.push('Process content in smaller batches');
|
|
290
|
+
}
|
|
291
|
+
return suggestions;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get troubleshooting steps for common issues
|
|
295
|
+
*/
|
|
296
|
+
export function getTroubleshootingSteps(issue) {
|
|
297
|
+
const steps = {
|
|
298
|
+
'model_loading_failed': [
|
|
299
|
+
'Check internet connection for model download',
|
|
300
|
+
'Verify model name spelling and availability',
|
|
301
|
+
'Ensure sufficient disk space for model cache',
|
|
302
|
+
'Try clearing the model cache and re-downloading',
|
|
303
|
+
'Check transformers.js version compatibility'
|
|
304
|
+
],
|
|
305
|
+
'out_of_memory': [
|
|
306
|
+
'Reduce batch size for processing',
|
|
307
|
+
'Use a smaller model variant',
|
|
308
|
+
'Increase Node.js memory limit with --max-old-space-size',
|
|
309
|
+
'Close other memory-intensive applications',
|
|
310
|
+
'Consider using model quantization'
|
|
311
|
+
],
|
|
312
|
+
'slow_performance': [
|
|
313
|
+
'Use GPU acceleration if available',
|
|
314
|
+
'Optimize batch sizes for your hardware',
|
|
315
|
+
'Consider using a smaller, faster model',
|
|
316
|
+
'Profile your code to identify bottlenecks',
|
|
317
|
+
'Use appropriate hardware for your model size'
|
|
318
|
+
],
|
|
319
|
+
'compatibility_issues': [
|
|
320
|
+
'Update transformers.js to the latest version',
|
|
321
|
+
'Check model requirements against your environment',
|
|
322
|
+
'Verify platform compatibility (Node.js vs browser)',
|
|
323
|
+
'Test with a known working model first',
|
|
324
|
+
'Check for conflicting dependencies'
|
|
325
|
+
]
|
|
326
|
+
};
|
|
327
|
+
return steps[issue] || [
|
|
328
|
+
'Check the documentation for your specific issue',
|
|
329
|
+
'Search for similar issues in the project repository',
|
|
330
|
+
'Ensure all dependencies are up to date',
|
|
331
|
+
'Try with a minimal test case to isolate the problem'
|
|
332
|
+
];
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=validation-messages.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message protocol for VectorIndex worker thread communication
|
|
3
|
+
*/
|
|
4
|
+
export interface VectorIndexRequest {
|
|
5
|
+
id: number;
|
|
6
|
+
type: 'init' | 'loadIndex' | 'saveIndex' | 'addVector' | 'addVectors' | 'search' | 'getCurrentCount' | 'resizeIndex' | 'reset' | 'cleanup' | 'indexExists' | 'setEf';
|
|
7
|
+
payload?: any;
|
|
8
|
+
}
|
|
9
|
+
export interface VectorIndexResponse {
|
|
10
|
+
id: number;
|
|
11
|
+
type: 'success' | 'error';
|
|
12
|
+
payload?: any;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface InitPayload {
|
|
16
|
+
dimensions: number;
|
|
17
|
+
maxElements: number;
|
|
18
|
+
M?: number;
|
|
19
|
+
efConstruction?: number;
|
|
20
|
+
seed?: number;
|
|
21
|
+
indexPath: string;
|
|
22
|
+
}
|
|
23
|
+
export interface LoadIndexPayload {
|
|
24
|
+
indexPath: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AddVectorPayload {
|
|
27
|
+
id: number;
|
|
28
|
+
vector: ArrayBuffer;
|
|
29
|
+
dimensions: number;
|
|
30
|
+
}
|
|
31
|
+
export interface AddVectorsPayload {
|
|
32
|
+
vectors: Array<{
|
|
33
|
+
id: number;
|
|
34
|
+
vector: ArrayBuffer;
|
|
35
|
+
dimensions: number;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface SearchPayload {
|
|
39
|
+
queryVector: ArrayBuffer;
|
|
40
|
+
dimensions: number;
|
|
41
|
+
k: number;
|
|
42
|
+
}
|
|
43
|
+
export interface ResizeIndexPayload {
|
|
44
|
+
newMaxElements: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SetEfPayload {
|
|
47
|
+
ef: number;
|
|
48
|
+
}
|
|
49
|
+
export interface IndexExistsPayload {
|
|
50
|
+
indexPath: string;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=vector-index-messages.d.ts.map
|