modality-kit 0.5.8 → 0.6.1
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export interface CompressionConfig {
|
|
2
|
+
maxTokens: number;
|
|
3
|
+
compressionLevel: 'light' | 'moderate' | 'aggressive';
|
|
4
|
+
preserveCodeBlocks: boolean;
|
|
5
|
+
autoDetectLanguage: boolean;
|
|
6
|
+
enableLogging: boolean;
|
|
7
|
+
maxSentencesForAnalysis: number;
|
|
8
|
+
fastModeMaxSentences: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_CONFIG: CompressionConfig;
|
|
11
|
+
export interface CompressionOptions {
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
compressionLevel?: 'light' | 'moderate' | 'aggressive';
|
|
14
|
+
preserveCodeBlocks?: boolean;
|
|
15
|
+
autoDetectLanguage?: boolean;
|
|
16
|
+
locale?: string;
|
|
17
|
+
prioritizeFirst?: boolean;
|
|
18
|
+
prioritizeLast?: boolean;
|
|
19
|
+
preserveStructure?: boolean;
|
|
20
|
+
bufferPercentage?: number;
|
|
21
|
+
maxSentences?: number;
|
|
22
|
+
fastMode?: boolean;
|
|
23
|
+
enableLogging?: boolean;
|
|
24
|
+
sentenceSplitPattern?: RegExp;
|
|
25
|
+
importanceWeights?: ImportanceWeights;
|
|
26
|
+
tokenizationMethod?: 'simple' | 'advanced';
|
|
27
|
+
}
|
|
28
|
+
export interface ImportanceWeights {
|
|
29
|
+
position: number;
|
|
30
|
+
length: number;
|
|
31
|
+
wordRarity: number;
|
|
32
|
+
codeElements: number;
|
|
33
|
+
}
|
|
34
|
+
export interface CompressionResult {
|
|
35
|
+
compressedText: string;
|
|
36
|
+
originalLength: number;
|
|
37
|
+
compressedLength: number;
|
|
38
|
+
compressionRatio: number;
|
|
39
|
+
tokensEstimate: number;
|
|
40
|
+
detectedLanguage?: string;
|
|
41
|
+
importanceScores?: Array<{
|
|
42
|
+
text: string;
|
|
43
|
+
score: number;
|
|
44
|
+
reasons: string[];
|
|
45
|
+
}>;
|
|
46
|
+
processingTime?: number;
|
|
47
|
+
errors?: string[];
|
|
48
|
+
warnings?: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface LanguageDetectionResult {
|
|
51
|
+
code: string;
|
|
52
|
+
locale: string;
|
|
53
|
+
confidence: number;
|
|
54
|
+
script?: string;
|
|
55
|
+
region?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare class CompressionError extends Error {
|
|
58
|
+
code: string;
|
|
59
|
+
details?: any | undefined;
|
|
60
|
+
constructor(message: string, code: string, details?: any | undefined);
|
|
61
|
+
}
|
|
62
|
+
export declare class LanguageDetectionError extends Error {
|
|
63
|
+
fallbackLanguage: string;
|
|
64
|
+
constructor(message: string, fallbackLanguage: string);
|
|
65
|
+
}
|
|
66
|
+
export declare class CompressionLogger {
|
|
67
|
+
private enabled;
|
|
68
|
+
constructor(enabled?: boolean);
|
|
69
|
+
info(message: string, data?: any): void;
|
|
70
|
+
warn(message: string, data?: any): void;
|
|
71
|
+
error(message: string, error?: Error): void;
|
|
72
|
+
}
|
|
73
|
+
export declare class UniversalLanguageDetector {
|
|
74
|
+
private logger;
|
|
75
|
+
private cache;
|
|
76
|
+
constructor(logger: CompressionLogger);
|
|
77
|
+
detectLanguage(text: string): Promise<LanguageDetectionResult>;
|
|
78
|
+
private performDetection;
|
|
79
|
+
private analyzeUnicodeRanges;
|
|
80
|
+
private prioritizeLocalesBasedOnUnicode;
|
|
81
|
+
private getAvailableTestLocales;
|
|
82
|
+
private getUnicodeRelevanceScore;
|
|
83
|
+
private getUnicodeBoost;
|
|
84
|
+
private testLocaleWithIntlAPIs;
|
|
85
|
+
private enhanceWithTextAnalysis;
|
|
86
|
+
private detectFromTextHeuristics;
|
|
87
|
+
}
|
|
88
|
+
export declare class IntelligentImportanceAnalyzer {
|
|
89
|
+
private wordFrequencyCache;
|
|
90
|
+
private logger;
|
|
91
|
+
private config;
|
|
92
|
+
constructor(logger: CompressionLogger, config: CompressionConfig);
|
|
93
|
+
analyzeImportance(text: string, detectedLanguage?: string): Promise<Array<{
|
|
94
|
+
text: string;
|
|
95
|
+
score: number;
|
|
96
|
+
reasons: string[];
|
|
97
|
+
}>>;
|
|
98
|
+
fastAnalyzeImportance(text: string, detectedLanguage?: string): Promise<Array<{
|
|
99
|
+
text: string;
|
|
100
|
+
score: number;
|
|
101
|
+
reasons: string[];
|
|
102
|
+
}>>;
|
|
103
|
+
private segmentSentences;
|
|
104
|
+
private analyzePosition;
|
|
105
|
+
private analyzeLengthDeviation;
|
|
106
|
+
private analyzeWordRarity;
|
|
107
|
+
private calculateWordFrequencies;
|
|
108
|
+
}
|
|
109
|
+
export declare class TextCompressionUtility {
|
|
110
|
+
private languageDetector;
|
|
111
|
+
private importanceAnalyzer;
|
|
112
|
+
private logger;
|
|
113
|
+
private config;
|
|
114
|
+
constructor(config?: Partial<CompressionConfig>);
|
|
115
|
+
compress(text: string, options?: CompressionOptions): Promise<CompressionResult>;
|
|
116
|
+
private extractCodeElements;
|
|
117
|
+
private applyUserPriorities;
|
|
118
|
+
private applyCompression;
|
|
119
|
+
private getCompressionThreshold;
|
|
120
|
+
private segmentSentences;
|
|
121
|
+
private trimToTokenLimit;
|
|
122
|
+
private estimateTokens;
|
|
123
|
+
}
|
|
124
|
+
export declare function compressUserInput(text: string, maxTokens?: number): Promise<string>;
|
|
125
|
+
export declare function compressConversationHistory(messages: Array<{
|
|
126
|
+
role: string;
|
|
127
|
+
content: string;
|
|
128
|
+
}>, maxTokens: number): Promise<Array<{
|
|
129
|
+
role: string;
|
|
130
|
+
content: string;
|
|
131
|
+
}>>;
|
|
132
|
+
export declare function analyzeTextImportance(text: string): Promise<Array<{
|
|
133
|
+
text: string;
|
|
134
|
+
score: number;
|
|
135
|
+
reasons: string[];
|
|
136
|
+
}>>;
|
|
137
|
+
export declare function compressText(text: string, options?: CompressionOptions): Promise<CompressionResult>;
|
|
138
|
+
export declare function fastCompressText(text: string, maxTokens?: number): Promise<string>;
|
|
139
|
+
export declare function compressWithLanguageDetection(text: string, maxTokens?: number): Promise<CompressionResult>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.1",
|
|
3
3
|
"name": "modality-kit",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "Hill <hill@kimo.com>",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/
|
|
16
|
+
"@types/bun": "^1.2.19",
|
|
17
17
|
"fastmcp": "^3.12.0",
|
|
18
18
|
"typescript": "^5.8.3",
|
|
19
19
|
"zod": "3.x"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build:types": "bunx tsc -p ./",
|
|
32
32
|
"build:src": "bun build src/index.ts --outdir dist",
|
|
33
33
|
"build": "bun run build:clean && bun run build:src && bun run build:types",
|
|
34
|
-
"test": "
|
|
34
|
+
"test": "bun test",
|
|
35
35
|
"prepublishOnly": "npm run test"
|
|
36
36
|
},
|
|
37
37
|
"types": "./dist/types/index.d.ts",
|