ai.matey.utils 0.2.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/LICENSE +21 -0
- package/dist/cjs/conversation-history.js +139 -0
- package/dist/cjs/conversation-history.js.map +1 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/model-cache.js +163 -0
- package/dist/cjs/model-cache.js.map +1 -0
- package/dist/cjs/parameter-normalizer.js +451 -0
- package/dist/cjs/parameter-normalizer.js.map +1 -0
- package/dist/cjs/streaming-modes.js +277 -0
- package/dist/cjs/streaming-modes.js.map +1 -0
- package/dist/cjs/streaming.js +892 -0
- package/dist/cjs/streaming.js.map +1 -0
- package/dist/cjs/structured-output.js +398 -0
- package/dist/cjs/structured-output.js.map +1 -0
- package/dist/cjs/system-message.js +222 -0
- package/dist/cjs/system-message.js.map +1 -0
- package/dist/cjs/validation.js +534 -0
- package/dist/cjs/validation.js.map +1 -0
- package/dist/cjs/warnings.js +301 -0
- package/dist/cjs/warnings.js.map +1 -0
- package/dist/esm/conversation-history.js +134 -0
- package/dist/esm/conversation-history.js.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/model-cache.js +158 -0
- package/dist/esm/model-cache.js.map +1 -0
- package/dist/esm/parameter-normalizer.js +434 -0
- package/dist/esm/parameter-normalizer.js.map +1 -0
- package/dist/esm/streaming-modes.js +265 -0
- package/dist/esm/streaming-modes.js.map +1 -0
- package/dist/esm/streaming.js +860 -0
- package/dist/esm/streaming.js.map +1 -0
- package/dist/esm/structured-output.js +387 -0
- package/dist/esm/structured-output.js.map +1 -0
- package/dist/esm/system-message.js +213 -0
- package/dist/esm/system-message.js.map +1 -0
- package/dist/esm/validation.js +523 -0
- package/dist/esm/validation.js.map +1 -0
- package/dist/esm/warnings.js +284 -0
- package/dist/esm/warnings.js.map +1 -0
- package/dist/types/conversation-history.d.ts +70 -0
- package/dist/types/conversation-history.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/model-cache.d.ts +88 -0
- package/dist/types/model-cache.d.ts.map +1 -0
- package/dist/types/parameter-normalizer.d.ts +154 -0
- package/dist/types/parameter-normalizer.d.ts.map +1 -0
- package/dist/types/streaming-modes.d.ts +139 -0
- package/dist/types/streaming-modes.d.ts.map +1 -0
- package/dist/types/streaming.d.ts +384 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/structured-output.d.ts +157 -0
- package/dist/types/structured-output.d.ts.map +1 -0
- package/dist/types/system-message.d.ts +78 -0
- package/dist/types/system-message.d.ts.map +1 -0
- package/dist/types/validation.d.ts +46 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/dist/types/warnings.d.ts +149 -0
- package/dist/types/warnings.d.ts.map +1 -0
- package/package.json +75 -0
- package/readme.md +280 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warning Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for creating, formatting, and managing semantic drift warnings.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Warning Creation
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Create a warning object.
|
|
13
|
+
*
|
|
14
|
+
* @param category Warning category
|
|
15
|
+
* @param message Human-readable message
|
|
16
|
+
* @param options Additional warning options
|
|
17
|
+
* @returns Warning object
|
|
18
|
+
*/
|
|
19
|
+
export function createWarning(category, message, options = {}) {
|
|
20
|
+
return {
|
|
21
|
+
category,
|
|
22
|
+
severity: options.severity ?? 'warning',
|
|
23
|
+
message,
|
|
24
|
+
field: options.field,
|
|
25
|
+
originalValue: options.originalValue,
|
|
26
|
+
transformedValue: options.transformedValue,
|
|
27
|
+
source: options.source,
|
|
28
|
+
details: options.details,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a parameter normalization warning.
|
|
33
|
+
*
|
|
34
|
+
* @param field Parameter field name
|
|
35
|
+
* @param originalValue Original value
|
|
36
|
+
* @param transformedValue Transformed value
|
|
37
|
+
* @param message Optional custom message
|
|
38
|
+
* @param source Source adapter
|
|
39
|
+
* @returns Warning object
|
|
40
|
+
*/
|
|
41
|
+
export function createNormalizationWarning(field, originalValue, transformedValue, message, source) {
|
|
42
|
+
return createWarning('parameter-normalized', message ||
|
|
43
|
+
`Parameter '${field}' normalized from ${String(originalValue)} to ${String(transformedValue)}`, {
|
|
44
|
+
severity: 'info',
|
|
45
|
+
field,
|
|
46
|
+
originalValue,
|
|
47
|
+
transformedValue,
|
|
48
|
+
source,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a parameter clamping warning.
|
|
53
|
+
*
|
|
54
|
+
* @param field Parameter field name
|
|
55
|
+
* @param originalValue Original value
|
|
56
|
+
* @param clampedValue Clamped value
|
|
57
|
+
* @param min Minimum allowed value
|
|
58
|
+
* @param max Maximum allowed value
|
|
59
|
+
* @param source Source adapter
|
|
60
|
+
* @returns Warning object
|
|
61
|
+
*/
|
|
62
|
+
export function createClampingWarning(field, originalValue, clampedValue, min, max, source) {
|
|
63
|
+
return createWarning('parameter-clamped', `Parameter '${field}' clamped from ${String(originalValue)} to ${String(clampedValue)} (valid range: ${min}-${max})`, {
|
|
64
|
+
severity: 'warning',
|
|
65
|
+
field,
|
|
66
|
+
originalValue,
|
|
67
|
+
transformedValue: clampedValue,
|
|
68
|
+
source,
|
|
69
|
+
details: { min, max },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create an unsupported parameter warning.
|
|
74
|
+
*
|
|
75
|
+
* @param field Parameter field name
|
|
76
|
+
* @param value Parameter value
|
|
77
|
+
* @param source Source adapter
|
|
78
|
+
* @returns Warning object
|
|
79
|
+
*/
|
|
80
|
+
export function createUnsupportedParameterWarning(field, value, source) {
|
|
81
|
+
return createWarning('parameter-unsupported', `Parameter '${field}' is not supported by provider (value: ${String(value)})`, {
|
|
82
|
+
severity: 'warning',
|
|
83
|
+
field,
|
|
84
|
+
originalValue: value,
|
|
85
|
+
source,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a capability unsupported warning.
|
|
90
|
+
*
|
|
91
|
+
* @param capability Capability name
|
|
92
|
+
* @param source Source adapter
|
|
93
|
+
* @returns Warning object
|
|
94
|
+
*/
|
|
95
|
+
export function createUnsupportedCapabilityWarning(capability, source) {
|
|
96
|
+
return createWarning('capability-unsupported', `Capability '${capability}' is not supported by provider`, {
|
|
97
|
+
severity: 'warning',
|
|
98
|
+
field: capability,
|
|
99
|
+
source,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a token limit exceeded warning.
|
|
104
|
+
*
|
|
105
|
+
* @param estimatedTokens Estimated token count
|
|
106
|
+
* @param maxTokens Maximum tokens allowed
|
|
107
|
+
* @param source Source adapter
|
|
108
|
+
* @returns Warning object
|
|
109
|
+
*/
|
|
110
|
+
export function createTokenLimitWarning(estimatedTokens, maxTokens, source) {
|
|
111
|
+
return createWarning('token-limit-exceeded', `Estimated tokens (${estimatedTokens}) may exceed provider limit (${maxTokens})`, {
|
|
112
|
+
severity: 'warning',
|
|
113
|
+
source,
|
|
114
|
+
details: { estimatedTokens, maxTokens },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a stop sequences truncated warning.
|
|
119
|
+
*
|
|
120
|
+
* @param originalCount Original number of stop sequences
|
|
121
|
+
* @param maxCount Maximum allowed
|
|
122
|
+
* @param source Source adapter
|
|
123
|
+
* @returns Warning object
|
|
124
|
+
*/
|
|
125
|
+
export function createStopSequencesTruncatedWarning(originalCount, maxCount, source) {
|
|
126
|
+
return createWarning('stop-sequences-truncated', `Stop sequences truncated from ${originalCount} to ${maxCount} (provider limit)`, {
|
|
127
|
+
severity: 'warning',
|
|
128
|
+
field: 'stopSequences',
|
|
129
|
+
originalValue: originalCount,
|
|
130
|
+
transformedValue: maxCount,
|
|
131
|
+
source,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Warning Manipulation
|
|
136
|
+
// ============================================================================
|
|
137
|
+
/**
|
|
138
|
+
* Merge warning arrays, removing duplicates.
|
|
139
|
+
*
|
|
140
|
+
* @param warningArrays Arrays of warnings to merge
|
|
141
|
+
* @returns Merged and deduplicated warnings
|
|
142
|
+
*/
|
|
143
|
+
export function mergeWarnings(...warningArrays) {
|
|
144
|
+
const warnings = [];
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
for (const array of warningArrays) {
|
|
147
|
+
if (!array) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
for (const warning of array) {
|
|
151
|
+
// Create a key for deduplication
|
|
152
|
+
const key = `${warning.category}:${warning.field}:${warning.message}`;
|
|
153
|
+
if (!seen.has(key)) {
|
|
154
|
+
seen.add(key);
|
|
155
|
+
warnings.push(warning);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return warnings;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Filter warnings by severity.
|
|
163
|
+
*
|
|
164
|
+
* @param warnings Warnings to filter
|
|
165
|
+
* @param minSeverity Minimum severity level
|
|
166
|
+
* @returns Filtered warnings
|
|
167
|
+
*/
|
|
168
|
+
export function filterWarningsBySeverity(warnings, minSeverity) {
|
|
169
|
+
const severityOrder = {
|
|
170
|
+
info: 0,
|
|
171
|
+
warning: 1,
|
|
172
|
+
error: 2,
|
|
173
|
+
};
|
|
174
|
+
const minLevel = severityOrder[minSeverity];
|
|
175
|
+
return warnings.filter((w) => severityOrder[w.severity] >= minLevel);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Filter warnings by category.
|
|
179
|
+
*
|
|
180
|
+
* @param warnings Warnings to filter
|
|
181
|
+
* @param categories Categories to include
|
|
182
|
+
* @returns Filtered warnings
|
|
183
|
+
*/
|
|
184
|
+
export function filterWarningsByCategory(warnings, categories) {
|
|
185
|
+
const categorySet = new Set(categories);
|
|
186
|
+
return warnings.filter((w) => categorySet.has(w.category));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Group warnings by category.
|
|
190
|
+
*
|
|
191
|
+
* @param warnings Warnings to group
|
|
192
|
+
* @returns Map of category to warnings
|
|
193
|
+
*/
|
|
194
|
+
export function groupWarningsByCategory(warnings) {
|
|
195
|
+
const groups = new Map();
|
|
196
|
+
for (const warning of warnings) {
|
|
197
|
+
const group = groups.get(warning.category) || [];
|
|
198
|
+
group.push(warning);
|
|
199
|
+
groups.set(warning.category, group);
|
|
200
|
+
}
|
|
201
|
+
return groups;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Check if warnings array contains a specific warning type.
|
|
205
|
+
*
|
|
206
|
+
* @param warnings Warnings to check
|
|
207
|
+
* @param category Warning category to look for
|
|
208
|
+
* @param field Optional field name to match
|
|
209
|
+
* @returns true if warning exists
|
|
210
|
+
*/
|
|
211
|
+
export function hasWarning(warnings, category, field) {
|
|
212
|
+
if (!warnings) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return warnings.some((w) => w.category === category && (field === undefined || w.field === field));
|
|
216
|
+
}
|
|
217
|
+
// ============================================================================
|
|
218
|
+
// Warning Formatting
|
|
219
|
+
// ============================================================================
|
|
220
|
+
/**
|
|
221
|
+
* Format a single warning as a string.
|
|
222
|
+
*
|
|
223
|
+
* @param warning Warning to format
|
|
224
|
+
* @param includeDetails Include full details
|
|
225
|
+
* @returns Formatted warning string
|
|
226
|
+
*/
|
|
227
|
+
export function formatWarning(warning, includeDetails = false) {
|
|
228
|
+
const prefix = `[${warning.severity.toUpperCase()}]`;
|
|
229
|
+
const source = warning.source ? ` (${warning.source})` : '';
|
|
230
|
+
if (!includeDetails) {
|
|
231
|
+
return `${prefix} ${warning.message}${source}`;
|
|
232
|
+
}
|
|
233
|
+
const parts = [
|
|
234
|
+
`${prefix} ${warning.message}${source}`,
|
|
235
|
+
warning.field ? ` Field: ${warning.field}` : null,
|
|
236
|
+
warning.originalValue !== undefined
|
|
237
|
+
? ` Original: ${JSON.stringify(warning.originalValue)}`
|
|
238
|
+
: null,
|
|
239
|
+
warning.transformedValue !== undefined
|
|
240
|
+
? ` Transformed: ${JSON.stringify(warning.transformedValue)}`
|
|
241
|
+
: null,
|
|
242
|
+
warning.details ? ` Details: ${JSON.stringify(warning.details)}` : null,
|
|
243
|
+
].filter(Boolean);
|
|
244
|
+
return parts.join('\n');
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Format multiple warnings as a string.
|
|
248
|
+
*
|
|
249
|
+
* @param warnings Warnings to format
|
|
250
|
+
* @param includeDetails Include full details
|
|
251
|
+
* @returns Formatted warnings string
|
|
252
|
+
*/
|
|
253
|
+
export function formatWarnings(warnings, includeDetails = false) {
|
|
254
|
+
if (warnings.length === 0) {
|
|
255
|
+
return 'No warnings';
|
|
256
|
+
}
|
|
257
|
+
const formatted = warnings.map((w) => formatWarning(w, includeDetails));
|
|
258
|
+
return formatted.join('\n');
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get a summary of warnings by category.
|
|
262
|
+
*
|
|
263
|
+
* @param warnings Warnings to summarize
|
|
264
|
+
* @returns Summary object with counts
|
|
265
|
+
*/
|
|
266
|
+
export function getWarningSummary(warnings) {
|
|
267
|
+
const summary = {
|
|
268
|
+
total: warnings.length,
|
|
269
|
+
byCategory: {},
|
|
270
|
+
bySeverity: {
|
|
271
|
+
info: 0,
|
|
272
|
+
warning: 0,
|
|
273
|
+
error: 0,
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
for (const warning of warnings) {
|
|
277
|
+
// Count by category
|
|
278
|
+
summary.byCategory[warning.category] = (summary.byCategory[warning.category] || 0) + 1;
|
|
279
|
+
// Count by severity
|
|
280
|
+
summary.bySeverity[warning.severity]++;
|
|
281
|
+
}
|
|
282
|
+
return summary;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=warnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../../src/warnings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAyB,EACzB,OAAe,EACf,UAOI,EAAE;IAEN,OAAO;QACL,QAAQ;QACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;QACvC,OAAO;QACP,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa,EACb,aAAsB,EACtB,gBAAyB,EACzB,OAAgB,EAChB,MAAe;IAEf,OAAO,aAAa,CAClB,sBAAsB,EACtB,OAAO;QACL,cAAc,KAAK,qBAAqB,MAAM,CAAC,aAAa,CAAC,OAAO,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAChG;QACE,QAAQ,EAAE,MAAM;QAChB,KAAK;QACL,aAAa;QACb,gBAAgB;QAChB,MAAM;KACP,CACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAa,EACb,aAAsB,EACtB,YAAqB,EACrB,GAAW,EACX,GAAW,EACX,MAAe;IAEf,OAAO,aAAa,CAClB,mBAAmB,EACnB,cAAc,KAAK,kBAAkB,MAAM,CAAC,aA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B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA8B;IAK9D,MAAM,OAAO,GAAG;QACd,KAAK,EAAE,QAAQ,CAAC,MAAM;QACtB,UAAU,EAAE,EAAqC;QACjD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,CAAC;SAC0B;KACrC,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,oBAAoB;QACpB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAEvF,oBAAoB;QACpB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation History Management Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities for managing conversation history with configurable trimming strategies.
|
|
5
|
+
* Used by both middleware and wrappers for consistent history management.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { IRMessage } from 'ai.matey.types';
|
|
10
|
+
/**
|
|
11
|
+
* Strategy for trimming conversation history
|
|
12
|
+
*/
|
|
13
|
+
export type TrimStrategy = 'fifo' | 'smart';
|
|
14
|
+
/**
|
|
15
|
+
* Trim conversation history to keep only the most recent messages.
|
|
16
|
+
*
|
|
17
|
+
* @param history - Current conversation history
|
|
18
|
+
* @param maxHistorySize - Maximum number of message pairs to keep
|
|
19
|
+
* - 0: Return empty array (no history)
|
|
20
|
+
* - -1: Return full history (no trimming)
|
|
21
|
+
* - N > 0: Keep last N user/assistant pairs
|
|
22
|
+
* @param strategy - Trimming strategy
|
|
23
|
+
* - 'fifo': First-in-first-out, remove oldest messages
|
|
24
|
+
* - 'smart': Preserve system messages, trim user/assistant pairs
|
|
25
|
+
* @returns Trimmed history
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const history = [
|
|
30
|
+
* { role: 'system', content: 'You are helpful' },
|
|
31
|
+
* { role: 'user', content: 'Hi' },
|
|
32
|
+
* { role: 'assistant', content: 'Hello!' },
|
|
33
|
+
* { role: 'user', content: 'How are you?' },
|
|
34
|
+
* { role: 'assistant', content: 'I am well!' },
|
|
35
|
+
* ];
|
|
36
|
+
*
|
|
37
|
+
* // Keep last 1 pair + system message
|
|
38
|
+
* const trimmed = trimHistory(history, 1, 'smart');
|
|
39
|
+
* // Result: system message + last user/assistant pair
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function trimHistory(history: readonly IRMessage[], maxHistorySize: number, strategy?: TrimStrategy): IRMessage[];
|
|
43
|
+
/**
|
|
44
|
+
* Count message pairs in history (excluding system messages)
|
|
45
|
+
*
|
|
46
|
+
* @param history - Conversation history
|
|
47
|
+
* @returns Number of user/assistant pairs
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const history = [
|
|
52
|
+
* { role: 'system', content: 'You are helpful' },
|
|
53
|
+
* { role: 'user', content: 'Hi' },
|
|
54
|
+
* { role: 'assistant', content: 'Hello!' },
|
|
55
|
+
* ];
|
|
56
|
+
*
|
|
57
|
+
* countMessagePairs(history); // 1
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function countMessagePairs(history: readonly IRMessage[]): number;
|
|
61
|
+
/**
|
|
62
|
+
* Check if history needs trimming
|
|
63
|
+
*
|
|
64
|
+
* @param history - Current history
|
|
65
|
+
* @param maxHistorySize - Maximum pairs to keep
|
|
66
|
+
* @param strategy - Trimming strategy
|
|
67
|
+
* @returns True if history exceeds limit
|
|
68
|
+
*/
|
|
69
|
+
export declare function shouldTrimHistory(history: readonly IRMessage[], maxHistorySize: number, strategy?: TrimStrategy): boolean;
|
|
70
|
+
//# sourceMappingURL=conversation-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-history.d.ts","sourceRoot":"","sources":["../../src/conversation-history.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,cAAc,EAAE,MAAM,EACtB,QAAQ,GAAE,YAAqB,GAC9B,SAAS,EAAE,CAsBb;AA2CD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAGvE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,cAAc,EAAE,MAAM,EACtB,QAAQ,GAAE,YAAqB,GAC9B,OAAO,CAiBT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Collection of utility functions for validation, normalization, and streaming.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export * from './validation.js';
|
|
9
|
+
export * from './system-message.js';
|
|
10
|
+
export * from './parameter-normalizer.js';
|
|
11
|
+
export * from './streaming.js';
|
|
12
|
+
export * from './streaming-modes.js';
|
|
13
|
+
export * from './warnings.js';
|
|
14
|
+
export * from './conversation-history.js';
|
|
15
|
+
export * from './model-cache.js';
|
|
16
|
+
export * from './structured-output.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,iBAAiB,CAAC;AAGhC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,gBAAgB,CAAC;AAG/B,cAAc,sBAAsB,CAAC;AAGrC,cAAc,eAAe,CAAC;AAG9B,cAAc,2BAA2B,CAAC;AAG1C,cAAc,kBAAkB,CAAC;AAGjC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Cache
|
|
3
|
+
*
|
|
4
|
+
* In-memory caching for model lists to reduce API calls.
|
|
5
|
+
* Supports both global (shared) and instance-scoped caches.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { ListModelsResult } from 'ai.matey.types';
|
|
10
|
+
/**
|
|
11
|
+
* In-memory cache for model lists with TTL-based expiration.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const cache = new ModelCache();
|
|
16
|
+
*
|
|
17
|
+
* // Set with 1 hour TTL
|
|
18
|
+
* cache.set('openai-backend', modelResult, 3600000);
|
|
19
|
+
*
|
|
20
|
+
* // Get (returns null if expired or not found)
|
|
21
|
+
* const cached = cache.get('openai-backend');
|
|
22
|
+
*
|
|
23
|
+
* // Invalidate specific backend
|
|
24
|
+
* cache.invalidate('openai-backend');
|
|
25
|
+
*
|
|
26
|
+
* // Clear all
|
|
27
|
+
* cache.clear();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class ModelCache {
|
|
31
|
+
private cache;
|
|
32
|
+
constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Get cached model list for a backend.
|
|
35
|
+
*
|
|
36
|
+
* @param backendName Unique backend identifier
|
|
37
|
+
* @returns Cached result or null if not found/expired
|
|
38
|
+
*/
|
|
39
|
+
get(backendName: string): ListModelsResult | null;
|
|
40
|
+
/**
|
|
41
|
+
* Cache a model list result.
|
|
42
|
+
*
|
|
43
|
+
* @param backendName Unique backend identifier
|
|
44
|
+
* @param result Model list result to cache
|
|
45
|
+
* @param ttl Time to live in milliseconds
|
|
46
|
+
*/
|
|
47
|
+
set(backendName: string, result: ListModelsResult, ttl: number): void;
|
|
48
|
+
/**
|
|
49
|
+
* Check if backend has cached models.
|
|
50
|
+
*
|
|
51
|
+
* @param backendName Unique backend identifier
|
|
52
|
+
* @returns true if cache exists and not expired
|
|
53
|
+
*/
|
|
54
|
+
has(backendName: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Invalidate (remove) cached models for a backend.
|
|
57
|
+
*
|
|
58
|
+
* @param backendName Unique backend identifier
|
|
59
|
+
*/
|
|
60
|
+
invalidate(backendName: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Clear all cached model lists.
|
|
63
|
+
*/
|
|
64
|
+
clear(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get number of cached backends.
|
|
67
|
+
*/
|
|
68
|
+
size(): number;
|
|
69
|
+
/**
|
|
70
|
+
* Get all cached backend names (excluding expired).
|
|
71
|
+
*/
|
|
72
|
+
keys(): string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Global model cache shared across all adapter instances.
|
|
76
|
+
*
|
|
77
|
+
* This is the default cache used when `modelsCacheScope: 'global'`.
|
|
78
|
+
* Reduces redundant API calls when multiple adapters share the same backend.
|
|
79
|
+
*/
|
|
80
|
+
export declare const globalModelCache: ModelCache;
|
|
81
|
+
/**
|
|
82
|
+
* Create or get model cache based on scope strategy.
|
|
83
|
+
*
|
|
84
|
+
* @param scope Cache scope strategy
|
|
85
|
+
* @returns Model cache instance
|
|
86
|
+
*/
|
|
87
|
+
export declare function getModelCache(scope?: 'global' | 'instance'): ModelCache;
|
|
88
|
+
//# sourceMappingURL=model-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-cache.d.ts","sourceRoot":"","sources":["../../src/model-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAyBvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA0B;;IAMvC;;;;;OAKG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAoBjD;;;;;;OAMG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IASrE;;;;;OAKG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIjC;;;;OAIG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;IAiBd;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE;CAejB;AAMD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,YAAmB,CAAC;AAMjD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,GAAE,QAAQ,GAAG,UAAqB,GAAG,UAAU,CAOjF"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter Normalization Utilities
|
|
3
|
+
*
|
|
4
|
+
* Normalizes parameters across different provider ranges and conventions.
|
|
5
|
+
* Enhanced with warning generation for semantic drift tracking.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { IRParameters, IRCapabilities, IRWarning } from 'ai.matey.types';
|
|
10
|
+
/**
|
|
11
|
+
* Normalize temperature to provider's range.
|
|
12
|
+
*
|
|
13
|
+
* IR uses 0-2 range (OpenAI convention).
|
|
14
|
+
* Some providers use 0-1 range (Anthropic).
|
|
15
|
+
*
|
|
16
|
+
* @param temperature Temperature value (0-2)
|
|
17
|
+
* @param targetRange Target range ('0-1' or '0-2')
|
|
18
|
+
* @returns Normalized temperature
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeTemperature(temperature: number | undefined, targetRange?: '0-1' | '0-2'): number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Denormalize temperature from provider's range back to IR.
|
|
23
|
+
*
|
|
24
|
+
* @param temperature Temperature value from provider
|
|
25
|
+
* @param sourceRange Source range ('0-1' or '0-2')
|
|
26
|
+
* @returns IR temperature (0-2)
|
|
27
|
+
*/
|
|
28
|
+
export declare function denormalizeTemperature(temperature: number | undefined, sourceRange?: '0-1' | '0-2'): number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Normalize topP parameter.
|
|
31
|
+
*
|
|
32
|
+
* Always 0-1 range across providers.
|
|
33
|
+
*
|
|
34
|
+
* @param topP TopP value
|
|
35
|
+
* @returns Clamped topP
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeTopP(topP: number | undefined): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Normalize topK parameter.
|
|
40
|
+
*
|
|
41
|
+
* @param topK TopK value
|
|
42
|
+
* @param maxTopK Maximum topK supported by provider
|
|
43
|
+
* @returns Clamped topK
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeTopK(topK: number | undefined, maxTopK?: number): number | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Normalize penalty parameters (frequency, presence).
|
|
48
|
+
*
|
|
49
|
+
* IR uses -2 to 2 range (OpenAI convention).
|
|
50
|
+
* Some providers might use different ranges.
|
|
51
|
+
*
|
|
52
|
+
* @param penalty Penalty value
|
|
53
|
+
* @param targetRange Target range
|
|
54
|
+
* @returns Normalized penalty
|
|
55
|
+
*/
|
|
56
|
+
export declare function normalizePenalty(penalty: number | undefined, targetRange?: {
|
|
57
|
+
min: number;
|
|
58
|
+
max: number;
|
|
59
|
+
}): number | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize stop sequences.
|
|
62
|
+
*
|
|
63
|
+
* @param stopSequences Stop sequences array
|
|
64
|
+
* @param maxStopSequences Maximum number of stop sequences supported
|
|
65
|
+
* @returns Normalized stop sequences
|
|
66
|
+
*/
|
|
67
|
+
export declare function normalizeStopSequences(stopSequences: readonly string[] | undefined, maxStopSequences?: number): string[] | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Filter parameters based on provider capabilities.
|
|
70
|
+
*
|
|
71
|
+
* Removes parameters that the provider doesn't support.
|
|
72
|
+
*
|
|
73
|
+
* @param parameters IR parameters
|
|
74
|
+
* @param capabilities Provider capabilities
|
|
75
|
+
* @returns Filtered parameters
|
|
76
|
+
*/
|
|
77
|
+
export declare function filterUnsupportedParameters(parameters: IRParameters | undefined, capabilities: IRCapabilities): IRParameters;
|
|
78
|
+
/**
|
|
79
|
+
* Apply parameter defaults.
|
|
80
|
+
*
|
|
81
|
+
* @param parameters IR parameters
|
|
82
|
+
* @param defaults Default values
|
|
83
|
+
* @returns Parameters with defaults applied
|
|
84
|
+
*/
|
|
85
|
+
export declare function applyParameterDefaults(parameters: IRParameters | undefined, defaults: Partial<IRParameters>): IRParameters;
|
|
86
|
+
/**
|
|
87
|
+
* Merge parameter objects.
|
|
88
|
+
*
|
|
89
|
+
* Later parameters override earlier ones.
|
|
90
|
+
*
|
|
91
|
+
* @param parameterSets Parameter objects to merge
|
|
92
|
+
* @returns Merged parameters
|
|
93
|
+
*/
|
|
94
|
+
export declare function mergeParameters(...parameterSets: Array<IRParameters | undefined>): IRParameters;
|
|
95
|
+
/**
|
|
96
|
+
* Clamp parameter to valid range.
|
|
97
|
+
*
|
|
98
|
+
* @param value Parameter value
|
|
99
|
+
* @param min Minimum value
|
|
100
|
+
* @param max Maximum value
|
|
101
|
+
* @returns Clamped value
|
|
102
|
+
*/
|
|
103
|
+
export declare function clampParameter(value: number | undefined, min: number, max: number): number | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Sanitize parameters by clamping to valid ranges.
|
|
106
|
+
*
|
|
107
|
+
* @param parameters IR parameters
|
|
108
|
+
* @returns Sanitized parameters
|
|
109
|
+
*/
|
|
110
|
+
export declare function sanitizeParameters(parameters: IRParameters | undefined): IRParameters;
|
|
111
|
+
/**
|
|
112
|
+
* Check if parameters are within valid ranges.
|
|
113
|
+
*
|
|
114
|
+
* @param parameters IR parameters
|
|
115
|
+
* @returns true if all parameters are valid
|
|
116
|
+
*/
|
|
117
|
+
export declare function areParametersValid(parameters: IRParameters | undefined): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Result of parameter normalization with warnings.
|
|
120
|
+
*/
|
|
121
|
+
export interface NormalizationResult<T> {
|
|
122
|
+
/** Normalized value */
|
|
123
|
+
value: T;
|
|
124
|
+
/** Warnings generated during normalization */
|
|
125
|
+
warnings: IRWarning[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Normalize temperature with warning generation.
|
|
129
|
+
*
|
|
130
|
+
* @param temperature Temperature value (0-2)
|
|
131
|
+
* @param targetRange Target range ('0-1' or '0-2')
|
|
132
|
+
* @param source Source adapter name
|
|
133
|
+
* @returns Normalized temperature and warnings
|
|
134
|
+
*/
|
|
135
|
+
export declare function normalizeTemperatureWithWarnings(temperature: number | undefined, targetRange?: '0-1' | '0-2', source?: string): NormalizationResult<number | undefined>;
|
|
136
|
+
/**
|
|
137
|
+
* Normalize stop sequences with warning generation.
|
|
138
|
+
*
|
|
139
|
+
* @param stopSequences Stop sequences array
|
|
140
|
+
* @param maxStopSequences Maximum number supported
|
|
141
|
+
* @param source Source adapter name
|
|
142
|
+
* @returns Normalized stop sequences and warnings
|
|
143
|
+
*/
|
|
144
|
+
export declare function normalizeStopSequencesWithWarnings(stopSequences: readonly string[] | undefined, maxStopSequences: number | undefined, source?: string): NormalizationResult<string[] | undefined>;
|
|
145
|
+
/**
|
|
146
|
+
* Filter parameters with warning generation.
|
|
147
|
+
*
|
|
148
|
+
* @param parameters IR parameters
|
|
149
|
+
* @param capabilities Provider capabilities
|
|
150
|
+
* @param source Source adapter name
|
|
151
|
+
* @returns Filtered parameters and warnings
|
|
152
|
+
*/
|
|
153
|
+
export declare function filterUnsupportedParametersWithWarnings(parameters: IRParameters | undefined, capabilities: IRCapabilities, source?: string): NormalizationResult<IRParameters>;
|
|
154
|
+
//# sourceMappingURL=parameter-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter-normalizer.d.ts","sourceRoot":"","sources":["../../src/parameter-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAY9E;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,GAAE,KAAK,GAAG,KAAa,GACjC,MAAM,GAAG,SAAS,CAcpB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,GAAE,KAAK,GAAG,KAAa,GACjC,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAM1E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE,MAAY,GAAG,MAAM,GAAG,SAAS,CAMjG;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,GAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAwB,GAC9D,MAAM,GAAG,SAAS,CAYpB;AAED;;;;;;G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