rag-lite-ts 1.0.2 → 2.0.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 +606 -93
- package/dist/cli/indexer.js +192 -4
- package/dist/cli/search.js +50 -11
- package/dist/cli.js +183 -26
- package/dist/core/abstract-embedder.d.ts +125 -0
- package/dist/core/abstract-embedder.js +264 -0
- package/dist/core/actionable-error-messages.d.ts +60 -0
- package/dist/core/actionable-error-messages.js +397 -0
- package/dist/core/batch-processing-optimizer.d.ts +155 -0
- package/dist/core/batch-processing-optimizer.js +541 -0
- package/dist/core/chunker.d.ts +2 -0
- package/dist/core/cli-database-utils.d.ts +53 -0
- package/dist/core/cli-database-utils.js +239 -0
- package/dist/core/config.js +10 -3
- package/dist/core/content-errors.d.ts +111 -0
- package/dist/core/content-errors.js +362 -0
- package/dist/core/content-manager.d.ts +343 -0
- package/dist/core/content-manager.js +1504 -0
- package/dist/core/content-performance-optimizer.d.ts +150 -0
- package/dist/core/content-performance-optimizer.js +516 -0
- package/dist/core/content-resolver.d.ts +104 -0
- package/dist/core/content-resolver.js +285 -0
- package/dist/core/cross-modal-search.d.ts +164 -0
- package/dist/core/cross-modal-search.js +342 -0
- package/dist/core/database-connection-manager.d.ts +109 -0
- package/dist/core/database-connection-manager.js +304 -0
- package/dist/core/db.d.ts +141 -2
- package/dist/core/db.js +631 -89
- package/dist/core/embedder-factory.d.ts +176 -0
- package/dist/core/embedder-factory.js +338 -0
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +4 -1
- package/dist/core/ingestion.d.ts +85 -15
- package/dist/core/ingestion.js +510 -45
- package/dist/core/lazy-dependency-loader.d.ts +152 -0
- package/dist/core/lazy-dependency-loader.js +453 -0
- package/dist/core/mode-detection-service.d.ts +150 -0
- package/dist/core/mode-detection-service.js +565 -0
- package/dist/core/mode-model-validator.d.ts +92 -0
- package/dist/core/mode-model-validator.js +203 -0
- package/dist/core/model-registry.d.ts +120 -0
- package/dist/core/model-registry.js +415 -0
- package/dist/core/model-validator.d.ts +217 -0
- package/dist/core/model-validator.js +782 -0
- package/dist/core/polymorphic-search-factory.d.ts +154 -0
- package/dist/core/polymorphic-search-factory.js +344 -0
- package/dist/core/raglite-paths.d.ts +121 -0
- package/dist/core/raglite-paths.js +145 -0
- package/dist/core/reranking-config.d.ts +42 -0
- package/dist/core/reranking-config.js +156 -0
- package/dist/core/reranking-factory.d.ts +92 -0
- package/dist/core/reranking-factory.js +591 -0
- package/dist/core/reranking-strategies.d.ts +325 -0
- package/dist/core/reranking-strategies.js +720 -0
- package/dist/core/resource-cleanup.d.ts +163 -0
- package/dist/core/resource-cleanup.js +371 -0
- package/dist/core/resource-manager.d.ts +212 -0
- package/dist/core/resource-manager.js +564 -0
- package/dist/core/search.d.ts +28 -1
- package/dist/core/search.js +83 -5
- package/dist/core/streaming-operations.d.ts +145 -0
- package/dist/core/streaming-operations.js +409 -0
- package/dist/core/types.d.ts +3 -0
- package/dist/core/universal-embedder.d.ts +177 -0
- package/dist/core/universal-embedder.js +139 -0
- package/dist/core/validation-messages.d.ts +99 -0
- package/dist/core/validation-messages.js +334 -0
- package/dist/core/vector-index.js +7 -8
- package/dist/factories/index.d.ts +1 -1
- package/dist/factories/text-factory.d.ts +128 -34
- package/dist/factories/text-factory.js +346 -97
- package/dist/file-processor.d.ts +88 -2
- package/dist/file-processor.js +720 -17
- package/dist/index.d.ts +9 -0
- package/dist/index.js +11 -0
- package/dist/ingestion.d.ts +16 -0
- package/dist/ingestion.js +21 -0
- package/dist/mcp-server.d.ts +35 -3
- package/dist/mcp-server.js +1107 -31
- package/dist/multimodal/clip-embedder.d.ts +314 -0
- package/dist/multimodal/clip-embedder.js +945 -0
- package/dist/multimodal/index.d.ts +6 -0
- package/dist/multimodal/index.js +6 -0
- package/dist/run-error-recovery-tests.d.ts +7 -0
- package/dist/run-error-recovery-tests.js +101 -0
- package/dist/search.d.ts +26 -0
- package/dist/search.js +54 -1
- package/dist/test-utils.d.ts +8 -26
- package/dist/text/chunker.d.ts +1 -0
- package/dist/text/embedder.js +15 -8
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.js +1 -0
- package/dist/text/reranker.d.ts +1 -2
- package/dist/text/reranker.js +17 -47
- package/dist/text/sentence-transformer-embedder.d.ts +96 -0
- package/dist/text/sentence-transformer-embedder.js +340 -0
- package/dist/types.d.ts +39 -0
- package/dist/utils/vector-math.d.ts +31 -0
- package/dist/utils/vector-math.js +70 -0
- package/package.json +15 -3
- package/dist/api-errors.d.ts.map +0 -1
- package/dist/api-errors.js.map +0 -1
- package/dist/cli/indexer.d.ts.map +0 -1
- package/dist/cli/indexer.js.map +0 -1
- package/dist/cli/search.d.ts.map +0 -1
- package/dist/cli/search.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/core/adapters.d.ts.map +0 -1
- package/dist/core/adapters.js.map +0 -1
- package/dist/core/chunker.d.ts.map +0 -1
- package/dist/core/chunker.js.map +0 -1
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js.map +0 -1
- package/dist/core/db.d.ts.map +0 -1
- package/dist/core/db.js.map +0 -1
- package/dist/core/error-handler.d.ts.map +0 -1
- package/dist/core/error-handler.js.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/ingestion.d.ts.map +0 -1
- package/dist/core/ingestion.js.map +0 -1
- package/dist/core/interfaces.d.ts.map +0 -1
- package/dist/core/interfaces.js.map +0 -1
- package/dist/core/path-manager.d.ts.map +0 -1
- package/dist/core/path-manager.js.map +0 -1
- package/dist/core/search-example.d.ts +0 -25
- package/dist/core/search-example.d.ts.map +0 -1
- package/dist/core/search-example.js +0 -138
- package/dist/core/search-example.js.map +0 -1
- package/dist/core/search-pipeline-example.d.ts +0 -21
- package/dist/core/search-pipeline-example.d.ts.map +0 -1
- package/dist/core/search-pipeline-example.js +0 -188
- package/dist/core/search-pipeline-example.js.map +0 -1
- package/dist/core/search-pipeline.d.ts.map +0 -1
- package/dist/core/search-pipeline.js.map +0 -1
- package/dist/core/search.d.ts.map +0 -1
- package/dist/core/search.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/vector-index.d.ts.map +0 -1
- package/dist/core/vector-index.js.map +0 -1
- package/dist/dom-polyfills.d.ts.map +0 -1
- package/dist/dom-polyfills.js.map +0 -1
- package/dist/examples/clean-api-examples.d.ts +0 -44
- package/dist/examples/clean-api-examples.d.ts.map +0 -1
- package/dist/examples/clean-api-examples.js +0 -206
- package/dist/examples/clean-api-examples.js.map +0 -1
- package/dist/factories/index.d.ts.map +0 -1
- package/dist/factories/index.js.map +0 -1
- package/dist/factories/text-factory.d.ts.map +0 -1
- package/dist/factories/text-factory.js.map +0 -1
- package/dist/file-processor.d.ts.map +0 -1
- package/dist/file-processor.js.map +0 -1
- package/dist/index-manager.d.ts.map +0 -1
- package/dist/index-manager.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/indexer.d.ts.map +0 -1
- package/dist/indexer.js.map +0 -1
- package/dist/ingestion.d.ts.map +0 -1
- package/dist/ingestion.js.map +0 -1
- package/dist/mcp-server.d.ts.map +0 -1
- package/dist/mcp-server.js.map +0 -1
- package/dist/preprocess.d.ts.map +0 -1
- package/dist/preprocess.js.map +0 -1
- package/dist/preprocessors/index.d.ts.map +0 -1
- package/dist/preprocessors/index.js.map +0 -1
- package/dist/preprocessors/mdx.d.ts.map +0 -1
- package/dist/preprocessors/mdx.js.map +0 -1
- package/dist/preprocessors/mermaid.d.ts.map +0 -1
- package/dist/preprocessors/mermaid.js.map +0 -1
- package/dist/preprocessors/registry.d.ts.map +0 -1
- package/dist/preprocessors/registry.js.map +0 -1
- package/dist/search-standalone.d.ts.map +0 -1
- package/dist/search-standalone.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/test-utils.d.ts.map +0 -1
- package/dist/test-utils.js.map +0 -1
- package/dist/text/chunker.d.ts.map +0 -1
- package/dist/text/chunker.js.map +0 -1
- package/dist/text/embedder.d.ts.map +0 -1
- package/dist/text/embedder.js.map +0 -1
- package/dist/text/index.d.ts.map +0 -1
- package/dist/text/index.js.map +0 -1
- package/dist/text/preprocessors/index.d.ts.map +0 -1
- package/dist/text/preprocessors/index.js.map +0 -1
- package/dist/text/preprocessors/mdx.d.ts.map +0 -1
- package/dist/text/preprocessors/mdx.js.map +0 -1
- package/dist/text/preprocessors/mermaid.d.ts.map +0 -1
- package/dist/text/preprocessors/mermaid.js.map +0 -1
- package/dist/text/preprocessors/registry.d.ts.map +0 -1
- package/dist/text/preprocessors/registry.js.map +0 -1
- package/dist/text/reranker.d.ts.map +0 -1
- package/dist/text/reranker.js.map +0 -1
- package/dist/text/tokenizer.d.ts.map +0 -1
- package/dist/text/tokenizer.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface EmbeddingResult {
|
|
|
19
19
|
embedding_id: string;
|
|
20
20
|
vector: Float32Array;
|
|
21
21
|
contentType?: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
22
23
|
}
|
|
23
24
|
export type EmbedFunction = (query: string, contentType?: string) => Promise<EmbeddingResult>;
|
|
24
25
|
export interface SearchResult {
|
|
@@ -30,6 +31,7 @@ export interface SearchResult {
|
|
|
30
31
|
source: string;
|
|
31
32
|
title: string;
|
|
32
33
|
contentType: string;
|
|
34
|
+
contentId?: string;
|
|
33
35
|
};
|
|
34
36
|
metadata?: Record<string, any>;
|
|
35
37
|
}
|
|
@@ -57,6 +59,7 @@ export interface Document {
|
|
|
57
59
|
source: string;
|
|
58
60
|
title: string;
|
|
59
61
|
content: string;
|
|
62
|
+
metadata?: Record<string, any>;
|
|
60
63
|
}
|
|
61
64
|
export type { DatabaseConnection } from './db.js';
|
|
62
65
|
export type { ContentChunk as ChunkResult } from './db.js';
|
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
import type { EmbeddingResult } from '../types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Universal embedder interface supporting both text and multimodal models
|
|
26
|
+
* Provides a consistent API across different model types and content types
|
|
27
|
+
*/
|
|
28
|
+
export interface UniversalEmbedder {
|
|
29
|
+
readonly modelName: string;
|
|
30
|
+
readonly modelType: ModelType;
|
|
31
|
+
readonly dimensions: number;
|
|
32
|
+
readonly supportedContentTypes: readonly string[];
|
|
33
|
+
embedText(text: string): Promise<EmbeddingResult>;
|
|
34
|
+
embedImage?(imagePath: string): Promise<EmbeddingResult>;
|
|
35
|
+
embedBatch(items: EmbeddingBatchItem[]): Promise<EmbeddingResult[]>;
|
|
36
|
+
loadModel(): Promise<void>;
|
|
37
|
+
isLoaded(): boolean;
|
|
38
|
+
getModelInfo(): ModelInfo;
|
|
39
|
+
cleanup(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Enhanced embedding result with content type and metadata support
|
|
43
|
+
* Extends the existing EmbeddingResult interface for multimodal compatibility
|
|
44
|
+
*/
|
|
45
|
+
export interface EnhancedEmbeddingResult extends EmbeddingResult {
|
|
46
|
+
contentType: string;
|
|
47
|
+
metadata?: Record<string, any>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Batch embedding item for efficient processing
|
|
51
|
+
*/
|
|
52
|
+
export interface EmbeddingBatchItem {
|
|
53
|
+
content: string;
|
|
54
|
+
contentType: string;
|
|
55
|
+
metadata?: Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Model information interface for runtime introspection
|
|
59
|
+
*/
|
|
60
|
+
export interface ModelInfo {
|
|
61
|
+
name: string;
|
|
62
|
+
type: ModelType;
|
|
63
|
+
dimensions: number;
|
|
64
|
+
version: string;
|
|
65
|
+
supportedContentTypes: readonly string[];
|
|
66
|
+
capabilities: ModelCapabilities;
|
|
67
|
+
requirements: ModelRequirements;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Model capabilities for feature detection
|
|
71
|
+
*/
|
|
72
|
+
export interface ModelCapabilities {
|
|
73
|
+
supportsText: boolean;
|
|
74
|
+
supportsImages: boolean;
|
|
75
|
+
supportsBatchProcessing: boolean;
|
|
76
|
+
supportsMetadata: boolean;
|
|
77
|
+
maxBatchSize?: number;
|
|
78
|
+
maxTextLength?: number;
|
|
79
|
+
supportedImageFormats?: readonly string[];
|
|
80
|
+
supportsMultimodal?: boolean;
|
|
81
|
+
supportsCrossModalSearch?: boolean;
|
|
82
|
+
unifiedEmbeddingSpace?: boolean;
|
|
83
|
+
reliableImplementation?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Model requirements for validation and compatibility checking
|
|
87
|
+
*/
|
|
88
|
+
export interface ModelRequirements {
|
|
89
|
+
transformersJsVersion: string;
|
|
90
|
+
minimumMemory?: number;
|
|
91
|
+
requiredFeatures?: readonly string[];
|
|
92
|
+
platformSupport?: readonly string[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Supported model types in the Chameleon architecture
|
|
96
|
+
*/
|
|
97
|
+
export type ModelType = 'sentence-transformer' | 'clip';
|
|
98
|
+
/**
|
|
99
|
+
* Content types supported by the system
|
|
100
|
+
*/
|
|
101
|
+
export type ContentType = 'text' | 'image' | 'pdf' | 'docx';
|
|
102
|
+
/**
|
|
103
|
+
* Model validation result for compatibility checking
|
|
104
|
+
*/
|
|
105
|
+
export interface ModelValidationResult {
|
|
106
|
+
isValid: boolean;
|
|
107
|
+
errors: string[];
|
|
108
|
+
warnings: string[];
|
|
109
|
+
suggestions: string[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Simple embedder creation function type
|
|
113
|
+
* Replaces complex factory patterns with a straightforward function approach
|
|
114
|
+
*/
|
|
115
|
+
export type CreateEmbedderFunction = (modelName: string, options?: EmbedderCreationOptions) => Promise<UniversalEmbedder>;
|
|
116
|
+
/**
|
|
117
|
+
* Options for creating embedder instances
|
|
118
|
+
*/
|
|
119
|
+
export interface EmbedderCreationOptions {
|
|
120
|
+
cachePath?: string;
|
|
121
|
+
maxBatchSize?: number;
|
|
122
|
+
timeout?: number;
|
|
123
|
+
enableGPU?: boolean;
|
|
124
|
+
customConfig?: Record<string, any>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Model validation error for unsupported or incompatible models
|
|
128
|
+
*/
|
|
129
|
+
export declare class ModelValidationError extends Error {
|
|
130
|
+
readonly modelName: string;
|
|
131
|
+
readonly availableModels: readonly string[];
|
|
132
|
+
constructor(modelName: string, availableModels: readonly string[], message: string);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Transformers.js compatibility error for version mismatches
|
|
136
|
+
*/
|
|
137
|
+
export declare class TransformersCompatibilityError extends Error {
|
|
138
|
+
readonly modelName: string;
|
|
139
|
+
readonly requiredVersion: string;
|
|
140
|
+
readonly currentVersion: string;
|
|
141
|
+
constructor(modelName: string, requiredVersion: string, currentVersion: string, message: string);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Content type error for unsupported content types
|
|
145
|
+
*/
|
|
146
|
+
export declare class ContentTypeError extends Error {
|
|
147
|
+
readonly contentType: string;
|
|
148
|
+
readonly supportedTypes: readonly string[];
|
|
149
|
+
constructor(contentType: string, supportedTypes: readonly string[], message: string);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Type guard for checking if an embedder supports images
|
|
153
|
+
*/
|
|
154
|
+
export declare function supportsImages(embedder: UniversalEmbedder): embedder is UniversalEmbedder & {
|
|
155
|
+
embedImage(imagePath: string): Promise<EmbeddingResult>;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Type guard for checking if an embedder supports a specific content type
|
|
159
|
+
*/
|
|
160
|
+
export declare function supportsContentType(embedder: UniversalEmbedder, contentType: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Utility function to create enhanced embedding results
|
|
163
|
+
*/
|
|
164
|
+
export declare function createEnhancedEmbeddingResult(embeddingId: string, vector: Float32Array, contentType: string, metadata?: Record<string, any>): EnhancedEmbeddingResult;
|
|
165
|
+
/**
|
|
166
|
+
* Utility function to validate content type against supported types
|
|
167
|
+
*/
|
|
168
|
+
export declare function validateContentType(contentType: string, supportedTypes: readonly string[]): void;
|
|
169
|
+
/**
|
|
170
|
+
* Default supported content types for different model types
|
|
171
|
+
*/
|
|
172
|
+
export declare const DEFAULT_CONTENT_TYPES: Record<ModelType, readonly string[]>;
|
|
173
|
+
/**
|
|
174
|
+
* Default model capabilities for different model types
|
|
175
|
+
*/
|
|
176
|
+
export declare const DEFAULT_CAPABILITIES: Record<ModelType, ModelCapabilities>;
|
|
177
|
+
//# sourceMappingURL=universal-embedder.d.ts.map
|
|
@@ -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
|