@ax-llm/ax 13.0.23 → 14.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/index.cjs +134 -52
- package/index.cjs.map +1 -1
- package/index.d.cts +1828 -179
- package/index.d.ts +1828 -179
- package/index.global.js +225 -143
- package/index.global.js.map +1 -1
- package/index.js +134 -52
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -74,6 +74,83 @@ declare class AxAIRefusalError extends Error {
|
|
|
74
74
|
constructor(refusalMessage: string, model?: string | undefined, requestId?: string | undefined);
|
|
75
75
|
toString(): string;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Error thrown when an AI provider doesn't support a required media type.
|
|
79
|
+
*
|
|
80
|
+
* This error is thrown during content processing when a provider cannot handle
|
|
81
|
+
* a specific media type and no suitable fallback mechanism is available or configured.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* try {
|
|
86
|
+
* await textOnlyProvider.chat(imageRequest);
|
|
87
|
+
* } catch (error) {
|
|
88
|
+
* if (error instanceof AxMediaNotSupportedError) {
|
|
89
|
+
* console.log(`${error.mediaType} not supported by ${error.provider}`);
|
|
90
|
+
* if (error.fallbackAvailable) {
|
|
91
|
+
* console.log('Consider using content processing services');
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
declare class AxMediaNotSupportedError extends Error {
|
|
98
|
+
readonly mediaType: string;
|
|
99
|
+
readonly provider: string;
|
|
100
|
+
readonly fallbackAvailable: boolean;
|
|
101
|
+
/** ISO timestamp when the error occurred */
|
|
102
|
+
readonly timestamp: string;
|
|
103
|
+
/** Unique identifier for this error instance */
|
|
104
|
+
readonly errorId: string;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new media not supported error.
|
|
107
|
+
*
|
|
108
|
+
* @param mediaType - The type of media that is not supported (e.g., 'Images', 'Audio')
|
|
109
|
+
* @param provider - The name of the AI provider that doesn't support the media type
|
|
110
|
+
* @param fallbackAvailable - Whether fallback processing options are available
|
|
111
|
+
*/
|
|
112
|
+
constructor(mediaType: string, provider: string, fallbackAvailable?: boolean);
|
|
113
|
+
toString(): string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Error thrown when content processing/transformation fails.
|
|
117
|
+
*
|
|
118
|
+
* This error wraps underlying failures from content processing services like
|
|
119
|
+
* image-to-text, audio transcription, file text extraction, or URL content fetching.
|
|
120
|
+
* It provides context about what type of content was being processed and at which step.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* try {
|
|
125
|
+
* await axProcessContentForProvider(content, provider, {
|
|
126
|
+
* imageToText: imageService.analyze
|
|
127
|
+
* });
|
|
128
|
+
* } catch (error) {
|
|
129
|
+
* if (error instanceof AxContentProcessingError) {
|
|
130
|
+
* console.log(`Failed processing ${error.contentType} during ${error.processingStep}`);
|
|
131
|
+
* console.log('Original error:', error.originalError.message);
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare class AxContentProcessingError extends Error {
|
|
137
|
+
readonly originalError: Error;
|
|
138
|
+
readonly contentType: string;
|
|
139
|
+
readonly processingStep: string;
|
|
140
|
+
/** ISO timestamp when the error occurred */
|
|
141
|
+
readonly timestamp: string;
|
|
142
|
+
/** Unique identifier for this error instance */
|
|
143
|
+
readonly errorId: string;
|
|
144
|
+
/**
|
|
145
|
+
* Creates a new content processing error.
|
|
146
|
+
*
|
|
147
|
+
* @param originalError - The underlying error that caused the processing failure
|
|
148
|
+
* @param contentType - The type of content being processed (e.g., 'image', 'audio', 'file')
|
|
149
|
+
* @param processingStep - The specific processing step that failed (e.g., 'vision analysis', 'transcription')
|
|
150
|
+
*/
|
|
151
|
+
constructor(originalError: Error, contentType: string, processingStep: string);
|
|
152
|
+
toString(): string;
|
|
153
|
+
}
|
|
77
154
|
|
|
78
155
|
type AxAIInputModelList<TModel, TEmbedModel, TModelKey> = (AxAIModelListBase<TModelKey> & {
|
|
79
156
|
isInternal?: boolean;
|
|
@@ -109,6 +186,10 @@ type AxTokenUsage = {
|
|
|
109
186
|
completionTokens: number;
|
|
110
187
|
totalTokens: number;
|
|
111
188
|
thoughtsTokens?: number;
|
|
189
|
+
reasoningTokens?: number;
|
|
190
|
+
cacheCreationTokens?: number;
|
|
191
|
+
cacheReadTokens?: number;
|
|
192
|
+
serviceTier?: 'standard' | 'priority' | 'batch';
|
|
112
193
|
};
|
|
113
194
|
type AxModelConfig = {
|
|
114
195
|
maxTokens?: number;
|
|
@@ -168,9 +249,23 @@ type AxChatResponseResult = {
|
|
|
168
249
|
url: string;
|
|
169
250
|
title?: string;
|
|
170
251
|
description?: string;
|
|
252
|
+
license?: string;
|
|
253
|
+
publicationDate?: string;
|
|
254
|
+
snippet?: string;
|
|
255
|
+
confidenceScore?: number;
|
|
171
256
|
};
|
|
172
257
|
}[];
|
|
173
258
|
finishReason?: 'stop' | 'length' | 'function_call' | 'content_filter' | 'error';
|
|
259
|
+
logprobs?: {
|
|
260
|
+
content?: {
|
|
261
|
+
token: string;
|
|
262
|
+
logprob: number;
|
|
263
|
+
topLogprobs?: {
|
|
264
|
+
token: string;
|
|
265
|
+
logprob: number;
|
|
266
|
+
}[];
|
|
267
|
+
}[];
|
|
268
|
+
};
|
|
174
269
|
};
|
|
175
270
|
type AxModelUsage = {
|
|
176
271
|
ai: string;
|
|
@@ -210,11 +305,43 @@ type AxChatRequest<TModel = string> = {
|
|
|
210
305
|
image: string;
|
|
211
306
|
details?: 'high' | 'low' | 'auto';
|
|
212
307
|
cache?: boolean;
|
|
308
|
+
/** Optimization preference for image processing */
|
|
309
|
+
optimize?: 'quality' | 'size' | 'auto';
|
|
310
|
+
/** Fallback text description when images aren't supported */
|
|
311
|
+
altText?: string;
|
|
213
312
|
} | {
|
|
214
313
|
type: 'audio';
|
|
215
314
|
data: string;
|
|
216
|
-
format?: 'wav';
|
|
315
|
+
format?: 'wav' | 'mp3' | 'ogg';
|
|
217
316
|
cache?: boolean;
|
|
317
|
+
/** Pre-transcribed text content for fallback */
|
|
318
|
+
transcription?: string;
|
|
319
|
+
/** Duration of audio in seconds */
|
|
320
|
+
duration?: number;
|
|
321
|
+
} | {
|
|
322
|
+
/** File content type */
|
|
323
|
+
type: 'file';
|
|
324
|
+
/** File data as base64 or file URL */
|
|
325
|
+
data: string;
|
|
326
|
+
/** Original filename */
|
|
327
|
+
filename: string;
|
|
328
|
+
/** MIME type of the file */
|
|
329
|
+
mimeType: string;
|
|
330
|
+
cache?: boolean;
|
|
331
|
+
/** Pre-extracted text content for fallback */
|
|
332
|
+
extractedText?: string;
|
|
333
|
+
} | {
|
|
334
|
+
/** URL/Link content type */
|
|
335
|
+
type: 'url';
|
|
336
|
+
/** The URL to fetch content from */
|
|
337
|
+
url: string;
|
|
338
|
+
cache?: boolean;
|
|
339
|
+
/** Pre-fetched content for providers without web access */
|
|
340
|
+
cachedContent?: string;
|
|
341
|
+
/** Page title for context */
|
|
342
|
+
title?: string;
|
|
343
|
+
/** Page description for context */
|
|
344
|
+
description?: string;
|
|
218
345
|
})[];
|
|
219
346
|
} | {
|
|
220
347
|
role: 'assistant';
|
|
@@ -236,6 +363,30 @@ type AxChatRequest<TModel = string> = {
|
|
|
236
363
|
functionId: string;
|
|
237
364
|
cache?: boolean;
|
|
238
365
|
})[];
|
|
366
|
+
/** Provider capability preferences and requirements */
|
|
367
|
+
capabilities?: {
|
|
368
|
+
/** Whether the request requires image support */
|
|
369
|
+
requiresImages?: boolean;
|
|
370
|
+
/** Whether the request requires audio support */
|
|
371
|
+
requiresAudio?: boolean;
|
|
372
|
+
/** Whether the request requires file support */
|
|
373
|
+
requiresFiles?: boolean;
|
|
374
|
+
/** Whether the request requires web search capabilities */
|
|
375
|
+
requiresWebSearch?: boolean;
|
|
376
|
+
/** How to handle unsupported content types */
|
|
377
|
+
fallbackBehavior?: 'error' | 'degrade' | 'skip';
|
|
378
|
+
};
|
|
379
|
+
/** Content processing preferences and hints */
|
|
380
|
+
processing?: {
|
|
381
|
+
/** Whether to apply image compression */
|
|
382
|
+
imageCompression?: boolean;
|
|
383
|
+
/** Whether to apply audio transcription */
|
|
384
|
+
audioTranscription?: boolean;
|
|
385
|
+
/** Whether to extract text from files */
|
|
386
|
+
fileTextExtraction?: boolean;
|
|
387
|
+
/** Whether to fetch content from URLs */
|
|
388
|
+
urlContentFetching?: boolean;
|
|
389
|
+
};
|
|
239
390
|
functions?: Readonly<{
|
|
240
391
|
name: string;
|
|
241
392
|
description: string;
|
|
@@ -400,6 +551,60 @@ interface AxAIFeatures {
|
|
|
400
551
|
functionCot?: boolean;
|
|
401
552
|
hasThinkingBudget?: boolean;
|
|
402
553
|
hasShowThoughts?: boolean;
|
|
554
|
+
/** Enhanced media capability specifications */
|
|
555
|
+
media: {
|
|
556
|
+
/** Image processing capabilities */
|
|
557
|
+
images: {
|
|
558
|
+
/** Whether the provider supports image inputs */
|
|
559
|
+
supported: boolean;
|
|
560
|
+
/** Supported image MIME types (e.g., ['image/jpeg', 'image/png']) */
|
|
561
|
+
formats: string[];
|
|
562
|
+
/** Maximum image size in bytes */
|
|
563
|
+
maxSize?: number;
|
|
564
|
+
/** Supported detail/quality levels for image processing */
|
|
565
|
+
detailLevels?: ('high' | 'low' | 'auto')[];
|
|
566
|
+
};
|
|
567
|
+
/** Audio processing capabilities */
|
|
568
|
+
audio: {
|
|
569
|
+
/** Whether the provider supports audio inputs */
|
|
570
|
+
supported: boolean;
|
|
571
|
+
/** Supported audio formats (e.g., ['wav', 'mp3']) */
|
|
572
|
+
formats: string[];
|
|
573
|
+
/** Maximum audio duration in seconds */
|
|
574
|
+
maxDuration?: number;
|
|
575
|
+
};
|
|
576
|
+
/** File processing capabilities */
|
|
577
|
+
files: {
|
|
578
|
+
/** Whether the provider supports file inputs */
|
|
579
|
+
supported: boolean;
|
|
580
|
+
/** Supported file MIME types (e.g., ['application/pdf', 'text/plain']) */
|
|
581
|
+
formats: string[];
|
|
582
|
+
/** Maximum file size in bytes */
|
|
583
|
+
maxSize?: number;
|
|
584
|
+
/** How files are uploaded to the provider */
|
|
585
|
+
uploadMethod: 'inline' | 'upload' | 'cloud' | 'none';
|
|
586
|
+
};
|
|
587
|
+
/** URL and web content capabilities */
|
|
588
|
+
urls: {
|
|
589
|
+
/** Whether the provider supports URL inputs */
|
|
590
|
+
supported: boolean;
|
|
591
|
+
/** Whether the provider can perform web searches */
|
|
592
|
+
webSearch: boolean;
|
|
593
|
+
/** Whether the provider can fetch web page content */
|
|
594
|
+
contextFetching: boolean;
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
/** Content caching capabilities */
|
|
598
|
+
caching: {
|
|
599
|
+
/** Whether the provider supports content caching */
|
|
600
|
+
supported: boolean;
|
|
601
|
+
/** Types of caching available */
|
|
602
|
+
types: ('ephemeral' | 'persistent')[];
|
|
603
|
+
};
|
|
604
|
+
/** Whether the provider supports thinking/reasoning modes */
|
|
605
|
+
thinking: boolean;
|
|
606
|
+
/** Whether the provider supports multi-turn conversations */
|
|
607
|
+
multiTurn: boolean;
|
|
403
608
|
}
|
|
404
609
|
interface AxBaseAIArgs<TModel, TEmbedModel, TModelKey> {
|
|
405
610
|
name: string;
|
|
@@ -1097,6 +1302,307 @@ declare class AxBalancer<TServices extends readonly AxAIService<any, any, any>[]
|
|
|
1097
1302
|
getLogger(): AxLoggerFunction;
|
|
1098
1303
|
}
|
|
1099
1304
|
|
|
1305
|
+
/**
|
|
1306
|
+
* Configuration options for content processing and fallback behavior
|
|
1307
|
+
*/
|
|
1308
|
+
interface ProcessingOptions {
|
|
1309
|
+
/** How to handle unsupported content types: 'error' throws, 'degrade' converts to text, 'skip' omits */
|
|
1310
|
+
fallbackBehavior?: 'error' | 'degrade' | 'skip';
|
|
1311
|
+
/** Service to convert images to text descriptions */
|
|
1312
|
+
imageToText?: (imageData: string) => Promise<string>;
|
|
1313
|
+
/** Service to convert audio to text transcriptions */
|
|
1314
|
+
audioToText?: (audioData: string, format?: string) => Promise<string>;
|
|
1315
|
+
/** Service to extract text from files */
|
|
1316
|
+
fileToText?: (fileData: string, mimeType: string) => Promise<string>;
|
|
1317
|
+
/** Service to fetch and extract text from URLs */
|
|
1318
|
+
urlToText?: (url: string) => Promise<string>;
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Represents processed content that has been converted to text format
|
|
1322
|
+
*/
|
|
1323
|
+
interface ProcessedContent {
|
|
1324
|
+
/** Content type after processing (always 'text') */
|
|
1325
|
+
type: 'text';
|
|
1326
|
+
/** The processed text content */
|
|
1327
|
+
text: string;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Indicates what types of media content are present in a request
|
|
1331
|
+
*/
|
|
1332
|
+
interface MediaRequirements {
|
|
1333
|
+
/** Whether the content includes images */
|
|
1334
|
+
hasImages: boolean;
|
|
1335
|
+
/** Whether the content includes audio */
|
|
1336
|
+
hasAudio: boolean;
|
|
1337
|
+
/** Whether the content includes files */
|
|
1338
|
+
hasFiles: boolean;
|
|
1339
|
+
/** Whether the content includes URLs */
|
|
1340
|
+
hasUrls: boolean;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Processes content for a specific AI provider, handling unsupported media types.
|
|
1344
|
+
*
|
|
1345
|
+
* This function takes mixed content (text, images, audio, files, URLs) and transforms
|
|
1346
|
+
* it to formats supported by the target provider. Unsupported content types are
|
|
1347
|
+
* handled according to the fallback behavior:
|
|
1348
|
+
* - 'error': Throws AxMediaNotSupportedError
|
|
1349
|
+
* - 'degrade': Converts to text using fallback services or alt text
|
|
1350
|
+
* - 'skip': Omits the unsupported content
|
|
1351
|
+
*
|
|
1352
|
+
* @param content - The content to process (string, object, or array of content items)
|
|
1353
|
+
* @param provider - The target AI service provider
|
|
1354
|
+
* @param options - Processing options including fallback behavior and conversion services
|
|
1355
|
+
* @returns Promise resolving to array of processed content items (all converted to text)
|
|
1356
|
+
* @throws AxMediaNotSupportedError when fallbackBehavior is 'error' and content is unsupported
|
|
1357
|
+
* @throws AxContentProcessingError when a conversion service fails
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```typescript
|
|
1361
|
+
* const processed = await axProcessContentForProvider(
|
|
1362
|
+
* [
|
|
1363
|
+
* { type: 'text', text: 'Analyze this:' },
|
|
1364
|
+
* { type: 'image', image: 'base64...', altText: 'Chart showing sales data' }
|
|
1365
|
+
* ],
|
|
1366
|
+
* textOnlyProvider,
|
|
1367
|
+
* {
|
|
1368
|
+
* fallbackBehavior: 'degrade',
|
|
1369
|
+
* imageToText: async (data) => await visionService.describe(data)
|
|
1370
|
+
* }
|
|
1371
|
+
* );
|
|
1372
|
+
* // Result: [{ type: 'text', text: 'Analyze this:' }, { type: 'text', text: 'Chart showing sales data' }]
|
|
1373
|
+
* ```
|
|
1374
|
+
*/
|
|
1375
|
+
declare function axProcessContentForProvider(content: any, provider: AxAIService, options?: ProcessingOptions): Promise<ProcessedContent[]>;
|
|
1376
|
+
/**
|
|
1377
|
+
* Analyzes a chat prompt to determine what media types it contains.
|
|
1378
|
+
*
|
|
1379
|
+
* Scans through chat messages to identify the types of media content present,
|
|
1380
|
+
* which can be used for provider capability matching and routing decisions.
|
|
1381
|
+
*
|
|
1382
|
+
* @param chatPrompt - Array of chat messages to analyze
|
|
1383
|
+
* @returns Object indicating which media types are present in the chat prompt
|
|
1384
|
+
*
|
|
1385
|
+
* @example
|
|
1386
|
+
* ```typescript
|
|
1387
|
+
* const requirements = axAnalyzeChatPromptRequirements([
|
|
1388
|
+
* {
|
|
1389
|
+
* role: 'user',
|
|
1390
|
+
* content: [
|
|
1391
|
+
* { type: 'text', text: 'Analyze this:' },
|
|
1392
|
+
* { type: 'image', image: 'base64...' },
|
|
1393
|
+
* { type: 'file', filename: 'report.pdf' }
|
|
1394
|
+
* ]
|
|
1395
|
+
* }
|
|
1396
|
+
* ]);
|
|
1397
|
+
* // Result: { hasImages: true, hasAudio: false, hasFiles: true, hasUrls: false }
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
declare function axAnalyzeChatPromptRequirements(chatPrompt: any[]): MediaRequirements;
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Represents a provider's compatibility score for a specific request
|
|
1404
|
+
*/
|
|
1405
|
+
interface ProviderCapabilityScore {
|
|
1406
|
+
/** The AI service provider */
|
|
1407
|
+
provider: AxAIService;
|
|
1408
|
+
/** Numerical score based on capability match (higher is better) */
|
|
1409
|
+
score: number;
|
|
1410
|
+
/** List of capabilities the provider is missing for this request */
|
|
1411
|
+
missingCapabilities: string[];
|
|
1412
|
+
/** List of capabilities the provider supports for this request */
|
|
1413
|
+
supportedCapabilities: string[];
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Result of validating whether a provider can handle a request
|
|
1417
|
+
*/
|
|
1418
|
+
interface CapabilityValidationResult {
|
|
1419
|
+
/** Whether the provider fully supports the request */
|
|
1420
|
+
isSupported: boolean;
|
|
1421
|
+
/** List of capabilities the provider is missing */
|
|
1422
|
+
missingCapabilities: string[];
|
|
1423
|
+
/** Non-critical issues or limitations */
|
|
1424
|
+
warnings: string[];
|
|
1425
|
+
/** Suggested alternatives for missing capabilities */
|
|
1426
|
+
alternatives: string[];
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Analyzes a chat request to determine what capabilities it requires from AI providers.
|
|
1430
|
+
*
|
|
1431
|
+
* This function examines the request content to identify:
|
|
1432
|
+
* - Media types (images, audio, files, URLs)
|
|
1433
|
+
* - Function calling requirements
|
|
1434
|
+
* - Streaming requirements
|
|
1435
|
+
* - Caching requirements
|
|
1436
|
+
* - Token usage estimation
|
|
1437
|
+
*
|
|
1438
|
+
* @param request - The chat request to analyze
|
|
1439
|
+
* @returns Object containing detailed capability requirements and token estimation
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* const requirements = axAnalyzeRequestRequirements({
|
|
1444
|
+
* chatPrompt: [{
|
|
1445
|
+
* role: 'user',
|
|
1446
|
+
* content: [
|
|
1447
|
+
* { type: 'text', text: 'Analyze this image:' },
|
|
1448
|
+
* { type: 'image', image: 'base64...', details: 'high' }
|
|
1449
|
+
* ]
|
|
1450
|
+
* }]
|
|
1451
|
+
* });
|
|
1452
|
+
*
|
|
1453
|
+
* console.log(requirements.hasImages); // true
|
|
1454
|
+
* console.log(requirements.estimatedTokens); // ~95
|
|
1455
|
+
* ```
|
|
1456
|
+
*/
|
|
1457
|
+
declare function axAnalyzeRequestRequirements(request: AxChatRequest): MediaRequirements & {
|
|
1458
|
+
requiresFunctions: boolean;
|
|
1459
|
+
requiresStreaming: boolean;
|
|
1460
|
+
requiresCaching: boolean;
|
|
1461
|
+
contentTypes: Set<string>;
|
|
1462
|
+
estimatedTokens: number;
|
|
1463
|
+
};
|
|
1464
|
+
/**
|
|
1465
|
+
* Validates whether an AI provider can handle a request with specific requirements.
|
|
1466
|
+
*
|
|
1467
|
+
* Compares the provider's feature set against the analyzed request requirements
|
|
1468
|
+
* to determine compatibility, missing capabilities, and potential issues.
|
|
1469
|
+
*
|
|
1470
|
+
* @param provider - The AI service provider to validate
|
|
1471
|
+
* @param requirements - Requirements object from axAnalyzeRequestRequirements()
|
|
1472
|
+
* @returns Validation result with support status, missing capabilities, and alternatives
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```typescript
|
|
1476
|
+
* const requirements = axAnalyzeRequestRequirements(request);
|
|
1477
|
+
* const validation = axValidateProviderCapabilities(openaiProvider, requirements);
|
|
1478
|
+
*
|
|
1479
|
+
* if (!validation.isSupported) {
|
|
1480
|
+
* console.log('Missing:', validation.missingCapabilities);
|
|
1481
|
+
* console.log('Try:', validation.alternatives);
|
|
1482
|
+
* }
|
|
1483
|
+
* ```
|
|
1484
|
+
*/
|
|
1485
|
+
declare function axValidateProviderCapabilities(provider: AxAIService, requirements: ReturnType<typeof axAnalyzeRequestRequirements>): CapabilityValidationResult;
|
|
1486
|
+
/**
|
|
1487
|
+
* Scores multiple AI providers based on how well they meet request requirements.
|
|
1488
|
+
*
|
|
1489
|
+
* Uses a weighted scoring system where providers earn points for supported capabilities:
|
|
1490
|
+
* - Base functionality: +10 points
|
|
1491
|
+
* - Media support (images/audio/files/URLs): +25 points each
|
|
1492
|
+
* - Core features (functions/streaming/caching): +8-15 points each
|
|
1493
|
+
* - Missing critical capabilities: -10 points each
|
|
1494
|
+
* - Bonus points for advanced features (large file support, persistent caching, etc.)
|
|
1495
|
+
*
|
|
1496
|
+
* @param providers - Array of AI service providers to score
|
|
1497
|
+
* @param requirements - Requirements object from axAnalyzeRequestRequirements()
|
|
1498
|
+
* @returns Array of scored providers sorted by score (highest first)
|
|
1499
|
+
*
|
|
1500
|
+
* @example
|
|
1501
|
+
* ```typescript
|
|
1502
|
+
* const requirements = axAnalyzeRequestRequirements(request);
|
|
1503
|
+
* const scores = axScoreProvidersForRequest([openai, gemini, cohere], requirements);
|
|
1504
|
+
*
|
|
1505
|
+
* console.log(`Best: ${scores[0].provider.getName()} (${scores[0].score} points)`);
|
|
1506
|
+
* console.log(`Supports: ${scores[0].supportedCapabilities.join(', ')}`);
|
|
1507
|
+
* ```
|
|
1508
|
+
*/
|
|
1509
|
+
declare function axScoreProvidersForRequest(providers: AxAIService[], requirements: ReturnType<typeof axAnalyzeRequestRequirements>): ProviderCapabilityScore[];
|
|
1510
|
+
/**
|
|
1511
|
+
* Automatically selects the optimal AI provider for a given request.
|
|
1512
|
+
*
|
|
1513
|
+
* Analyzes the request requirements, scores available providers, and returns
|
|
1514
|
+
* the best match based on capability compatibility and scoring algorithm.
|
|
1515
|
+
*
|
|
1516
|
+
* @param request - The chat request to find a provider for
|
|
1517
|
+
* @param availableProviders - Array of available AI service providers
|
|
1518
|
+
* @param options - Selection options
|
|
1519
|
+
* @param options.requireExactMatch - Only return providers with full capability support
|
|
1520
|
+
* @param options.allowDegradation - Allow providers that require content processing fallbacks
|
|
1521
|
+
* @returns The optimal AI service provider
|
|
1522
|
+
* @throws Error if no suitable provider found or requirements not met
|
|
1523
|
+
*
|
|
1524
|
+
* @example
|
|
1525
|
+
* ```typescript
|
|
1526
|
+
* // Automatic selection with degradation allowed
|
|
1527
|
+
* const provider = axSelectOptimalProvider(
|
|
1528
|
+
* multiModalRequest,
|
|
1529
|
+
* [openai, gemini, cohere],
|
|
1530
|
+
* { allowDegradation: true }
|
|
1531
|
+
* );
|
|
1532
|
+
*
|
|
1533
|
+
* // Strict matching - must support all features natively
|
|
1534
|
+
* const provider = axSelectOptimalProvider(
|
|
1535
|
+
* imageRequest,
|
|
1536
|
+
* [openai, gemini],
|
|
1537
|
+
* { requireExactMatch: true }
|
|
1538
|
+
* );
|
|
1539
|
+
* ```
|
|
1540
|
+
*/
|
|
1541
|
+
declare function axSelectOptimalProvider(request: AxChatRequest, availableProviders: AxAIService[], options?: {
|
|
1542
|
+
requireExactMatch?: boolean;
|
|
1543
|
+
allowDegradation?: boolean;
|
|
1544
|
+
}): AxAIService;
|
|
1545
|
+
/**
|
|
1546
|
+
* Generates a comprehensive compatibility report for a request across all providers.
|
|
1547
|
+
*
|
|
1548
|
+
* Provides detailed analysis including requirement breakdown, provider scoring,
|
|
1549
|
+
* recommendations, and human-readable compatibility summary.
|
|
1550
|
+
*
|
|
1551
|
+
* @param request - The chat request to analyze
|
|
1552
|
+
* @param availableProviders - Array of available AI service providers
|
|
1553
|
+
* @returns Comprehensive compatibility report with analysis and recommendations
|
|
1554
|
+
*
|
|
1555
|
+
* @example
|
|
1556
|
+
* ```typescript
|
|
1557
|
+
* const report = axGetCompatibilityReport(request, [openai, gemini, cohere]);
|
|
1558
|
+
*
|
|
1559
|
+
* console.log(report.summary); // "OpenAI supports 4/4 requirements (100% compatibility)"
|
|
1560
|
+
* console.log('Requirements:', report.requirements);
|
|
1561
|
+
*
|
|
1562
|
+
* for (const score of report.providerScores) {
|
|
1563
|
+
* console.log(`${score.provider.getName()}: ${score.score} points`);
|
|
1564
|
+
* console.log(` Missing: ${score.missingCapabilities.join(', ')}`);
|
|
1565
|
+
* }
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
declare function axGetCompatibilityReport(request: AxChatRequest, availableProviders: AxAIService[]): {
|
|
1569
|
+
requirements: ReturnType<typeof axAnalyzeRequestRequirements>;
|
|
1570
|
+
providerScores: ProviderCapabilityScore[];
|
|
1571
|
+
recommendedProvider: AxAIService | null;
|
|
1572
|
+
summary: string;
|
|
1573
|
+
};
|
|
1574
|
+
/**
|
|
1575
|
+
* Filters providers that support a specific media type.
|
|
1576
|
+
*
|
|
1577
|
+
* @param providers - Array of AI service providers to filter
|
|
1578
|
+
* @param mediaType - The media type to check support for
|
|
1579
|
+
* @returns Array of providers that support the specified media type
|
|
1580
|
+
*
|
|
1581
|
+
* @example
|
|
1582
|
+
* ```typescript
|
|
1583
|
+
* const imageProviders = axGetProvidersWithMediaSupport(allProviders, 'images');
|
|
1584
|
+
* console.log(`${imageProviders.length} providers support images`);
|
|
1585
|
+
* ```
|
|
1586
|
+
*/
|
|
1587
|
+
declare function axGetProvidersWithMediaSupport(providers: AxAIService[], mediaType: 'images' | 'audio' | 'files' | 'urls'): AxAIService[];
|
|
1588
|
+
/**
|
|
1589
|
+
* Analyzes format compatibility across providers for a specific media type.
|
|
1590
|
+
*
|
|
1591
|
+
* @param providers - Array of AI service providers to analyze
|
|
1592
|
+
* @param mediaType - The media type to check format support for
|
|
1593
|
+
* @returns Object mapping each supported format to the providers that support it
|
|
1594
|
+
*
|
|
1595
|
+
* @example
|
|
1596
|
+
* ```typescript
|
|
1597
|
+
* const compatibility = axGetFormatCompatibility(allProviders, 'images');
|
|
1598
|
+
* console.log('JPEG support:', compatibility['image/jpeg']?.map(p => p.getName()));
|
|
1599
|
+
* console.log('PNG support:', compatibility['image/png']?.map(p => p.getName()));
|
|
1600
|
+
* ```
|
|
1601
|
+
*/
|
|
1602
|
+
declare function axGetFormatCompatibility(providers: AxAIService[], mediaType: 'images' | 'audio' | 'files'): {
|
|
1603
|
+
[format: string]: AxAIService[];
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1100
1606
|
/**
|
|
1101
1607
|
* Cohere: Models for text generation
|
|
1102
1608
|
*/
|
|
@@ -1685,10 +2191,7 @@ declare class AxMockAIService<TModelKey> implements AxAIService<unknown, unknown
|
|
|
1685
2191
|
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
1686
2192
|
getName(): string;
|
|
1687
2193
|
getId(): string;
|
|
1688
|
-
getFeatures(_model?: string):
|
|
1689
|
-
functions: boolean;
|
|
1690
|
-
streaming: boolean;
|
|
1691
|
-
};
|
|
2194
|
+
getFeatures(_model?: string): AxAIFeatures;
|
|
1692
2195
|
getModelList(): AxAIModelList<TModelKey> | undefined;
|
|
1693
2196
|
getMetrics(): AxAIServiceMetrics;
|
|
1694
2197
|
chat(req: Readonly<AxChatRequest<unknown>>, _options?: Readonly<AxAIServiceOptions>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
@@ -1751,11 +2254,7 @@ declare class AxMultiServiceRouter<TServices extends readonly (AxAIService | AxA
|
|
|
1751
2254
|
* If a model key is provided, delegate to the corresponding service's features.
|
|
1752
2255
|
* Otherwise, returns a default feature set.
|
|
1753
2256
|
*/
|
|
1754
|
-
getFeatures(model?: TModelKey):
|
|
1755
|
-
functions: boolean;
|
|
1756
|
-
streaming: boolean;
|
|
1757
|
-
functionCot?: boolean;
|
|
1758
|
-
};
|
|
2257
|
+
getFeatures(model?: TModelKey): AxAIFeatures;
|
|
1759
2258
|
/**
|
|
1760
2259
|
* Returns aggregated metrics from the underlying service.
|
|
1761
2260
|
* Uses the metrics from the last service that was used,
|
|
@@ -2453,6 +2952,235 @@ declare class AxAIReka<TModelKey> extends AxBaseAI<AxAIRekaModel, undefined, AxA
|
|
|
2453
2952
|
*/
|
|
2454
2953
|
declare const axModelInfoReka: AxModelInfo[];
|
|
2455
2954
|
|
|
2955
|
+
/**
|
|
2956
|
+
* Services for converting unsupported content types to text or optimized formats
|
|
2957
|
+
*/
|
|
2958
|
+
interface AxContentProcessingServices {
|
|
2959
|
+
/** Service to convert images to text descriptions */
|
|
2960
|
+
imageToText?: (imageData: string) => Promise<string>;
|
|
2961
|
+
/** Service to convert audio to text transcriptions */
|
|
2962
|
+
audioToText?: (audioData: string, format?: string) => Promise<string>;
|
|
2963
|
+
/** Service to extract text from files */
|
|
2964
|
+
fileToText?: (fileData: string, mimeType: string) => Promise<string>;
|
|
2965
|
+
/** Service to fetch and extract text from URLs */
|
|
2966
|
+
urlToText?: (url: string) => Promise<string>;
|
|
2967
|
+
/** Service to optimize images for size/quality */
|
|
2968
|
+
imageOptimization?: (imageData: string, options: OptimizationOptions) => Promise<string>;
|
|
2969
|
+
}
|
|
2970
|
+
/**
|
|
2971
|
+
* Options for image optimization processing
|
|
2972
|
+
*/
|
|
2973
|
+
interface OptimizationOptions {
|
|
2974
|
+
/** Image quality (0-100) */
|
|
2975
|
+
quality?: number;
|
|
2976
|
+
/** Maximum file size in bytes */
|
|
2977
|
+
maxSize?: number;
|
|
2978
|
+
/** Target image format */
|
|
2979
|
+
format?: 'jpeg' | 'png' | 'webp';
|
|
2980
|
+
}
|
|
2981
|
+
/**
|
|
2982
|
+
* Configuration for multi-provider routing with fallback capabilities
|
|
2983
|
+
*/
|
|
2984
|
+
interface AxMultiProviderConfig {
|
|
2985
|
+
/** Provider hierarchy for routing */
|
|
2986
|
+
providers: {
|
|
2987
|
+
/** Primary provider to try first */
|
|
2988
|
+
primary: AxAIService;
|
|
2989
|
+
/** Alternative providers for fallback */
|
|
2990
|
+
alternatives: AxAIService[];
|
|
2991
|
+
};
|
|
2992
|
+
/** Routing behavior configuration */
|
|
2993
|
+
routing: {
|
|
2994
|
+
/** Order of preferences when selecting providers */
|
|
2995
|
+
preferenceOrder: ('capability' | 'cost' | 'speed' | 'quality')[];
|
|
2996
|
+
/** Capability matching requirements */
|
|
2997
|
+
capability: {
|
|
2998
|
+
/** Only use providers with full capability support */
|
|
2999
|
+
requireExactMatch: boolean;
|
|
3000
|
+
/** Allow providers that require content processing fallbacks */
|
|
3001
|
+
allowDegradation: boolean;
|
|
3002
|
+
};
|
|
3003
|
+
};
|
|
3004
|
+
/** Content processing services for unsupported media types */
|
|
3005
|
+
processing: AxContentProcessingServices;
|
|
3006
|
+
}
|
|
3007
|
+
/**
|
|
3008
|
+
* Result of the routing process including provider selection and processing information
|
|
3009
|
+
*/
|
|
3010
|
+
interface AxRoutingResult {
|
|
3011
|
+
/** The selected AI service provider */
|
|
3012
|
+
provider: AxAIService;
|
|
3013
|
+
/** List of content processing steps that were applied */
|
|
3014
|
+
processingApplied: string[];
|
|
3015
|
+
/** List of capability degradations that occurred */
|
|
3016
|
+
degradations: string[];
|
|
3017
|
+
/** Non-critical warnings about the routing decision */
|
|
3018
|
+
warnings: string[];
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Multi-provider router that automatically selects optimal AI providers and handles content processing.
|
|
3022
|
+
*
|
|
3023
|
+
* The router analyzes requests to determine capability requirements, scores available providers,
|
|
3024
|
+
* and automatically handles content transformation for unsupported media types. It provides
|
|
3025
|
+
* graceful degradation and fallback mechanisms for robust multi-modal AI applications.
|
|
3026
|
+
*
|
|
3027
|
+
* @example
|
|
3028
|
+
* ```typescript
|
|
3029
|
+
* const router = new AxProviderRouter({
|
|
3030
|
+
* providers: {
|
|
3031
|
+
* primary: openaiProvider,
|
|
3032
|
+
* alternatives: [geminiProvider, cohereProvider]
|
|
3033
|
+
* },
|
|
3034
|
+
* routing: {
|
|
3035
|
+
* preferenceOrder: ['capability', 'quality'],
|
|
3036
|
+
* capability: {
|
|
3037
|
+
* requireExactMatch: false,
|
|
3038
|
+
* allowDegradation: true
|
|
3039
|
+
* }
|
|
3040
|
+
* },
|
|
3041
|
+
* processing: {
|
|
3042
|
+
* imageToText: async (data) => await visionService.describe(data),
|
|
3043
|
+
* audioToText: async (data) => await speechService.transcribe(data)
|
|
3044
|
+
* }
|
|
3045
|
+
* });
|
|
3046
|
+
*
|
|
3047
|
+
* const result = await router.chat(multiModalRequest);
|
|
3048
|
+
* console.log(`Used: ${result.routing.provider.getName()}`);
|
|
3049
|
+
* ```
|
|
3050
|
+
*/
|
|
3051
|
+
declare class AxProviderRouter {
|
|
3052
|
+
private providers;
|
|
3053
|
+
private processingServices;
|
|
3054
|
+
private config;
|
|
3055
|
+
/**
|
|
3056
|
+
* Creates a new provider router with the specified configuration.
|
|
3057
|
+
*
|
|
3058
|
+
* @param config - Router configuration including providers, routing preferences, and processing services
|
|
3059
|
+
*/
|
|
3060
|
+
constructor(config: AxMultiProviderConfig);
|
|
3061
|
+
/**
|
|
3062
|
+
* Routes a chat request to the most appropriate provider with automatic content processing.
|
|
3063
|
+
*
|
|
3064
|
+
* This method analyzes the request, selects the optimal provider, preprocesses content
|
|
3065
|
+
* for compatibility, and executes the request with fallback support.
|
|
3066
|
+
*
|
|
3067
|
+
* @param request - The chat request to process
|
|
3068
|
+
* @param options - Extended options including fallback providers and routing preferences
|
|
3069
|
+
* @param options.fallbackProviders - Additional providers to try if primary selection fails
|
|
3070
|
+
* @param options.processingOptions - Content processing options and conversion services
|
|
3071
|
+
* @param options.routingOptions - Provider selection and routing behavior options
|
|
3072
|
+
* @param options.routingOptions.requireExactMatch - Only use providers with full capability support
|
|
3073
|
+
* @param options.routingOptions.allowDegradation - Allow content processing for unsupported types
|
|
3074
|
+
* @param options.routingOptions.maxRetries - Maximum number of fallback providers to try
|
|
3075
|
+
* @returns Promise resolving to the AI response and routing information
|
|
3076
|
+
* @throws AxMediaNotSupportedError when no suitable provider can handle the request
|
|
3077
|
+
*
|
|
3078
|
+
* @example
|
|
3079
|
+
* ```typescript
|
|
3080
|
+
* const result = await router.chat(
|
|
3081
|
+
* { chatPrompt: [{ role: 'user', content: [{ type: 'image', image: '...' }] }] },
|
|
3082
|
+
* {
|
|
3083
|
+
* processingOptions: { fallbackBehavior: 'degrade' },
|
|
3084
|
+
* routingOptions: { allowDegradation: true }
|
|
3085
|
+
* }
|
|
3086
|
+
* );
|
|
3087
|
+
*
|
|
3088
|
+
* console.log(`Provider: ${result.routing.provider.getName()}`);
|
|
3089
|
+
* console.log(`Processing applied: ${result.routing.processingApplied}`);
|
|
3090
|
+
* ```
|
|
3091
|
+
*/
|
|
3092
|
+
chat(request: AxChatRequest, options?: AxAIServiceOptions & {
|
|
3093
|
+
fallbackProviders?: AxAIService[];
|
|
3094
|
+
processingOptions?: ProcessingOptions;
|
|
3095
|
+
routingOptions?: {
|
|
3096
|
+
requireExactMatch?: boolean;
|
|
3097
|
+
allowDegradation?: boolean;
|
|
3098
|
+
maxRetries?: number;
|
|
3099
|
+
};
|
|
3100
|
+
}): Promise<{
|
|
3101
|
+
response: AxChatResponse | ReadableStream<AxChatResponse>;
|
|
3102
|
+
routing: AxRoutingResult;
|
|
3103
|
+
}>;
|
|
3104
|
+
/**
|
|
3105
|
+
* Preprocesses request content for the target provider
|
|
3106
|
+
*/
|
|
3107
|
+
private preprocessRequest;
|
|
3108
|
+
/**
|
|
3109
|
+
* Selects provider with graceful degradation
|
|
3110
|
+
*/
|
|
3111
|
+
private selectProviderWithDegradation;
|
|
3112
|
+
/**
|
|
3113
|
+
* Tries fallback providers when primary provider fails
|
|
3114
|
+
*/
|
|
3115
|
+
private tryFallbackProviders;
|
|
3116
|
+
/**
|
|
3117
|
+
* Gets routing recommendation without executing the request.
|
|
3118
|
+
*
|
|
3119
|
+
* Analyzes the request and returns routing information including which provider
|
|
3120
|
+
* would be selected, what processing would be applied, and any degradations or warnings.
|
|
3121
|
+
*
|
|
3122
|
+
* @param request - The chat request to analyze
|
|
3123
|
+
* @returns Promise resolving to routing result with provider selection and processing info
|
|
3124
|
+
*
|
|
3125
|
+
* @example
|
|
3126
|
+
* ```typescript
|
|
3127
|
+
* const recommendation = await router.getRoutingRecommendation(request);
|
|
3128
|
+
* console.log(`Would use: ${recommendation.provider.getName()}`);
|
|
3129
|
+
* console.log(`Degradations: ${recommendation.degradations.join(', ')}`);
|
|
3130
|
+
* ```
|
|
3131
|
+
*/
|
|
3132
|
+
getRoutingRecommendation(request: AxChatRequest): Promise<AxRoutingResult>;
|
|
3133
|
+
/**
|
|
3134
|
+
* Validates whether the configured providers can handle a specific request.
|
|
3135
|
+
*
|
|
3136
|
+
* Performs pre-flight validation to check if the request can be successfully
|
|
3137
|
+
* processed by available providers, identifies potential issues, and provides
|
|
3138
|
+
* recommendations for improving compatibility.
|
|
3139
|
+
*
|
|
3140
|
+
* @param request - The chat request to validate
|
|
3141
|
+
* @returns Promise resolving to validation result with handling capability and recommendations
|
|
3142
|
+
*
|
|
3143
|
+
* @example
|
|
3144
|
+
* ```typescript
|
|
3145
|
+
* const validation = await router.validateRequest(request);
|
|
3146
|
+
* if (!validation.canHandle) {
|
|
3147
|
+
* console.log('Issues:', validation.issues);
|
|
3148
|
+
* console.log('Recommendations:', validation.recommendations);
|
|
3149
|
+
* }
|
|
3150
|
+
* ```
|
|
3151
|
+
*/
|
|
3152
|
+
validateRequest(request: AxChatRequest): Promise<{
|
|
3153
|
+
canHandle: boolean;
|
|
3154
|
+
issues: string[];
|
|
3155
|
+
recommendations: string[];
|
|
3156
|
+
}>;
|
|
3157
|
+
/**
|
|
3158
|
+
* Gets detailed statistics about the router's provider capabilities.
|
|
3159
|
+
*
|
|
3160
|
+
* Returns information about available providers, their supported capabilities,
|
|
3161
|
+
* and routing recommendations for analysis and debugging purposes.
|
|
3162
|
+
*
|
|
3163
|
+
* @returns Object containing provider statistics and capability matrix
|
|
3164
|
+
*
|
|
3165
|
+
* @example
|
|
3166
|
+
* ```typescript
|
|
3167
|
+
* const stats = router.getRoutingStats();
|
|
3168
|
+
* console.log(`Total providers: ${stats.totalProviders}`);
|
|
3169
|
+
* console.log('Capabilities:');
|
|
3170
|
+
* for (const [capability, providers] of Object.entries(stats.capabilityMatrix)) {
|
|
3171
|
+
* console.log(` ${capability}: ${providers.join(', ')}`);
|
|
3172
|
+
* }
|
|
3173
|
+
* ```
|
|
3174
|
+
*/
|
|
3175
|
+
getRoutingStats(): {
|
|
3176
|
+
totalProviders: number;
|
|
3177
|
+
capabilityMatrix: {
|
|
3178
|
+
[capability: string]: string[];
|
|
3179
|
+
};
|
|
3180
|
+
recommendedProvider: string;
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3183
|
+
|
|
2456
3184
|
type TogetherAIConfig = AxAIOpenAIConfig<string, unknown>;
|
|
2457
3185
|
declare const axAITogetherDefaultConfig: () => TogetherAIConfig;
|
|
2458
3186
|
type AxAITogetherArgs<TModelKey> = AxAIOpenAIArgs<'together', string, unknown, TModelKey>;
|
|
@@ -2718,16 +3446,45 @@ type ExtractModelKeysAndValues<T> = T extends readonly {
|
|
|
2718
3446
|
type InferTModelKey<T> = T extends {
|
|
2719
3447
|
models: infer M;
|
|
2720
3448
|
} ? ExtractModelKeysAndValues<M> : string;
|
|
3449
|
+
/**
|
|
3450
|
+
* Factory function for creating AxAI instances with type safety.
|
|
3451
|
+
* This is the recommended way to create AxAI instances instead of using the constructor.
|
|
3452
|
+
*
|
|
3453
|
+
* @param options - Configuration options for the AI service
|
|
3454
|
+
* @returns A properly typed AxAI instance
|
|
3455
|
+
*
|
|
3456
|
+
* @example
|
|
3457
|
+
* ```typescript
|
|
3458
|
+
* const ai = ai({
|
|
3459
|
+
* name: 'openai',
|
|
3460
|
+
* apiKey: process.env.OPENAI_APIKEY!
|
|
3461
|
+
* });
|
|
3462
|
+
* ```
|
|
3463
|
+
*/
|
|
3464
|
+
declare function ai<const T extends AxAIArgs<any>>(options: T): AxAI<InferTModelKey<T>>;
|
|
2721
3465
|
declare class AxAI<TModelKey = string> implements AxAIService<any, any, TModelKey> {
|
|
2722
3466
|
private ai;
|
|
2723
3467
|
static create<const T extends AxAIArgs<any>>(options: T): AxAI<InferTModelKey<T>>;
|
|
3468
|
+
/**
|
|
3469
|
+
* @deprecated Use `AxAI.create()` or `ai()` function instead for better type safety.
|
|
3470
|
+
* This constructor will be removed in v15.0.0.
|
|
3471
|
+
*
|
|
3472
|
+
* Migration timeline:
|
|
3473
|
+
* - v13.0.24+: Deprecation warnings (current)
|
|
3474
|
+
* - v14.0.0: Runtime console warnings
|
|
3475
|
+
* - v15.0.0: Complete removal
|
|
3476
|
+
*
|
|
3477
|
+
* @example
|
|
3478
|
+
* ```typescript
|
|
3479
|
+
* // Instead of: new AxAI({ name: 'openai', apiKey: '...' })
|
|
3480
|
+
* // Use: AxAI.create({ name: 'openai', apiKey: '...' })
|
|
3481
|
+
* // Or: ai({ name: 'openai', apiKey: '...' })
|
|
3482
|
+
* ```
|
|
3483
|
+
*/
|
|
2724
3484
|
constructor(options: Readonly<AxAIArgs<TModelKey>>);
|
|
2725
3485
|
getName(): string;
|
|
2726
3486
|
getId(): string;
|
|
2727
|
-
getFeatures(model?: string):
|
|
2728
|
-
functions: boolean;
|
|
2729
|
-
streaming: boolean;
|
|
2730
|
-
};
|
|
3487
|
+
getFeatures(model?: string): AxAIFeatures;
|
|
2731
3488
|
getModelList(): AxAIModelList<TModelKey> | undefined;
|
|
2732
3489
|
getLastUsedChatModel(): any;
|
|
2733
3490
|
getLastUsedEmbedModel(): any;
|
|
@@ -2908,61 +3665,6 @@ interface AxAIMemory {
|
|
|
2908
3665
|
rewindToTag(name: string, sessionId?: string): AxMemoryData;
|
|
2909
3666
|
}
|
|
2910
3667
|
|
|
2911
|
-
interface AxField {
|
|
2912
|
-
name: string;
|
|
2913
|
-
title?: string;
|
|
2914
|
-
description?: string;
|
|
2915
|
-
type?: {
|
|
2916
|
-
name: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'date' | 'datetime' | 'class' | 'code';
|
|
2917
|
-
isArray?: boolean;
|
|
2918
|
-
options?: string[];
|
|
2919
|
-
};
|
|
2920
|
-
isOptional?: boolean;
|
|
2921
|
-
isInternal?: boolean;
|
|
2922
|
-
}
|
|
2923
|
-
type AxIField = Omit<AxField, 'title'> & {
|
|
2924
|
-
title: string;
|
|
2925
|
-
};
|
|
2926
|
-
interface AxSignatureConfig {
|
|
2927
|
-
description?: string;
|
|
2928
|
-
inputs: readonly AxField[];
|
|
2929
|
-
outputs: readonly AxField[];
|
|
2930
|
-
}
|
|
2931
|
-
declare class AxSignature {
|
|
2932
|
-
private description?;
|
|
2933
|
-
private inputFields;
|
|
2934
|
-
private outputFields;
|
|
2935
|
-
private sigHash;
|
|
2936
|
-
private sigString;
|
|
2937
|
-
private validatedAtHash?;
|
|
2938
|
-
constructor(signature?: Readonly<AxSignature | string | AxSignatureConfig>);
|
|
2939
|
-
private parseParsedField;
|
|
2940
|
-
private parseField;
|
|
2941
|
-
setDescription: (desc: string) => void;
|
|
2942
|
-
addInputField: (field: Readonly<AxField>) => void;
|
|
2943
|
-
addOutputField: (field: Readonly<AxField>) => void;
|
|
2944
|
-
setInputFields: (fields: readonly AxField[]) => void;
|
|
2945
|
-
setOutputFields: (fields: readonly AxField[]) => void;
|
|
2946
|
-
getInputFields: () => Readonly<AxIField[]>;
|
|
2947
|
-
getOutputFields: () => Readonly<AxIField[]>;
|
|
2948
|
-
getDescription: () => string | undefined;
|
|
2949
|
-
private invalidateValidationCache;
|
|
2950
|
-
private toTitle;
|
|
2951
|
-
toJSONSchema: () => AxFunctionJSONSchema;
|
|
2952
|
-
private updateHashLight;
|
|
2953
|
-
private updateHash;
|
|
2954
|
-
private validateSignatureConsistency;
|
|
2955
|
-
validate: () => boolean;
|
|
2956
|
-
hash: () => string;
|
|
2957
|
-
toString: () => string;
|
|
2958
|
-
toJSON: () => {
|
|
2959
|
-
id: string;
|
|
2960
|
-
description: string | undefined;
|
|
2961
|
-
inputFields: AxIField[];
|
|
2962
|
-
outputFields: AxIField[];
|
|
2963
|
-
};
|
|
2964
|
-
}
|
|
2965
|
-
|
|
2966
3668
|
declare class AxMemory implements AxAIMemory {
|
|
2967
3669
|
private memories;
|
|
2968
3670
|
private defaultMemory;
|
|
@@ -2993,11 +3695,29 @@ declare class AxMemory implements AxAIMemory {
|
|
|
2993
3695
|
image: string;
|
|
2994
3696
|
details?: "high" | "low" | "auto";
|
|
2995
3697
|
cache?: boolean;
|
|
3698
|
+
optimize?: "quality" | "size" | "auto";
|
|
3699
|
+
altText?: string;
|
|
2996
3700
|
} | {
|
|
2997
3701
|
type: "audio";
|
|
2998
3702
|
data: string;
|
|
2999
|
-
format?: "wav";
|
|
3703
|
+
format?: "wav" | "mp3" | "ogg";
|
|
3704
|
+
cache?: boolean;
|
|
3705
|
+
transcription?: string;
|
|
3706
|
+
duration?: number;
|
|
3707
|
+
} | {
|
|
3708
|
+
type: "file";
|
|
3709
|
+
data: string;
|
|
3710
|
+
filename: string;
|
|
3711
|
+
mimeType: string;
|
|
3712
|
+
cache?: boolean;
|
|
3713
|
+
extractedText?: string;
|
|
3714
|
+
} | {
|
|
3715
|
+
type: "url";
|
|
3716
|
+
url: string;
|
|
3000
3717
|
cache?: boolean;
|
|
3718
|
+
cachedContent?: string;
|
|
3719
|
+
title?: string;
|
|
3720
|
+
description?: string;
|
|
3001
3721
|
})[];
|
|
3002
3722
|
} | {
|
|
3003
3723
|
role: "assistant";
|
|
@@ -3078,7 +3798,7 @@ declare class AxPromptTemplate {
|
|
|
3078
3798
|
private readonly functions?;
|
|
3079
3799
|
constructor(sig: Readonly<AxSignature>, options?: Readonly<AxPromptTemplateOptions>, fieldTemplates?: Record<string, AxFieldTemplateFn>);
|
|
3080
3800
|
private renderSingleValueUserContent;
|
|
3081
|
-
render: <T
|
|
3801
|
+
render: <T = any>(values: T | ReadonlyArray<AxMessage<T>>, // Allow T or array of AxMessages
|
|
3082
3802
|
{ examples, demos, }: Readonly<{
|
|
3083
3803
|
skipSystemPrompt?: boolean;
|
|
3084
3804
|
examples?: Record<string, AxFieldValue>[];
|
|
@@ -3096,11 +3816,29 @@ declare class AxPromptTemplate {
|
|
|
3096
3816
|
image: string;
|
|
3097
3817
|
details?: "high" | "low" | "auto";
|
|
3098
3818
|
cache?: boolean;
|
|
3819
|
+
optimize?: "quality" | "size" | "auto";
|
|
3820
|
+
altText?: string;
|
|
3099
3821
|
} | {
|
|
3100
3822
|
type: "audio";
|
|
3101
3823
|
data: string;
|
|
3102
|
-
format?: "wav";
|
|
3824
|
+
format?: "wav" | "mp3" | "ogg";
|
|
3103
3825
|
cache?: boolean;
|
|
3826
|
+
transcription?: string;
|
|
3827
|
+
duration?: number;
|
|
3828
|
+
} | {
|
|
3829
|
+
type: "file";
|
|
3830
|
+
data: string;
|
|
3831
|
+
filename: string;
|
|
3832
|
+
mimeType: string;
|
|
3833
|
+
cache?: boolean;
|
|
3834
|
+
extractedText?: string;
|
|
3835
|
+
} | {
|
|
3836
|
+
type: "url";
|
|
3837
|
+
url: string;
|
|
3838
|
+
cache?: boolean;
|
|
3839
|
+
cachedContent?: string;
|
|
3840
|
+
title?: string;
|
|
3841
|
+
description?: string;
|
|
3104
3842
|
})[];
|
|
3105
3843
|
private renderExamples;
|
|
3106
3844
|
private renderDemos;
|
|
@@ -3109,6 +3847,165 @@ declare class AxPromptTemplate {
|
|
|
3109
3847
|
private defaultRenderInField;
|
|
3110
3848
|
}
|
|
3111
3849
|
|
|
3850
|
+
/**
|
|
3851
|
+
* A map of string type names to their corresponding TypeScript types.
|
|
3852
|
+
* Maps signature type strings to actual TypeScript types for type inference.
|
|
3853
|
+
*/
|
|
3854
|
+
interface TypeMap {
|
|
3855
|
+
string: string;
|
|
3856
|
+
number: number;
|
|
3857
|
+
boolean: boolean;
|
|
3858
|
+
json: any;
|
|
3859
|
+
date: Date;
|
|
3860
|
+
datetime: Date;
|
|
3861
|
+
image: {
|
|
3862
|
+
mimeType: string;
|
|
3863
|
+
data: string;
|
|
3864
|
+
};
|
|
3865
|
+
audio: {
|
|
3866
|
+
format?: 'wav';
|
|
3867
|
+
data: string;
|
|
3868
|
+
};
|
|
3869
|
+
file: {
|
|
3870
|
+
mimeType: string;
|
|
3871
|
+
data: string;
|
|
3872
|
+
};
|
|
3873
|
+
url: string;
|
|
3874
|
+
code: string;
|
|
3875
|
+
}
|
|
3876
|
+
type ParseClassOptions<S extends string> = S extends `${infer First},${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : S extends `${infer First}|${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : S extends `${infer First} | ${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : S extends `${infer First}, ${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : Trim<S>;
|
|
3877
|
+
type ResolveType<T extends string> = T extends keyof TypeMap ? TypeMap[T] : T extends `${infer BaseType}[]` ? BaseType extends keyof TypeMap ? TypeMap[BaseType][] : any[] : T extends `class[]|${infer Options}` ? ParseClassOptions<Options>[] : T extends `class|${infer Options}` ? ParseClassOptions<Options> : T extends 'class' ? string : any;
|
|
3878
|
+
type Trim<S extends string> = S extends ` ${infer T}` ? Trim<T> : S extends `\n${infer T}` ? Trim<T> : S extends `\t${infer T}` ? Trim<T> : S extends `\r${infer T}` ? Trim<T> : S extends `${infer U} ` ? Trim<U> : S extends `${infer U}\n` ? Trim<U> : S extends `${infer U}\t` ? Trim<U> : S extends `${infer U}\r` ? Trim<U> : S;
|
|
3879
|
+
type ParseField<S extends string> = S extends `${infer Name}?` ? {
|
|
3880
|
+
name: Trim<Name>;
|
|
3881
|
+
optional: true;
|
|
3882
|
+
} : {
|
|
3883
|
+
name: Trim<S>;
|
|
3884
|
+
optional: false;
|
|
3885
|
+
};
|
|
3886
|
+
type ExtractType<S extends string> = S extends `class[] "${infer Options}" "${infer _Desc}"` ? `class[]|${Options}` : S extends `class[] "${infer Options}"` ? `class[]|${Options}` : S extends `class "${infer Options}" "${infer _Desc}"` ? `class|${Options}` : S extends `class "${infer Options}"` ? `class|${Options}` : S extends `${infer Type}[] "${infer _Desc}"` ? `${Type}[]` : S extends `${infer Type}[]` ? `${Type}[]` : S extends `${infer Type} "${infer _Desc}"` ? Type : S;
|
|
3887
|
+
type ParseNameAndType<S extends string> = S extends `${infer Name}:${infer TypePart}` ? ParseField<Name> & {
|
|
3888
|
+
type: Trim<ExtractType<Trim<TypePart>>>;
|
|
3889
|
+
} : S extends `${infer Name} "${infer _Description}"` ? ParseField<Name> & {
|
|
3890
|
+
type: 'string';
|
|
3891
|
+
} : ParseField<S> & {
|
|
3892
|
+
type: 'string';
|
|
3893
|
+
};
|
|
3894
|
+
/**
|
|
3895
|
+
* Advanced field splitting that respects quotes using a state machine approach.
|
|
3896
|
+
*
|
|
3897
|
+
* This type-level parser solves the core problem of parsing comma-separated fields
|
|
3898
|
+
* when commas can appear both as field separators AND inside quoted strings.
|
|
3899
|
+
*
|
|
3900
|
+
* PROBLEM EXAMPLE:
|
|
3901
|
+
* Input: 'sourceType:class "class1, class2, class3", relevantContext:string, sources:string'
|
|
3902
|
+
*
|
|
3903
|
+
* Simple comma splitting would incorrectly produce:
|
|
3904
|
+
* ['sourceType:class "class1', ' class2', ' class3"', ' relevantContext:string', ' sources:string']
|
|
3905
|
+
*
|
|
3906
|
+
* This parser correctly produces:
|
|
3907
|
+
* ['sourceType:class "class1, class2, class3"', 'relevantContext:string', 'sources:string']
|
|
3908
|
+
*
|
|
3909
|
+
* ALGORITHM:
|
|
3910
|
+
* 1. Process each character in the input string one by one
|
|
3911
|
+
* 2. Track whether we're currently inside or outside quotes
|
|
3912
|
+
* 3. When encountering a quote ("), toggle the quote state
|
|
3913
|
+
* 4. When encountering a comma (,):
|
|
3914
|
+
* - If inside quotes: treat as literal character, add to current field
|
|
3915
|
+
* - If outside quotes: treat as field separator, complete current field and start new one
|
|
3916
|
+
* 5. For all other characters: add to current field being built
|
|
3917
|
+
*
|
|
3918
|
+
* STATE PARAMETERS:
|
|
3919
|
+
* @param S - The remaining string to process
|
|
3920
|
+
* @param Current - The current field being built character by character
|
|
3921
|
+
* @param InQuote - Boolean state tracking if we're inside quotes
|
|
3922
|
+
* @param Result - Accumulator array of completed fields
|
|
3923
|
+
*/
|
|
3924
|
+
type SplitFieldsRespectingQuotes<S extends string, Current extends string = '', InQuote extends boolean = false, Result extends string[] = []> = S extends `${infer Char}${infer Rest}` ? Char extends '"' ? SplitFieldsRespectingQuotes<Rest, `${Current}${Char}`, InQuote extends true ? false : true, Result> : Char extends ',' ? InQuote extends true ? SplitFieldsRespectingQuotes<Rest, `${Current}${Char}`, InQuote, Result> : Rest extends ` ${infer RestTrimmed}` ? SplitFieldsRespectingQuotes<RestTrimmed, '', false, [
|
|
3925
|
+
...Result,
|
|
3926
|
+
Current
|
|
3927
|
+
]> : SplitFieldsRespectingQuotes<Rest, '', false, [...Result, Current]> : SplitFieldsRespectingQuotes<Rest, `${Current}${Char}`, InQuote, Result> : Current extends '' ? Result : [...Result, Current];
|
|
3928
|
+
/**
|
|
3929
|
+
* Convert string array to parsed field objects.
|
|
3930
|
+
*
|
|
3931
|
+
* Takes the array of field strings produced by SplitFieldsRespectingQuotes
|
|
3932
|
+
* and converts each string into a structured field object with name, type, and optional properties.
|
|
3933
|
+
*
|
|
3934
|
+
* EXAMPLE:
|
|
3935
|
+
* Input: ['sourceType:class "class1, class2, class3"', 'relevantContext:string', 'sources:string']
|
|
3936
|
+
* Output: [
|
|
3937
|
+
* { name: 'sourceType', type: 'class|class1, class2, class3', optional: false },
|
|
3938
|
+
* { name: 'relevantContext', type: 'string', optional: false },
|
|
3939
|
+
* { name: 'sources', type: 'string', optional: false }
|
|
3940
|
+
* ]
|
|
3941
|
+
*/
|
|
3942
|
+
type StringArrayToFields<T extends readonly string[]> = T extends readonly [
|
|
3943
|
+
infer First,
|
|
3944
|
+
...infer Rest
|
|
3945
|
+
] ? First extends string ? Rest extends readonly string[] ? [ParseNameAndType<Trim<First>>, ...StringArrayToFields<Rest>] : [ParseNameAndType<Trim<First>>] : [] : [];
|
|
3946
|
+
/**
|
|
3947
|
+
* Main field parser using the quote-aware splitter.
|
|
3948
|
+
*
|
|
3949
|
+
* This is the entry point for parsing a field list string into typed field objects.
|
|
3950
|
+
* It combines the quote-aware splitting with field object conversion to produce
|
|
3951
|
+
* the final tuple that BuildObject can use for type inference.
|
|
3952
|
+
*
|
|
3953
|
+
* FLOW:
|
|
3954
|
+
* 1. SplitFieldsRespectingQuotes: 'field1, field2' -> ['field1', 'field2']
|
|
3955
|
+
* 2. StringArrayToFields: ['field1', 'field2'] -> [FieldObj1, FieldObj2]
|
|
3956
|
+
* 3. BuildObject: [FieldObj1, FieldObj2] -> { field1: Type1, field2: Type2 }
|
|
3957
|
+
*/
|
|
3958
|
+
type ParseFields<S extends string> = StringArrayToFields<SplitFieldsRespectingQuotes<S>>;
|
|
3959
|
+
/**
|
|
3960
|
+
* Builds a TypeScript object type from a readonly tuple of field definitions,
|
|
3961
|
+
* supporting both required and optional fields.
|
|
3962
|
+
*/
|
|
3963
|
+
type BuildObject<T extends readonly {
|
|
3964
|
+
name: string;
|
|
3965
|
+
type: string;
|
|
3966
|
+
optional: boolean;
|
|
3967
|
+
}[]> = {
|
|
3968
|
+
-readonly [K in T[number] as K['optional'] extends false ? K['name'] : never]: ResolveType<K['type']>;
|
|
3969
|
+
} & {
|
|
3970
|
+
-readonly [K in T[number] as K['optional'] extends true ? K['name'] : never]?: ResolveType<K['type']>;
|
|
3971
|
+
};
|
|
3972
|
+
type StripSignatureDescription<S extends string> = S extends `"${infer _Desc}" ${infer Rest}` ? Trim<Rest> : S;
|
|
3973
|
+
/**
|
|
3974
|
+
* The main signature parser that handles the complete parsing pipeline.
|
|
3975
|
+
*
|
|
3976
|
+
* This is the top-level type that users interact with. It takes a signature string
|
|
3977
|
+
* and produces TypeScript types for both inputs and outputs with proper type inference.
|
|
3978
|
+
*
|
|
3979
|
+
* SIGNATURE FORMAT:
|
|
3980
|
+
* "[description] inputField1:type1, inputField2:type2 -> outputField1:type1, outputField2:type2"
|
|
3981
|
+
*
|
|
3982
|
+
* EXAMPLES:
|
|
3983
|
+
* Simple: 'userQuery:string -> response:string'
|
|
3984
|
+
* Complex: 'searchQuery:string -> sourceType:class "class1, class2, class3", context:string'
|
|
3985
|
+
* With description: '"Analyze text" text:string -> sentiment:class "positive, negative", confidence:number'
|
|
3986
|
+
*
|
|
3987
|
+
* PROCESSING STEPS:
|
|
3988
|
+
* 1. StripSignatureDescription: Remove optional description at start
|
|
3989
|
+
* 2. Split on " -> " to separate inputs from outputs
|
|
3990
|
+
* 3. ParseFields: Use quote-aware parsing for both input and output field lists
|
|
3991
|
+
* 4. BuildObject: Convert field tuples to TypeScript object types
|
|
3992
|
+
*
|
|
3993
|
+
* RESULT TYPE:
|
|
3994
|
+
* {
|
|
3995
|
+
* inputs: { [fieldName]: FieldType },
|
|
3996
|
+
* outputs: { [fieldName]: FieldType }
|
|
3997
|
+
* }
|
|
3998
|
+
*
|
|
3999
|
+
* Where FieldType is inferred from the signature (string, number, 'option1'|'option2', etc.)
|
|
4000
|
+
*/
|
|
4001
|
+
type ParseSignature<S extends string> = StripSignatureDescription<Trim<S>> extends `${infer Inputs} -> ${infer Outputs}` ? {
|
|
4002
|
+
inputs: BuildObject<ParseFields<Trim<Inputs>>>;
|
|
4003
|
+
outputs: BuildObject<ParseFields<Trim<Outputs>>>;
|
|
4004
|
+
} : {
|
|
4005
|
+
inputs: Record<string, any>;
|
|
4006
|
+
outputs: Record<string, any>;
|
|
4007
|
+
};
|
|
4008
|
+
|
|
3112
4009
|
type AxFieldValue = string | string[] | number | boolean | object | null | undefined | {
|
|
3113
4010
|
mimeType: string;
|
|
3114
4011
|
data: string;
|
|
@@ -3128,23 +4025,23 @@ type AxGenIn = {
|
|
|
3128
4025
|
type AxGenOut = {
|
|
3129
4026
|
[key: string]: AxFieldValue;
|
|
3130
4027
|
};
|
|
3131
|
-
type AxMessage<IN
|
|
4028
|
+
type AxMessage<IN> = {
|
|
3132
4029
|
role: 'user';
|
|
3133
4030
|
values: IN;
|
|
3134
4031
|
} | {
|
|
3135
4032
|
role: 'assistant';
|
|
3136
4033
|
values: IN;
|
|
3137
4034
|
};
|
|
3138
|
-
type AxProgramTrace<IN
|
|
4035
|
+
type AxProgramTrace<IN, OUT> = {
|
|
3139
4036
|
trace: OUT & IN;
|
|
3140
4037
|
programId: string;
|
|
3141
4038
|
};
|
|
3142
|
-
type AxProgramDemos<IN
|
|
4039
|
+
type AxProgramDemos<IN, OUT> = {
|
|
3143
4040
|
traces: (OUT & IN)[];
|
|
3144
4041
|
programId: string;
|
|
3145
4042
|
};
|
|
3146
|
-
type AxProgramExamples<IN
|
|
3147
|
-
type AxResultPickerFunctionFieldResults<OUT
|
|
4043
|
+
type AxProgramExamples<IN, OUT> = AxProgramDemos<IN, OUT> | AxProgramDemos<IN, OUT>['traces'];
|
|
4044
|
+
type AxResultPickerFunctionFieldResults<OUT> = {
|
|
3148
4045
|
type: 'fields';
|
|
3149
4046
|
results: readonly {
|
|
3150
4047
|
index: number;
|
|
@@ -3162,7 +4059,7 @@ type AxResultPickerFunctionFunctionResults = {
|
|
|
3162
4059
|
isError?: boolean;
|
|
3163
4060
|
}[];
|
|
3164
4061
|
};
|
|
3165
|
-
type AxResultPickerFunction<OUT
|
|
4062
|
+
type AxResultPickerFunction<OUT> = (data: AxResultPickerFunctionFieldResults<OUT> | AxResultPickerFunctionFunctionResults) => number | Promise<number>;
|
|
3166
4063
|
type AxProgramForwardOptions<MODEL> = AxAIServiceOptions & {
|
|
3167
4064
|
maxRetries?: number;
|
|
3168
4065
|
maxSteps?: number;
|
|
@@ -3195,18 +4092,18 @@ type AxProgramStreamingForwardOptions<MODEL> = Omit<AxProgramForwardOptions<MODE
|
|
|
3195
4092
|
type AxAIServiceModelType<T extends Readonly<AxAIService<any, any, any>>> = T extends Readonly<AxAIService<infer TModel, any, infer TModelKey>> ? TModel extends unknown ? TModelKey : TModel | TModelKey : never;
|
|
3196
4093
|
type AxProgramForwardOptionsWithModels<T extends Readonly<AxAIService<any, any, any>>> = AxProgramForwardOptions<AxAIServiceModelType<T>>;
|
|
3197
4094
|
type AxProgramStreamingForwardOptionsWithModels<T extends Readonly<AxAIService<any, any, any>>> = AxProgramStreamingForwardOptions<AxAIServiceModelType<T>>;
|
|
3198
|
-
type AxGenDeltaOut<OUT
|
|
4095
|
+
type AxGenDeltaOut<OUT> = {
|
|
3199
4096
|
version: number;
|
|
3200
4097
|
index: number;
|
|
3201
4098
|
delta: Partial<OUT>;
|
|
3202
4099
|
};
|
|
3203
|
-
type AxGenStreamingOut<OUT
|
|
4100
|
+
type AxGenStreamingOut<OUT> = AsyncGenerator<AxGenDeltaOut<OUT>, void, unknown>;
|
|
3204
4101
|
type AxSetExamplesOptions = {};
|
|
3205
|
-
interface AxForwardable<IN
|
|
4102
|
+
interface AxForwardable<IN, OUT, TModelKey> {
|
|
3206
4103
|
forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions<TModelKey>>): Promise<OUT>;
|
|
3207
4104
|
streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions<TModelKey>>): AxGenStreamingOut<OUT>;
|
|
3208
4105
|
}
|
|
3209
|
-
interface AxTunable<IN
|
|
4106
|
+
interface AxTunable<IN, OUT> {
|
|
3210
4107
|
setExamples: (examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>) => void;
|
|
3211
4108
|
setId: (id: string) => void;
|
|
3212
4109
|
setParentId: (parentId: string) => void;
|
|
@@ -3217,7 +4114,7 @@ interface AxUsable {
|
|
|
3217
4114
|
getUsage: () => AxProgramUsage[];
|
|
3218
4115
|
resetUsage: () => void;
|
|
3219
4116
|
}
|
|
3220
|
-
interface AxProgrammable<IN
|
|
4117
|
+
interface AxProgrammable<IN, OUT, TModelKey = string> extends AxForwardable<IN, OUT, TModelKey>, AxTunable<IN, OUT>, AxUsable {
|
|
3221
4118
|
getSignature: () => AxSignature;
|
|
3222
4119
|
}
|
|
3223
4120
|
type AxProgramUsage = AxChatResponse['modelUsage'] & {
|
|
@@ -3229,6 +4126,207 @@ interface AxProgramOptions {
|
|
|
3229
4126
|
traceLabel?: string;
|
|
3230
4127
|
}
|
|
3231
4128
|
|
|
4129
|
+
interface AxFieldType {
|
|
4130
|
+
readonly type: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'file' | 'url' | 'date' | 'datetime' | 'class' | 'code';
|
|
4131
|
+
readonly isArray?: boolean;
|
|
4132
|
+
readonly options?: readonly string[];
|
|
4133
|
+
readonly description?: string;
|
|
4134
|
+
readonly isOptional?: boolean;
|
|
4135
|
+
readonly isInternal?: boolean;
|
|
4136
|
+
}
|
|
4137
|
+
declare class AxSignatureBuilder<_TInput extends Record<string, any> = {}, _TOutput extends Record<string, any> = {}> {
|
|
4138
|
+
private inputFields;
|
|
4139
|
+
private outputFields;
|
|
4140
|
+
private desc?;
|
|
4141
|
+
/**
|
|
4142
|
+
* Add an input field to the signature
|
|
4143
|
+
* @param name - Field name
|
|
4144
|
+
* @param fieldInfo - Field type created with f.string(), f.number(), etc.
|
|
4145
|
+
* @param prepend - If true, adds field to the beginning of input fields
|
|
4146
|
+
*/
|
|
4147
|
+
input<K extends string, T extends AxFluentFieldInfo<any, any, any, any> | AxFluentFieldType>(name: K, fieldInfo: T, prepend?: boolean): AxSignatureBuilder<_TInput & Record<K, InferFluentType<T>>, _TOutput>;
|
|
4148
|
+
/**
|
|
4149
|
+
* Add an output field to the signature
|
|
4150
|
+
* @param name - Field name
|
|
4151
|
+
* @param fieldInfo - Field type created with f.string(), f.number(), etc.
|
|
4152
|
+
* @param prepend - If true, adds field to the beginning of output fields
|
|
4153
|
+
*/
|
|
4154
|
+
output<K extends string, T extends AxFluentFieldInfo<any, any, any, any> | AxFluentFieldType>(name: K, fieldInfo: T, prepend?: boolean): AxSignatureBuilder<_TInput, _TOutput & Record<K, InferFluentType<T>>>;
|
|
4155
|
+
/**
|
|
4156
|
+
* Set the description for the signature
|
|
4157
|
+
* @param description - Description text
|
|
4158
|
+
*/
|
|
4159
|
+
description(description: string): AxSignatureBuilder<_TInput, _TOutput>;
|
|
4160
|
+
/**
|
|
4161
|
+
* Build the final AxSignature instance
|
|
4162
|
+
*/
|
|
4163
|
+
build(): AxSignature<_TInput, _TOutput>;
|
|
4164
|
+
}
|
|
4165
|
+
declare class AxFluentFieldType implements AxFieldType {
|
|
4166
|
+
readonly type: AxFieldType['type'];
|
|
4167
|
+
readonly isArray?: boolean;
|
|
4168
|
+
readonly options?: readonly string[];
|
|
4169
|
+
readonly description?: string;
|
|
4170
|
+
readonly isOptional?: boolean;
|
|
4171
|
+
readonly isInternal?: boolean;
|
|
4172
|
+
constructor(fieldType: AxFieldType);
|
|
4173
|
+
optional(): AxFluentFieldType;
|
|
4174
|
+
array(): AxFluentFieldType;
|
|
4175
|
+
internal(): AxFluentFieldType;
|
|
4176
|
+
}
|
|
4177
|
+
declare const f: (() => AxSignatureBuilder) & {
|
|
4178
|
+
string: (desc?: string) => AxFluentFieldType;
|
|
4179
|
+
number: (desc?: string) => AxFluentFieldType;
|
|
4180
|
+
boolean: (desc?: string) => AxFluentFieldType;
|
|
4181
|
+
json: (desc?: string) => AxFluentFieldType;
|
|
4182
|
+
datetime: (desc?: string) => AxFluentFieldType;
|
|
4183
|
+
date: (desc?: string) => AxFluentFieldType;
|
|
4184
|
+
class: <const TOptions extends readonly string[]>(options: TOptions, desc?: string) => AxFluentFieldType;
|
|
4185
|
+
image: (desc?: string) => AxFluentFieldType;
|
|
4186
|
+
audio: (desc?: string) => AxFluentFieldType;
|
|
4187
|
+
file: (desc?: string) => AxFluentFieldType;
|
|
4188
|
+
url: (desc?: string) => AxFluentFieldType;
|
|
4189
|
+
code: (language?: string, desc?: string) => AxFluentFieldType;
|
|
4190
|
+
array: <T extends AxFluentFieldInfo<any, any, any, any>>(baseType: T) => AxFluentFieldInfo<T["type"], true, T["options"], T["isOptional"]>;
|
|
4191
|
+
optional: <T extends AxFluentFieldInfo<any, any, any, any>>(baseType: T) => AxFluentFieldInfo<T["type"], T["isArray"], T["options"], true>;
|
|
4192
|
+
internal: <T extends AxFluentFieldInfo<any, any, any, any>>(baseType: T) => T & {
|
|
4193
|
+
readonly isInternal: true;
|
|
4194
|
+
};
|
|
4195
|
+
legacyArray: <T extends AxFieldType>(baseType: T) => T & {
|
|
4196
|
+
readonly isArray: true;
|
|
4197
|
+
};
|
|
4198
|
+
legacyOptional: <T extends AxFieldType>(baseType: T) => T & {
|
|
4199
|
+
readonly isOptional: true;
|
|
4200
|
+
};
|
|
4201
|
+
legacyInternal: <T extends AxFieldType>(baseType: T) => T & {
|
|
4202
|
+
readonly isInternal: true;
|
|
4203
|
+
};
|
|
4204
|
+
};
|
|
4205
|
+
interface AxField {
|
|
4206
|
+
name: string;
|
|
4207
|
+
title?: string;
|
|
4208
|
+
description?: string;
|
|
4209
|
+
type?: {
|
|
4210
|
+
name: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'file' | 'url' | 'date' | 'datetime' | 'class' | 'code';
|
|
4211
|
+
isArray?: boolean;
|
|
4212
|
+
options?: string[];
|
|
4213
|
+
};
|
|
4214
|
+
isOptional?: boolean;
|
|
4215
|
+
isInternal?: boolean;
|
|
4216
|
+
}
|
|
4217
|
+
type AxIField = Omit<AxField, 'title'> & {
|
|
4218
|
+
title: string;
|
|
4219
|
+
};
|
|
4220
|
+
type InferFieldValueType<T> = T extends AxFieldType | AxFluentFieldType ? T['type'] extends 'string' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'number' ? T['isArray'] extends true ? number[] : number : T['type'] extends 'boolean' ? T['isArray'] extends true ? boolean[] : boolean : T['type'] extends 'json' ? T['isArray'] extends true ? any[] : any : T['type'] extends 'date' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'datetime' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'image' ? T['isArray'] extends true ? {
|
|
4221
|
+
mimeType: string;
|
|
4222
|
+
data: string;
|
|
4223
|
+
}[] : {
|
|
4224
|
+
mimeType: string;
|
|
4225
|
+
data: string;
|
|
4226
|
+
} : T['type'] extends 'audio' ? T['isArray'] extends true ? {
|
|
4227
|
+
format?: 'wav';
|
|
4228
|
+
data: string;
|
|
4229
|
+
}[] : {
|
|
4230
|
+
format?: 'wav';
|
|
4231
|
+
data: string;
|
|
4232
|
+
} : T['type'] extends 'file' ? T['isArray'] extends true ? {
|
|
4233
|
+
mimeType: string;
|
|
4234
|
+
data: string;
|
|
4235
|
+
}[] : {
|
|
4236
|
+
mimeType: string;
|
|
4237
|
+
data: string;
|
|
4238
|
+
} : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any : any;
|
|
4239
|
+
interface AxFluentFieldInfo<TType extends AxFieldType['type'] = AxFieldType['type'], TIsArray extends boolean = false, TOptions extends readonly string[] = readonly string[], TIsOptional extends boolean = false> {
|
|
4240
|
+
readonly type: TType;
|
|
4241
|
+
readonly isArray?: TIsArray;
|
|
4242
|
+
readonly options?: TOptions;
|
|
4243
|
+
readonly description?: string;
|
|
4244
|
+
readonly isOptional?: TIsOptional;
|
|
4245
|
+
readonly isInternal?: boolean;
|
|
4246
|
+
}
|
|
4247
|
+
type InferFluentType<T extends AxFluentFieldInfo<any, any, any, any> | AxFluentFieldType> = T['type'] extends 'string' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'number' ? T['isArray'] extends true ? number[] : number : T['type'] extends 'boolean' ? T['isArray'] extends true ? boolean[] : boolean : T['type'] extends 'json' ? T['isArray'] extends true ? any[] : any : T['type'] extends 'date' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'datetime' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'image' ? T['isArray'] extends true ? {
|
|
4248
|
+
mimeType: string;
|
|
4249
|
+
data: string;
|
|
4250
|
+
}[] : {
|
|
4251
|
+
mimeType: string;
|
|
4252
|
+
data: string;
|
|
4253
|
+
} : T['type'] extends 'audio' ? T['isArray'] extends true ? {
|
|
4254
|
+
format?: 'wav';
|
|
4255
|
+
data: string;
|
|
4256
|
+
}[] : {
|
|
4257
|
+
format?: 'wav';
|
|
4258
|
+
data: string;
|
|
4259
|
+
} : T['type'] extends 'file' ? T['isArray'] extends true ? {
|
|
4260
|
+
mimeType: string;
|
|
4261
|
+
data: string;
|
|
4262
|
+
}[] : {
|
|
4263
|
+
mimeType: string;
|
|
4264
|
+
data: string;
|
|
4265
|
+
} : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any;
|
|
4266
|
+
interface AxSignatureConfig {
|
|
4267
|
+
description?: string;
|
|
4268
|
+
inputs: readonly AxField[];
|
|
4269
|
+
outputs: readonly AxField[];
|
|
4270
|
+
}
|
|
4271
|
+
declare class AxSignature<_TInput extends Record<string, any> = Record<string, any>, _TOutput extends Record<string, any> = Record<string, any>> {
|
|
4272
|
+
private description?;
|
|
4273
|
+
private inputFields;
|
|
4274
|
+
private outputFields;
|
|
4275
|
+
private sigHash;
|
|
4276
|
+
private sigString;
|
|
4277
|
+
private validatedAtHash?;
|
|
4278
|
+
/**
|
|
4279
|
+
* @deprecated Use `AxSignature.create()` for better type safety instead of the constructor.
|
|
4280
|
+
* This constructor will be removed in v15.0.0.
|
|
4281
|
+
*
|
|
4282
|
+
* Migration timeline:
|
|
4283
|
+
* - v13.0.24+: Deprecation warnings (current)
|
|
4284
|
+
* - v14.0.0: Runtime console warnings
|
|
4285
|
+
* - v15.0.0: Complete removal
|
|
4286
|
+
*
|
|
4287
|
+
* @example
|
|
4288
|
+
* ```typescript
|
|
4289
|
+
* // Instead of: new AxSignature('userInput:string -> responseText:string')
|
|
4290
|
+
* // Use: AxSignature.create('userInput:string -> responseText:string')
|
|
4291
|
+
* ```
|
|
4292
|
+
*/
|
|
4293
|
+
constructor(signature?: Readonly<AxSignature | string | AxSignatureConfig>);
|
|
4294
|
+
/**
|
|
4295
|
+
* Static factory method for type inference.
|
|
4296
|
+
* Creates a typed AxSignature instance from a signature string.
|
|
4297
|
+
*/
|
|
4298
|
+
static create<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
4299
|
+
private parseParsedField;
|
|
4300
|
+
private parseField;
|
|
4301
|
+
setDescription: (desc: string) => void;
|
|
4302
|
+
addInputField: (field: Readonly<AxField>) => void;
|
|
4303
|
+
addOutputField: (field: Readonly<AxField>) => void;
|
|
4304
|
+
setInputFields: (fields: readonly AxField[]) => void;
|
|
4305
|
+
setOutputFields: (fields: readonly AxField[]) => void;
|
|
4306
|
+
getInputFields: () => Readonly<AxIField[]>;
|
|
4307
|
+
getOutputFields: () => Readonly<AxIField[]>;
|
|
4308
|
+
getDescription: () => string | undefined;
|
|
4309
|
+
appendInputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<_TInput & Record<K, InferFieldValueType<T>>, _TOutput>;
|
|
4310
|
+
prependInputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<Record<K, InferFieldValueType<T>> & _TInput, _TOutput>;
|
|
4311
|
+
appendOutputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<_TInput, _TOutput & Record<K, InferFieldValueType<T>>>;
|
|
4312
|
+
prependOutputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<_TInput, Record<K, InferFieldValueType<T>> & _TOutput>;
|
|
4313
|
+
private invalidateValidationCache;
|
|
4314
|
+
private toTitle;
|
|
4315
|
+
toJSONSchema: () => AxFunctionJSONSchema;
|
|
4316
|
+
private updateHashLight;
|
|
4317
|
+
private updateHash;
|
|
4318
|
+
private validateSignatureConsistency;
|
|
4319
|
+
validate: () => boolean;
|
|
4320
|
+
hash: () => string;
|
|
4321
|
+
toString: () => string;
|
|
4322
|
+
toJSON: () => {
|
|
4323
|
+
id: string;
|
|
4324
|
+
description: string | undefined;
|
|
4325
|
+
inputFields: AxIField[];
|
|
4326
|
+
outputFields: AxIField[];
|
|
4327
|
+
};
|
|
4328
|
+
}
|
|
4329
|
+
|
|
3232
4330
|
interface AxAssertion {
|
|
3233
4331
|
fn(values: Record<string, unknown>): Promise<boolean | undefined> | boolean | undefined;
|
|
3234
4332
|
message?: string;
|
|
@@ -3271,7 +4369,7 @@ interface AxFieldProcessor {
|
|
|
3271
4369
|
process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
|
|
3272
4370
|
}
|
|
3273
4371
|
|
|
3274
|
-
declare class AxProgram<IN
|
|
4372
|
+
declare class AxProgram<IN, OUT> implements AxUsable {
|
|
3275
4373
|
protected signature: AxSignature;
|
|
3276
4374
|
protected sigHash: string;
|
|
3277
4375
|
protected examples?: OUT[];
|
|
@@ -3298,7 +4396,7 @@ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxU
|
|
|
3298
4396
|
setDemos(demos: readonly AxProgramDemos<IN, OUT>[]): void;
|
|
3299
4397
|
}
|
|
3300
4398
|
|
|
3301
|
-
type AxGenerateResult<OUT
|
|
4399
|
+
type AxGenerateResult<OUT> = OUT & {
|
|
3302
4400
|
thought?: string;
|
|
3303
4401
|
};
|
|
3304
4402
|
interface AxResponseHandlerArgs<T> {
|
|
@@ -3322,7 +4420,7 @@ interface AxStreamingEvent<T> {
|
|
|
3322
4420
|
functions?: AxChatResponseFunctionCall[];
|
|
3323
4421
|
};
|
|
3324
4422
|
}
|
|
3325
|
-
declare class AxGen<IN
|
|
4423
|
+
declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN, OUT> implements AxProgrammable<IN, OUT> {
|
|
3326
4424
|
private promptTemplate;
|
|
3327
4425
|
private asserts;
|
|
3328
4426
|
private streamingAsserts;
|
|
@@ -3332,7 +4430,7 @@ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOu
|
|
|
3332
4430
|
private streamingFieldProcessors;
|
|
3333
4431
|
private excludeContentFromTrace;
|
|
3334
4432
|
private thoughtFieldName;
|
|
3335
|
-
constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>, options?: Readonly<AxProgramForwardOptions<any>>);
|
|
4433
|
+
constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]> | AxSignature<any, any>, options?: Readonly<AxProgramForwardOptions<any>>);
|
|
3336
4434
|
private getSignatureName;
|
|
3337
4435
|
private getMetricsInstruments;
|
|
3338
4436
|
updateMeter(meter?: Meter): void;
|
|
@@ -3564,12 +4662,12 @@ type AxOptimizerLoggerData = {
|
|
|
3564
4662
|
type AxOptimizerLoggerFunction = (data: AxOptimizerLoggerData) => void;
|
|
3565
4663
|
|
|
3566
4664
|
type AxExample = Record<string, AxFieldValue>;
|
|
3567
|
-
type AxMetricFn = <T
|
|
4665
|
+
type AxMetricFn = <T = any>(arg0: Readonly<{
|
|
3568
4666
|
prediction: T;
|
|
3569
4667
|
example: AxExample;
|
|
3570
4668
|
}>) => number | Promise<number>;
|
|
3571
4669
|
type AxMetricFnArgs = Parameters<AxMetricFn>[0];
|
|
3572
|
-
type AxMultiMetricFn = <T
|
|
4670
|
+
type AxMultiMetricFn = <T = any>(arg0: Readonly<{
|
|
3573
4671
|
prediction: T;
|
|
3574
4672
|
example: AxExample;
|
|
3575
4673
|
}>) => Record<string, number>;
|
|
@@ -3625,6 +4723,28 @@ type AxOptimizerArgs = {
|
|
|
3625
4723
|
studentAI: AxAIService;
|
|
3626
4724
|
teacherAI?: AxAIService;
|
|
3627
4725
|
examples: readonly AxExample[];
|
|
4726
|
+
optimizerEndpoint?: string;
|
|
4727
|
+
optimizerTimeout?: number;
|
|
4728
|
+
optimizerRetries?: number;
|
|
4729
|
+
numCandidates?: number;
|
|
4730
|
+
initTemperature?: number;
|
|
4731
|
+
maxBootstrappedDemos?: number;
|
|
4732
|
+
maxLabeledDemos?: number;
|
|
4733
|
+
numTrials?: number;
|
|
4734
|
+
minibatch?: boolean;
|
|
4735
|
+
minibatchSize?: number;
|
|
4736
|
+
minibatchFullEvalSteps?: number;
|
|
4737
|
+
programAwareProposer?: boolean;
|
|
4738
|
+
dataAwareProposer?: boolean;
|
|
4739
|
+
viewDataBatchSize?: number;
|
|
4740
|
+
tipAwareProposer?: boolean;
|
|
4741
|
+
fewshotAwareProposer?: boolean;
|
|
4742
|
+
earlyStoppingTrials?: number;
|
|
4743
|
+
minImprovementThreshold?: number;
|
|
4744
|
+
bayesianOptimization?: boolean;
|
|
4745
|
+
acquisitionFunction?: 'expected_improvement' | 'upper_confidence_bound' | 'probability_improvement';
|
|
4746
|
+
explorationWeight?: number;
|
|
4747
|
+
sampleCount?: number;
|
|
3628
4748
|
validationSet?: readonly AxExample[];
|
|
3629
4749
|
minSuccessRate?: number;
|
|
3630
4750
|
targetScore?: number;
|
|
@@ -3717,17 +4837,17 @@ interface AxOptimizerMetricsInstruments {
|
|
|
3717
4837
|
}
|
|
3718
4838
|
declare const axUpdateOptimizerMetricsConfig: (config: Readonly<Partial<AxOptimizerMetricsConfig>>) => void;
|
|
3719
4839
|
declare const axGetOptimizerMetricsConfig: () => AxOptimizerMetricsConfig;
|
|
3720
|
-
interface AxOptimizerResult<OUT
|
|
3721
|
-
demos?: AxProgramDemos<
|
|
4840
|
+
interface AxOptimizerResult<OUT> {
|
|
4841
|
+
demos?: AxProgramDemos<any, OUT>[];
|
|
3722
4842
|
stats: AxOptimizationStats;
|
|
3723
4843
|
bestScore: number;
|
|
3724
4844
|
finalConfiguration?: Record<string, unknown>;
|
|
3725
4845
|
scoreHistory?: number[];
|
|
3726
4846
|
configurationHistory?: Record<string, unknown>[];
|
|
3727
4847
|
}
|
|
3728
|
-
interface AxParetoResult<OUT
|
|
4848
|
+
interface AxParetoResult<OUT = any> extends AxOptimizerResult<OUT> {
|
|
3729
4849
|
paretoFront: ReadonlyArray<{
|
|
3730
|
-
demos: readonly AxProgramDemos<
|
|
4850
|
+
demos: readonly AxProgramDemos<any, OUT>[];
|
|
3731
4851
|
scores: Readonly<Record<string, number>>;
|
|
3732
4852
|
configuration: Readonly<Record<string, unknown>>;
|
|
3733
4853
|
dominatedSolutions: number;
|
|
@@ -3751,7 +4871,7 @@ interface AxCompileOptions {
|
|
|
3751
4871
|
overrideCheckpointInterval?: number;
|
|
3752
4872
|
saveCheckpointOnComplete?: boolean;
|
|
3753
4873
|
}
|
|
3754
|
-
interface AxOptimizer<IN
|
|
4874
|
+
interface AxOptimizer<IN = any, OUT extends AxGenOut = any> {
|
|
3755
4875
|
/**
|
|
3756
4876
|
* Optimize a program using the provided metric function
|
|
3757
4877
|
* @param program The program to optimize (moved from constructor)
|
|
@@ -3852,11 +4972,11 @@ interface AxMiPROOptimizerOptions {
|
|
|
3852
4972
|
interface AxBootstrapCompileOptions extends AxCompileOptions {
|
|
3853
4973
|
validationExamples?: readonly AxExample[];
|
|
3854
4974
|
maxDemos?: number;
|
|
3855
|
-
teacherProgram?: Readonly<AxGen<
|
|
4975
|
+
teacherProgram?: Readonly<AxGen<any, any>>;
|
|
3856
4976
|
}
|
|
3857
4977
|
interface AxMiPROCompileOptions extends AxCompileOptions {
|
|
3858
4978
|
validationExamples?: readonly AxExample[];
|
|
3859
|
-
teacher?: Readonly<AxGen<
|
|
4979
|
+
teacher?: Readonly<AxGen<any, any>>;
|
|
3860
4980
|
auto?: 'light' | 'medium' | 'heavy';
|
|
3861
4981
|
instructionCandidates?: string[];
|
|
3862
4982
|
customProposer?: (context: Readonly<{
|
|
@@ -3883,7 +5003,7 @@ declare class AxDefaultCostTracker implements AxCostTracker {
|
|
|
3883
5003
|
* Abstract base class for optimizers that provides common functionality
|
|
3884
5004
|
* and standardized handling of AxOptimizerArgs
|
|
3885
5005
|
*/
|
|
3886
|
-
declare abstract class AxBaseOptimizer<IN
|
|
5006
|
+
declare abstract class AxBaseOptimizer<IN = any, OUT extends AxGenOut = any> implements AxOptimizer<IN, OUT> {
|
|
3887
5007
|
protected readonly studentAI: AxAIService;
|
|
3888
5008
|
protected readonly teacherAI?: AxAIService;
|
|
3889
5009
|
protected readonly examples: readonly AxExample[];
|
|
@@ -4206,7 +5326,7 @@ declare const axCreateDefaultOptimizerTextLogger: (output?: (message: string) =>
|
|
|
4206
5326
|
*/
|
|
4207
5327
|
declare const axDefaultOptimizerLogger: AxOptimizerLoggerFunction;
|
|
4208
5328
|
|
|
4209
|
-
declare class AxBootstrapFewShot<IN
|
|
5329
|
+
declare class AxBootstrapFewShot<IN = any, OUT extends AxGenOut = any> extends AxBaseOptimizer<IN, OUT> {
|
|
4210
5330
|
private maxRounds;
|
|
4211
5331
|
private maxDemos;
|
|
4212
5332
|
private maxExamples;
|
|
@@ -4249,9 +5369,8 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
|
|
|
4249
5369
|
private sampleCount;
|
|
4250
5370
|
private miproConfigHistory;
|
|
4251
5371
|
private surrogateModel;
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
}>);
|
|
5372
|
+
private pythonClient?;
|
|
5373
|
+
constructor(args: Readonly<AxOptimizerArgs>);
|
|
4255
5374
|
/**
|
|
4256
5375
|
* Configures the optimizer for light, medium, or heavy optimization
|
|
4257
5376
|
* @param level The optimization level: "light", "medium", or "heavy"
|
|
@@ -4333,6 +5452,10 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
|
|
|
4333
5452
|
* Encodes a configuration into a string key for surrogate model lookup
|
|
4334
5453
|
*/
|
|
4335
5454
|
private encodeConfiguration;
|
|
5455
|
+
/**
|
|
5456
|
+
* Simple string hash function for instruction content
|
|
5457
|
+
*/
|
|
5458
|
+
private hashString;
|
|
4336
5459
|
/**
|
|
4337
5460
|
* Updates the surrogate model with a new configuration-score pair
|
|
4338
5461
|
*/
|
|
@@ -4353,17 +5476,29 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
|
|
|
4353
5476
|
* Selects the next configuration to evaluate using Bayesian optimization
|
|
4354
5477
|
*/
|
|
4355
5478
|
private selectConfigurationViaBayesianOptimization;
|
|
5479
|
+
/**
|
|
5480
|
+
* Python-based compilation method
|
|
5481
|
+
*
|
|
5482
|
+
* This is a simplified implementation that demonstrates integration
|
|
5483
|
+
* with the Python optimizer service. For now, it focuses on basic
|
|
5484
|
+
* parameter optimization rather than full MiPRO functionality.
|
|
5485
|
+
*/
|
|
5486
|
+
private compilePython;
|
|
5487
|
+
/**
|
|
5488
|
+
* Simplified evaluation method for Python optimization
|
|
5489
|
+
*/
|
|
5490
|
+
private evaluateConfiguration;
|
|
4356
5491
|
}
|
|
4357
5492
|
|
|
4358
|
-
type AxInstanceRegistryItem<T extends AxTunable<IN, OUT>, IN
|
|
4359
|
-
declare class AxInstanceRegistry<T extends AxTunable<IN, OUT>, IN
|
|
5493
|
+
type AxInstanceRegistryItem<T extends AxTunable<IN, OUT>, IN, OUT> = T & AxUsable;
|
|
5494
|
+
declare class AxInstanceRegistry<T extends AxTunable<IN, OUT>, IN, OUT> {
|
|
4360
5495
|
private reg;
|
|
4361
5496
|
constructor();
|
|
4362
5497
|
register(instance: AxInstanceRegistryItem<T, IN, OUT>): void;
|
|
4363
5498
|
[Symbol.iterator](): Generator<AxInstanceRegistryItem<T, IN, OUT>, void, unknown>;
|
|
4364
5499
|
}
|
|
4365
5500
|
|
|
4366
|
-
interface AxSamplePickerOptions<OUT
|
|
5501
|
+
interface AxSamplePickerOptions<OUT> {
|
|
4367
5502
|
resultPicker?: AxResultPickerFunction<OUT>;
|
|
4368
5503
|
}
|
|
4369
5504
|
|
|
@@ -4379,45 +5514,8 @@ declare const AxStringUtil: {
|
|
|
4379
5514
|
batchArray: <T>(arr: readonly T[], size: number) => T[][];
|
|
4380
5515
|
};
|
|
4381
5516
|
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
readonly type: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'date' | 'datetime' | 'class' | 'code';
|
|
4385
|
-
readonly isArray?: boolean;
|
|
4386
|
-
readonly options?: readonly string[];
|
|
4387
|
-
readonly description?: string;
|
|
4388
|
-
readonly isOptional?: boolean;
|
|
4389
|
-
readonly isInternal?: boolean;
|
|
4390
|
-
}
|
|
4391
|
-
interface AxFieldDescriptor {
|
|
4392
|
-
readonly name: string;
|
|
4393
|
-
readonly type?: AxFieldType;
|
|
4394
|
-
readonly description?: string;
|
|
4395
|
-
readonly isOptional?: boolean;
|
|
4396
|
-
readonly isInternal?: boolean;
|
|
4397
|
-
}
|
|
4398
|
-
declare function s(strings: TemplateStringsArray, ...values: readonly AxSignatureTemplateValue[]): AxSignature;
|
|
4399
|
-
declare function ax<IN extends AxGenIn = AxGenIn, OUT extends AxGenerateResult<AxGenOut> = AxGenerateResult<AxGenOut>>(strings: TemplateStringsArray, ...values: readonly AxSignatureTemplateValue[]): AxGen<IN, OUT>;
|
|
4400
|
-
declare const f: {
|
|
4401
|
-
string: (desc?: string) => AxFieldType;
|
|
4402
|
-
number: (desc?: string) => AxFieldType;
|
|
4403
|
-
boolean: (desc?: string) => AxFieldType;
|
|
4404
|
-
date: (desc?: string) => AxFieldType;
|
|
4405
|
-
datetime: (desc?: string) => AxFieldType;
|
|
4406
|
-
json: (desc?: string) => AxFieldType;
|
|
4407
|
-
image: (desc?: string) => AxFieldType;
|
|
4408
|
-
audio: (desc?: string) => AxFieldType;
|
|
4409
|
-
class: (options: readonly string[], desc?: string) => AxFieldType;
|
|
4410
|
-
code: (language: string, desc?: string) => AxFieldType;
|
|
4411
|
-
array: <T extends AxFieldType>(baseType: T) => T & {
|
|
4412
|
-
readonly isArray: true;
|
|
4413
|
-
};
|
|
4414
|
-
optional: <T extends AxFieldType>(baseType: T) => T & {
|
|
4415
|
-
readonly isOptional: true;
|
|
4416
|
-
};
|
|
4417
|
-
internal: <T extends AxFieldType>(baseType: T) => T & {
|
|
4418
|
-
readonly isInternal: true;
|
|
4419
|
-
};
|
|
4420
|
-
};
|
|
5517
|
+
declare function s<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5518
|
+
declare function ax<const T extends string>(signature: T, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
4421
5519
|
|
|
4422
5520
|
/**
|
|
4423
5521
|
* Analyzes mapping functions to extract state dependencies.
|
|
@@ -4518,18 +5616,18 @@ interface AxFlowDynamicContext<T extends Readonly<AxAIService>> {
|
|
|
4518
5616
|
ai?: T;
|
|
4519
5617
|
options?: AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>;
|
|
4520
5618
|
}
|
|
4521
|
-
type GetGenIn<T extends AxProgrammable<
|
|
4522
|
-
type GetGenOut<T extends AxProgrammable<
|
|
4523
|
-
type InferAxGen<TSig extends string> =
|
|
5619
|
+
type GetGenIn<T extends AxProgrammable<any, any>> = T extends AxProgrammable<infer IN, any> ? IN : never;
|
|
5620
|
+
type GetGenOut<T extends AxProgrammable<any, any>> = T extends AxProgrammable<any, infer OUT> ? OUT : never;
|
|
5621
|
+
type InferAxGen<TSig extends string> = AxGen<ParseSignature<TSig>['inputs'], ParseSignature<TSig>['outputs']>;
|
|
4524
5622
|
type NodeResultKey<TNodeName extends string> = `${TNodeName}Result`;
|
|
4525
|
-
type AddNodeResult<TState extends AxFlowState, TNodeName extends string, TNodeOut
|
|
5623
|
+
type AddNodeResult<TState extends AxFlowState, TNodeName extends string, TNodeOut> = TState & {
|
|
4526
5624
|
[K in NodeResultKey<TNodeName>]: TNodeOut;
|
|
4527
5625
|
};
|
|
4528
5626
|
/**
|
|
4529
5627
|
* Interface for flows that can be tuned, executed, and used in compositions.
|
|
4530
5628
|
* Provides methods for building and executing complex AI workflows.
|
|
4531
5629
|
*/
|
|
4532
|
-
interface AxFlowable<IN
|
|
5630
|
+
interface AxFlowable<IN, OUT> extends AxProgrammable<IN, OUT> {
|
|
4533
5631
|
}
|
|
4534
5632
|
type AxFlowTypedParallelBranch<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> = (subFlow: AxFlowTypedSubContext<TNodes, TState>) => AxFlowTypedSubContext<TNodes, AxFlowState>;
|
|
4535
5633
|
interface AxFlowTypedSubContext<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> {
|
|
@@ -4791,6 +5889,92 @@ declare class AxFlowExecutionPlanner {
|
|
|
4791
5889
|
};
|
|
4792
5890
|
}
|
|
4793
5891
|
|
|
5892
|
+
/**
|
|
5893
|
+
* Data types for different AxFlow logging events
|
|
5894
|
+
*/
|
|
5895
|
+
interface AxFlowLoggerData {
|
|
5896
|
+
name: string;
|
|
5897
|
+
timestamp: number;
|
|
5898
|
+
[key: string]: unknown;
|
|
5899
|
+
}
|
|
5900
|
+
interface AxFlowStartData extends AxFlowLoggerData {
|
|
5901
|
+
name: 'FlowStart';
|
|
5902
|
+
inputFields: string[];
|
|
5903
|
+
totalSteps: number;
|
|
5904
|
+
parallelGroups: number;
|
|
5905
|
+
maxParallelism: number;
|
|
5906
|
+
autoParallelEnabled: boolean;
|
|
5907
|
+
}
|
|
5908
|
+
interface AxFlowStepStartData extends AxFlowLoggerData {
|
|
5909
|
+
name: 'StepStart';
|
|
5910
|
+
stepIndex: number;
|
|
5911
|
+
stepType: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive' | 'branch' | 'feedback' | 'while' | 'other';
|
|
5912
|
+
nodeName?: string;
|
|
5913
|
+
dependencies: string[];
|
|
5914
|
+
produces: string[];
|
|
5915
|
+
state: AxFlowState;
|
|
5916
|
+
}
|
|
5917
|
+
interface AxFlowStepCompleteData extends AxFlowLoggerData {
|
|
5918
|
+
name: 'StepComplete';
|
|
5919
|
+
stepIndex: number;
|
|
5920
|
+
stepType: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive' | 'branch' | 'feedback' | 'while' | 'other';
|
|
5921
|
+
nodeName?: string;
|
|
5922
|
+
executionTime: number;
|
|
5923
|
+
state: AxFlowState;
|
|
5924
|
+
newFields?: string[];
|
|
5925
|
+
result?: any;
|
|
5926
|
+
}
|
|
5927
|
+
interface AxFlowParallelGroupStartData extends AxFlowLoggerData {
|
|
5928
|
+
name: 'ParallelGroupStart';
|
|
5929
|
+
groupLevel: number;
|
|
5930
|
+
stepsCount: number;
|
|
5931
|
+
stepTypes: string[];
|
|
5932
|
+
}
|
|
5933
|
+
interface AxFlowParallelGroupCompleteData extends AxFlowLoggerData {
|
|
5934
|
+
name: 'ParallelGroupComplete';
|
|
5935
|
+
groupLevel: number;
|
|
5936
|
+
stepsCount: number;
|
|
5937
|
+
executionTime: number;
|
|
5938
|
+
}
|
|
5939
|
+
interface AxFlowBranchEvaluationData extends AxFlowLoggerData {
|
|
5940
|
+
name: 'BranchEvaluation';
|
|
5941
|
+
branchValue: unknown;
|
|
5942
|
+
hasMatchingBranch: boolean;
|
|
5943
|
+
branchStepsCount: number;
|
|
5944
|
+
}
|
|
5945
|
+
interface AxFlowCompleteData extends AxFlowLoggerData {
|
|
5946
|
+
name: 'FlowComplete';
|
|
5947
|
+
totalExecutionTime: number;
|
|
5948
|
+
finalState: AxFlowState;
|
|
5949
|
+
outputFields: string[];
|
|
5950
|
+
stepsExecuted: number;
|
|
5951
|
+
}
|
|
5952
|
+
interface AxFlowErrorData extends AxFlowLoggerData {
|
|
5953
|
+
name: 'FlowError';
|
|
5954
|
+
error: string;
|
|
5955
|
+
stepIndex?: number;
|
|
5956
|
+
stepType?: string;
|
|
5957
|
+
nodeName?: string;
|
|
5958
|
+
state?: AxFlowState;
|
|
5959
|
+
}
|
|
5960
|
+
type AxFlowLogData = AxFlowStartData | AxFlowStepStartData | AxFlowStepCompleteData | AxFlowParallelGroupStartData | AxFlowParallelGroupCompleteData | AxFlowBranchEvaluationData | AxFlowCompleteData | AxFlowErrorData;
|
|
5961
|
+
/**
|
|
5962
|
+
* Function type for AxFlow logging
|
|
5963
|
+
*/
|
|
5964
|
+
type AxFlowLoggerFunction = (data: AxFlowLogData) => void;
|
|
5965
|
+
/**
|
|
5966
|
+
* Factory function to create a colorized AxFlow logger
|
|
5967
|
+
*/
|
|
5968
|
+
declare const axCreateFlowColorLogger: (output?: (message: string) => void) => AxFlowLoggerFunction;
|
|
5969
|
+
/**
|
|
5970
|
+
* Factory function to create a text-only AxFlow logger (no colors)
|
|
5971
|
+
*/
|
|
5972
|
+
declare const axCreateFlowTextLogger: (output?: (message: string) => void) => AxFlowLoggerFunction;
|
|
5973
|
+
/**
|
|
5974
|
+
* Default AxFlow logger with colors
|
|
5975
|
+
*/
|
|
5976
|
+
declare const axDefaultFlowLogger: AxFlowLoggerFunction;
|
|
5977
|
+
|
|
4794
5978
|
/**
|
|
4795
5979
|
* AxFlow - A fluent, chainable API for building and orchestrating complex, stateful AI programs.
|
|
4796
5980
|
*
|
|
@@ -4809,7 +5993,7 @@ declare class AxFlowExecutionPlanner {
|
|
|
4809
5993
|
* const result = await flow.forward(ai, { topic: "AI safety" })
|
|
4810
5994
|
* ```
|
|
4811
5995
|
*/
|
|
4812
|
-
declare class AxFlow<IN extends
|
|
5996
|
+
declare class AxFlow<IN extends Record<string, any>, OUT, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, // Node registry for type tracking
|
|
4813
5997
|
TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
4814
5998
|
private readonly nodes;
|
|
4815
5999
|
private readonly flowDefinition;
|
|
@@ -4822,10 +6006,28 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4822
6006
|
private program?;
|
|
4823
6007
|
private nodeUsage;
|
|
4824
6008
|
private nodeTraces;
|
|
6009
|
+
private readonly flowLogger?;
|
|
6010
|
+
private readonly timingLogger?;
|
|
4825
6011
|
/**
|
|
4826
6012
|
* Converts a string to camelCase for valid field names
|
|
4827
6013
|
*/
|
|
4828
6014
|
private toCamelCase;
|
|
6015
|
+
/**
|
|
6016
|
+
* Executes a list of steps with comprehensive logging
|
|
6017
|
+
*/
|
|
6018
|
+
private executeStepsWithLogging;
|
|
6019
|
+
/**
|
|
6020
|
+
* Determines the type of a step function for logging purposes
|
|
6021
|
+
*/
|
|
6022
|
+
private getStepType;
|
|
6023
|
+
/**
|
|
6024
|
+
* Gets metadata about a step for logging purposes
|
|
6025
|
+
*/
|
|
6026
|
+
private getStepMetadata;
|
|
6027
|
+
/**
|
|
6028
|
+
* Extracts node name from step function source code
|
|
6029
|
+
*/
|
|
6030
|
+
private extractNodeNameFromSource;
|
|
4829
6031
|
/**
|
|
4830
6032
|
* Infers the signature of the flow based on the execution plan and node definitions.
|
|
4831
6033
|
* This is the core method that determines what input/output fields the flow should have
|
|
@@ -4849,7 +6051,20 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4849
6051
|
constructor(options?: {
|
|
4850
6052
|
autoParallel?: boolean;
|
|
4851
6053
|
batchSize?: number;
|
|
6054
|
+
logger?: AxFlowLoggerFunction;
|
|
6055
|
+
debug?: boolean;
|
|
4852
6056
|
});
|
|
6057
|
+
/**
|
|
6058
|
+
* Static factory method to create a new AxFlow instance with proper type safety
|
|
6059
|
+
* @param options - Optional configuration for the flow
|
|
6060
|
+
* @returns New AxFlow instance with type-safe defaults
|
|
6061
|
+
*/
|
|
6062
|
+
static create<IN extends Record<string, any> = Record<string, never>, OUT = {}, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, TState extends AxFlowState = IN>(options?: {
|
|
6063
|
+
autoParallel?: boolean;
|
|
6064
|
+
batchSize?: number;
|
|
6065
|
+
logger?: AxFlowLoggerFunction;
|
|
6066
|
+
debug?: boolean;
|
|
6067
|
+
}): AxFlow<IN, OUT, TNodes, TState>;
|
|
4853
6068
|
/**
|
|
4854
6069
|
* Initializes the program field every time something is added to the graph
|
|
4855
6070
|
*/
|
|
@@ -4942,7 +6157,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4942
6157
|
*
|
|
4943
6158
|
* @example
|
|
4944
6159
|
* ```
|
|
4945
|
-
* const sig =
|
|
6160
|
+
* const sig = s('text:string -> summary:string')
|
|
4946
6161
|
* flow.node('summarizer', sig, { temperature: 0.1 })
|
|
4947
6162
|
* ```
|
|
4948
6163
|
*/
|
|
@@ -5010,6 +6225,22 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
5010
6225
|
* ```
|
|
5011
6226
|
*/
|
|
5012
6227
|
map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
6228
|
+
/**
|
|
6229
|
+
* Applies an asynchronous transformation to the state object.
|
|
6230
|
+
* Returns a new AxFlow type with the evolved state.
|
|
6231
|
+
*
|
|
6232
|
+
* @param transform - Async function that takes the current state and returns a promise of new state
|
|
6233
|
+
* @returns New AxFlow instance with updated TState type
|
|
6234
|
+
*
|
|
6235
|
+
* @example
|
|
6236
|
+
* ```
|
|
6237
|
+
* flow.map(async state => ({
|
|
6238
|
+
* ...state,
|
|
6239
|
+
* apiResult: await fetchDataFromAPI(state.query)
|
|
6240
|
+
* }))
|
|
6241
|
+
* ```
|
|
6242
|
+
*/
|
|
6243
|
+
map<TNewState extends AxFlowState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
5013
6244
|
/**
|
|
5014
6245
|
* Applies a transformation to the state object with optional parallel execution.
|
|
5015
6246
|
* When parallel is enabled, the transform function should prepare data for parallel processing.
|
|
@@ -5032,16 +6263,65 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
5032
6263
|
map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
|
|
5033
6264
|
parallel: true;
|
|
5034
6265
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
5035
|
-
|
|
6266
|
+
/**
|
|
6267
|
+
* Applies async transformations to the state object with optional parallel execution.
|
|
6268
|
+
* When parallel is enabled, all async transforms are executed concurrently.
|
|
6269
|
+
*
|
|
6270
|
+
* @param transforms - Array of async transformation functions to apply in parallel
|
|
6271
|
+
* @param options - Options including parallel execution configuration
|
|
6272
|
+
* @returns New AxFlow instance with updated TState type
|
|
6273
|
+
*
|
|
6274
|
+
* @example
|
|
6275
|
+
* ```
|
|
6276
|
+
* // Parallel async map with multiple transforms
|
|
6277
|
+
* flow.map([
|
|
6278
|
+
* async state => ({ ...state, result1: await apiCall1(state.data) }),
|
|
6279
|
+
* async state => ({ ...state, result2: await apiCall2(state.data) }),
|
|
6280
|
+
* async state => ({ ...state, result3: await apiCall3(state.data) })
|
|
6281
|
+
* ], { parallel: true })
|
|
6282
|
+
* ```
|
|
6283
|
+
*/
|
|
6284
|
+
map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => Promise<TNewState>>, options: {
|
|
6285
|
+
parallel: true;
|
|
6286
|
+
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
6287
|
+
map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState | Promise<TNewState>, options?: {
|
|
5036
6288
|
parallel?: boolean;
|
|
5037
6289
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
5038
6290
|
/**
|
|
5039
|
-
* Short alias for map() - supports parallel option
|
|
6291
|
+
* Short alias for map() - supports parallel option and async functions
|
|
5040
6292
|
*/
|
|
5041
6293
|
m<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
6294
|
+
m<TNewState extends AxFlowState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
5042
6295
|
m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
|
|
5043
6296
|
parallel: true;
|
|
5044
6297
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
6298
|
+
m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => Promise<TNewState>>, options: {
|
|
6299
|
+
parallel: true;
|
|
6300
|
+
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
6301
|
+
/**
|
|
6302
|
+
* Terminal transformation that sets the final output type of the flow.
|
|
6303
|
+
* Use this as the last transformation to get proper type inference for the flow result.
|
|
6304
|
+
*
|
|
6305
|
+
* @param transform - Function that transforms the current state to the final output
|
|
6306
|
+
* @returns A new flow with the output type set to the transform result
|
|
6307
|
+
*
|
|
6308
|
+
* @example
|
|
6309
|
+
* ```typescript
|
|
6310
|
+
* const flow = flow<{ input: string }>()
|
|
6311
|
+
* .map(state => ({ ...state, processed: true }))
|
|
6312
|
+
* .returns(state => ({
|
|
6313
|
+
* result: state.processed ? "done" : "pending"
|
|
6314
|
+
* })) // TypeScript now knows the output is { result: string }
|
|
6315
|
+
* ```
|
|
6316
|
+
*/
|
|
6317
|
+
returns<TNewOut extends Record<string, unknown>>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;
|
|
6318
|
+
/**
|
|
6319
|
+
* Short alias for returns() - r() is to returns() as m() is to map()
|
|
6320
|
+
*
|
|
6321
|
+
* @param transform - Function that transforms the current state to the final output
|
|
6322
|
+
* @returns A new flow with the output type set to the transform result
|
|
6323
|
+
*/
|
|
6324
|
+
r<TNewOut extends Record<string, unknown>>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;
|
|
5045
6325
|
/**
|
|
5046
6326
|
* Labels a step for later reference (useful for feedback loops).
|
|
5047
6327
|
*
|
|
@@ -5280,7 +6560,146 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
5280
6560
|
groups?: AxFlowParallelGroup[];
|
|
5281
6561
|
};
|
|
5282
6562
|
getSignature(): AxSignature;
|
|
6563
|
+
/**
|
|
6564
|
+
* Creates a new AxFlow node from an existing signature by extending it with additional fields.
|
|
6565
|
+
*
|
|
6566
|
+
* @param name - The name of the new node
|
|
6567
|
+
* @param baseSignature - The base signature to extend (string or AxSignature)
|
|
6568
|
+
* @param extensions - Object defining how to extend the signature
|
|
6569
|
+
* @returns New AxFlow instance with the extended node
|
|
6570
|
+
*
|
|
6571
|
+
* @example
|
|
6572
|
+
* ```typescript
|
|
6573
|
+
* // Create a chain-of-thought node
|
|
6574
|
+
* flow.nodeExtended('reasoner', 'question:string -> answer:string', {
|
|
6575
|
+
* prependOutputs: [
|
|
6576
|
+
* { name: 'reasoning', type: f.internal(f.string('Step-by-step reasoning')) }
|
|
6577
|
+
* ]
|
|
6578
|
+
* })
|
|
6579
|
+
*
|
|
6580
|
+
* // Create a node with context and confidence
|
|
6581
|
+
* flow.nodeExtended('analyzer', 'input:string -> output:string', {
|
|
6582
|
+
* appendInputs: [{ name: 'context', type: f.optional(f.string('Context')) }],
|
|
6583
|
+
* appendOutputs: [{ name: 'confidence', type: f.number('Confidence score') }]
|
|
6584
|
+
* })
|
|
6585
|
+
* ```
|
|
6586
|
+
*/
|
|
6587
|
+
nodeExtended<TName extends string>(name: TName, baseSignature: string | AxSignature, extensions: {
|
|
6588
|
+
prependInputs?: Array<{
|
|
6589
|
+
name: string;
|
|
6590
|
+
type: AxFieldType;
|
|
6591
|
+
}>;
|
|
6592
|
+
appendInputs?: Array<{
|
|
6593
|
+
name: string;
|
|
6594
|
+
type: AxFieldType;
|
|
6595
|
+
}>;
|
|
6596
|
+
prependOutputs?: Array<{
|
|
6597
|
+
name: string;
|
|
6598
|
+
type: AxFieldType;
|
|
6599
|
+
}>;
|
|
6600
|
+
appendOutputs?: Array<{
|
|
6601
|
+
name: string;
|
|
6602
|
+
type: AxFieldType;
|
|
6603
|
+
}>;
|
|
6604
|
+
}): AxFlow<IN, OUT, TNodes & {
|
|
6605
|
+
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
6606
|
+
}, TState>;
|
|
6607
|
+
/**
|
|
6608
|
+
* Short alias for nodeExtended() - creates nodes with extended signatures
|
|
6609
|
+
*/
|
|
6610
|
+
nx<TName extends string>(name: TName, baseSignature: string | AxSignature, extensions: {
|
|
6611
|
+
prependInputs?: Array<{
|
|
6612
|
+
name: string;
|
|
6613
|
+
type: AxFieldType;
|
|
6614
|
+
}>;
|
|
6615
|
+
appendInputs?: Array<{
|
|
6616
|
+
name: string;
|
|
6617
|
+
type: AxFieldType;
|
|
6618
|
+
}>;
|
|
6619
|
+
prependOutputs?: Array<{
|
|
6620
|
+
name: string;
|
|
6621
|
+
type: AxFieldType;
|
|
6622
|
+
}>;
|
|
6623
|
+
appendOutputs?: Array<{
|
|
6624
|
+
name: string;
|
|
6625
|
+
type: AxFieldType;
|
|
6626
|
+
}>;
|
|
6627
|
+
}): AxFlow<IN, OUT, TNodes & {
|
|
6628
|
+
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
6629
|
+
}, TState>;
|
|
6630
|
+
/**
|
|
6631
|
+
* Applies a final transformation to the state object that updates both state and output type.
|
|
6632
|
+
* This is specifically designed for terminal transformations that shape the final output.
|
|
6633
|
+
*
|
|
6634
|
+
* @param transform - Function that takes the current state and returns the final output
|
|
6635
|
+
* @returns New AxFlow instance with updated OUT and TState types
|
|
6636
|
+
*
|
|
6637
|
+
* @example
|
|
6638
|
+
* ```
|
|
6639
|
+
* const result = await flow
|
|
6640
|
+
* .node('analyzer', 'userQuestion:string -> analysisResult:string')
|
|
6641
|
+
* .execute('analyzer', state => ({ userQuestion: state.userQuestion }))
|
|
6642
|
+
* .mapOutput(state => ({
|
|
6643
|
+
* // Note: Node results are typed as AxFieldValue, so you may need to cast
|
|
6644
|
+
* finalAnswer: state.analyzerResult.analysisResult as string
|
|
6645
|
+
* }))
|
|
6646
|
+
* .forward(ai, { userQuestion: 'test' });
|
|
6647
|
+
*
|
|
6648
|
+
* // result is typed as { finalAnswer: string }
|
|
6649
|
+
* ```
|
|
6650
|
+
*/
|
|
6651
|
+
mapOutput<TOutput>(transform: (_state: TState) => TOutput): AxFlow<IN, TOutput, TNodes, TOutput & TState>;
|
|
6652
|
+
/**
|
|
6653
|
+
* Short alias for mapOutput()
|
|
6654
|
+
*/
|
|
6655
|
+
mo<TOutput>(transform: (_state: TState) => TOutput): AxFlow<IN, TOutput, TNodes, TOutput & TState>;
|
|
5283
6656
|
}
|
|
6657
|
+
/**
|
|
6658
|
+
* Factory function to create a new AxFlow instance
|
|
6659
|
+
* Similar to ai() for AI services, this creates a fluent flow
|
|
6660
|
+
*
|
|
6661
|
+
* @param options - Optional configuration for the flow
|
|
6662
|
+
* @returns New AxFlow instance
|
|
6663
|
+
*
|
|
6664
|
+
* @example
|
|
6665
|
+
* ```typescript
|
|
6666
|
+
* // Input type is required - provides type safety throughout the flow
|
|
6667
|
+
* const workflow = flow<{ userInput: string }>()
|
|
6668
|
+
* .node('summarizer', 'documentText:string -> summaryText:string')
|
|
6669
|
+
* .execute('summarizer', state => ({ documentText: state.userInput }));
|
|
6670
|
+
*
|
|
6671
|
+
* // Complex input types work great for multi-field workflows
|
|
6672
|
+
* const complexFlow = flow<{ userQuestion: string; context: string }>()
|
|
6673
|
+
* .map(state => ({
|
|
6674
|
+
* ...state,
|
|
6675
|
+
* processedQuestion: state.userQuestion.toUpperCase() // TypeScript knows this exists!
|
|
6676
|
+
* }));
|
|
6677
|
+
* ```
|
|
6678
|
+
*/
|
|
6679
|
+
/**
|
|
6680
|
+
* Creates a new AxFlow instance with required input type specification.
|
|
6681
|
+
*
|
|
6682
|
+
* The input type must be specified upfront to enable proper type inference
|
|
6683
|
+
* throughout the flow construction and execution.
|
|
6684
|
+
*
|
|
6685
|
+
* @example
|
|
6686
|
+
* ```typescript
|
|
6687
|
+
* // ✅ Define input type upfront for better type safety
|
|
6688
|
+
* const workflow = flow<{ userInput: string, options?: any }>()
|
|
6689
|
+
* .map(state => ({ ...state, processedInput: state.userInput.toUpperCase() }))
|
|
6690
|
+
* .node('analyzer', 'processedInput:string -> result:string')
|
|
6691
|
+
*
|
|
6692
|
+
* // ✅ Simple input types work too
|
|
6693
|
+
* const simpleFlow = flow<{ documentText: string }>()
|
|
6694
|
+
* .node('summarizer', 'documentText:string -> summary:string')
|
|
6695
|
+
* ```
|
|
6696
|
+
*/
|
|
6697
|
+
declare function flow<TInput extends Record<string, any>, TOutput = {}>(options?: {
|
|
6698
|
+
autoParallel?: boolean;
|
|
6699
|
+
batchSize?: number;
|
|
6700
|
+
logger?: AxFlowLoggerFunction;
|
|
6701
|
+
debug?: boolean;
|
|
6702
|
+
}): AxFlow<TInput, TOutput, {}, TInput>;
|
|
5284
6703
|
|
|
5285
6704
|
/**
|
|
5286
6705
|
* Implementation of the sub-context for parallel execution
|
|
@@ -5662,6 +7081,29 @@ interface AxAgentFeatures {
|
|
|
5662
7081
|
/**
|
|
5663
7082
|
* An AI agent that can process inputs using an AI service and coordinate with child agents.
|
|
5664
7083
|
* Supports features like smart model routing and automatic input field passing to child agents.
|
|
7084
|
+
*
|
|
7085
|
+
* @deprecated Use the `agent()` factory function instead of instantiating this class directly.
|
|
7086
|
+
* The factory function provides better type inference and cleaner syntax.
|
|
7087
|
+
* This class will be removed in v15.0.0.
|
|
7088
|
+
*
|
|
7089
|
+
* Migration timeline:
|
|
7090
|
+
* - v13.0.24+: Deprecation warnings (current)
|
|
7091
|
+
* - v14.0.0: Runtime console warnings
|
|
7092
|
+
* - v15.0.0: Complete removal
|
|
7093
|
+
*
|
|
7094
|
+
* @example
|
|
7095
|
+
* // Old (deprecated):
|
|
7096
|
+
* const myAgent = new AxAgent({
|
|
7097
|
+
* name: 'myAgent',
|
|
7098
|
+
* description: 'An agent that does something',
|
|
7099
|
+
* signature: 'userInput:string -> responseText:string'
|
|
7100
|
+
* });
|
|
7101
|
+
*
|
|
7102
|
+
* // New (recommended):
|
|
7103
|
+
* const myAgent = agent('userInput:string -> responseText:string', {
|
|
7104
|
+
* name: 'myAgent',
|
|
7105
|
+
* description: 'An agent that does something'
|
|
7106
|
+
* });
|
|
5665
7107
|
*/
|
|
5666
7108
|
declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAgentic<IN, OUT> {
|
|
5667
7109
|
private ai?;
|
|
@@ -5682,6 +7124,28 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
5682
7124
|
agents?: AxAgentic<IN, OUT>[];
|
|
5683
7125
|
functions?: AxInputFunctionType;
|
|
5684
7126
|
}>, options?: Readonly<AxAgentOptions>);
|
|
7127
|
+
/**
|
|
7128
|
+
* Creates a new AxAgent instance with type-safe signature parsing.
|
|
7129
|
+
* This is the recommended way to create agents with string-based signatures.
|
|
7130
|
+
*
|
|
7131
|
+
* @param signature - The signature string defining input/output fields
|
|
7132
|
+
* @param config - Agent configuration including name, description, etc.
|
|
7133
|
+
* @returns A new AxAgent instance with inferred types
|
|
7134
|
+
*
|
|
7135
|
+
* @example
|
|
7136
|
+
* ```typescript
|
|
7137
|
+
* const agent = AxAgent.create(
|
|
7138
|
+
* 'userInput:string "User question" -> responseText:string "Agent response"',
|
|
7139
|
+
* {
|
|
7140
|
+
* name: 'helpfulAgent',
|
|
7141
|
+
* description: 'An agent that provides helpful responses to user questions',
|
|
7142
|
+
* definition: 'You are a helpful assistant that provides clear, accurate responses to user questions.',
|
|
7143
|
+
* ai: llm
|
|
7144
|
+
* }
|
|
7145
|
+
* );
|
|
7146
|
+
* ```
|
|
7147
|
+
*/
|
|
7148
|
+
static create<const T extends string>(signature: T, config: AxAgentConfig<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>): AxAgent<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5685
7149
|
setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;
|
|
5686
7150
|
setId(id: string): void;
|
|
5687
7151
|
setParentId(parentId: string): void;
|
|
@@ -5713,35 +7177,220 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
5713
7177
|
setSignature(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>): void;
|
|
5714
7178
|
private getDebug;
|
|
5715
7179
|
}
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
7180
|
+
/**
|
|
7181
|
+
* Configuration options for creating an agent using the agent() factory function.
|
|
7182
|
+
*/
|
|
7183
|
+
interface AxAgentConfig<IN extends AxGenIn, OUT extends AxGenOut> extends AxAgentOptions {
|
|
7184
|
+
ai?: AxAIService;
|
|
7185
|
+
name: string;
|
|
7186
|
+
description: string;
|
|
7187
|
+
definition?: string;
|
|
7188
|
+
agents?: AxAgentic<IN, OUT>[];
|
|
7189
|
+
functions?: AxInputFunctionType;
|
|
5721
7190
|
}
|
|
7191
|
+
/**
|
|
7192
|
+
* Creates a strongly-typed AI agent from a string signature.
|
|
7193
|
+
* This is the recommended way to create agents, providing better type inference and cleaner syntax.
|
|
7194
|
+
*
|
|
7195
|
+
* @param signature - The input/output signature as a string (e.g., "userInput:string -> responseText:string")
|
|
7196
|
+
* @param config - Configuration options for the agent
|
|
7197
|
+
* @returns A typed agent instance
|
|
7198
|
+
*
|
|
7199
|
+
* @example
|
|
7200
|
+
* ```typescript
|
|
7201
|
+
* const myAgent = agent('userInput:string -> responseText:string', {
|
|
7202
|
+
* name: 'myAgent',
|
|
7203
|
+
* description: 'An agent that processes user input and returns a response',
|
|
7204
|
+
* definition: 'You are a helpful assistant that responds to user queries...'
|
|
7205
|
+
* });
|
|
7206
|
+
*
|
|
7207
|
+
* // With child agents
|
|
7208
|
+
* const parentAgent = agent('taskDescription:string -> completedTask:string', {
|
|
7209
|
+
* name: 'parentAgent',
|
|
7210
|
+
* description: 'Coordinates child agents to complete tasks',
|
|
7211
|
+
* agents: [childAgent1, childAgent2]
|
|
7212
|
+
* });
|
|
7213
|
+
*
|
|
7214
|
+
* // Type-safe usage
|
|
7215
|
+
* const result = await myAgent.forward(ai, { userInput: 'Hello!' });
|
|
7216
|
+
* console.log(result.responseText); // TypeScript knows this exists
|
|
7217
|
+
* ```
|
|
7218
|
+
*/
|
|
7219
|
+
declare function agent<const T extends string>(signature: T, config: AxAgentConfig<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>): AxAgent<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5722
7220
|
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
7221
|
+
/**
|
|
7222
|
+
* Advanced Multi-hop RAG with iterative query refinement, context accumulation,
|
|
7223
|
+
* parallel sub-queries, and self-healing quality feedback loops
|
|
7224
|
+
*
|
|
7225
|
+
* @param queryFn - Function to execute search queries and return results
|
|
7226
|
+
* @param options - Configuration options
|
|
7227
|
+
* @returns AxFlow instance with advanced RAG capability
|
|
7228
|
+
*/
|
|
7229
|
+
declare const axRAG: (queryFn: (query: string) => Promise<string>, options?: {
|
|
7230
|
+
maxHops?: number;
|
|
7231
|
+
qualityThreshold?: number;
|
|
7232
|
+
maxIterations?: number;
|
|
7233
|
+
qualityTarget?: number;
|
|
7234
|
+
disableQualityHealing?: boolean;
|
|
7235
|
+
logger?: AxFlowLoggerFunction;
|
|
7236
|
+
debug?: boolean;
|
|
7237
|
+
}) => AxFlow<{
|
|
7238
|
+
originalQuestion: string;
|
|
5726
7239
|
}, {
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
7240
|
+
finalAnswer: string;
|
|
7241
|
+
totalHops: number;
|
|
7242
|
+
retrievedContexts: string[];
|
|
7243
|
+
iterationCount: number;
|
|
7244
|
+
healingAttempts: number;
|
|
7245
|
+
qualityAchieved: number;
|
|
7246
|
+
}, {
|
|
7247
|
+
queryGenerator: InferAxGen<"originalQuestion:string, previousContext?:string -> searchQuery:string, queryReasoning:string">;
|
|
7248
|
+
} & {
|
|
7249
|
+
contextualizer: InferAxGen<"retrievedDocument:string, accumulatedContext?:string -> enhancedContext:string">;
|
|
7250
|
+
} & {
|
|
7251
|
+
qualityAssessor: InferAxGen<"currentContext:string, originalQuestion:string -> completenessScore:number, missingAspects:string[]">;
|
|
7252
|
+
} & {
|
|
7253
|
+
questionDecomposer: InferAxGen<"complexQuestion:string -> subQuestions:string[], decompositionReason:string">;
|
|
7254
|
+
} & {
|
|
7255
|
+
evidenceSynthesizer: InferAxGen<"collectedEvidence:string[], originalQuestion:string -> synthesizedEvidence:string, evidenceGaps:string[]">;
|
|
7256
|
+
} & {
|
|
7257
|
+
gapAnalyzer: InferAxGen<"synthesizedEvidence:string, evidenceGaps:string[], originalQuestion:string -> needsMoreInfo:boolean, focusedQueries:string[]">;
|
|
7258
|
+
} & {
|
|
7259
|
+
answerGenerator: InferAxGen<"finalContext:string, originalQuestion:string -> comprehensiveAnswer:string, confidenceLevel:number">;
|
|
7260
|
+
} & {
|
|
7261
|
+
queryRefiner: InferAxGen<"originalQuestion:string, currentContext:string, missingAspects:string[] -> refinedQuery:string">;
|
|
7262
|
+
} & {
|
|
7263
|
+
qualityValidator: InferAxGen<"generatedAnswer:string, userQuery:string -> qualityScore:number, issues:string[]">;
|
|
7264
|
+
} & {
|
|
7265
|
+
answerHealer: InferAxGen<"originalAnswer:string, healingDocument:string, issues?:string[] -> healedAnswer:string">;
|
|
7266
|
+
}, {
|
|
7267
|
+
currentAnswer: string;
|
|
7268
|
+
currentQuality: number;
|
|
7269
|
+
currentIssues: string[];
|
|
7270
|
+
shouldContinueHealing: boolean;
|
|
7271
|
+
healingResult: {
|
|
7272
|
+
healingDocument: string;
|
|
7273
|
+
};
|
|
7274
|
+
healingAttempts: number;
|
|
7275
|
+
allEvidence: string[];
|
|
7276
|
+
evidenceSources: string[];
|
|
7277
|
+
needsMoreInfo: boolean;
|
|
7278
|
+
synthesizedEvidence: string;
|
|
7279
|
+
retrievalResults: string[];
|
|
7280
|
+
currentQueries: string[];
|
|
7281
|
+
iteration: number;
|
|
7282
|
+
searchQuery: string;
|
|
7283
|
+
accumulatedContext: string;
|
|
7284
|
+
retrievedContexts: string[];
|
|
7285
|
+
completenessScore: number;
|
|
7286
|
+
shouldContinue: boolean;
|
|
7287
|
+
retrievalResult: {
|
|
7288
|
+
retrievedDocument: string;
|
|
7289
|
+
retrievalConfidence: number;
|
|
7290
|
+
};
|
|
7291
|
+
currentHop: number;
|
|
7292
|
+
maxHops: number;
|
|
7293
|
+
qualityThreshold: number;
|
|
7294
|
+
maxIterations: number;
|
|
7295
|
+
qualityTarget: number;
|
|
7296
|
+
disableQualityHealing: boolean;
|
|
7297
|
+
originalQuestion: string;
|
|
7298
|
+
queryGeneratorResult: BuildObject<[{
|
|
7299
|
+
name: "searchQuery";
|
|
7300
|
+
optional: false;
|
|
7301
|
+
} & {
|
|
7302
|
+
type: "string";
|
|
7303
|
+
}, {
|
|
7304
|
+
name: "queryReasoning";
|
|
7305
|
+
optional: false;
|
|
7306
|
+
} & {
|
|
7307
|
+
type: "string";
|
|
7308
|
+
}]>;
|
|
7309
|
+
contextualizerResult: BuildObject<[{
|
|
7310
|
+
name: "enhancedContext";
|
|
7311
|
+
optional: false;
|
|
7312
|
+
} & {
|
|
7313
|
+
type: "string";
|
|
7314
|
+
}]>;
|
|
7315
|
+
qualityAssessorResult: BuildObject<[{
|
|
7316
|
+
name: "completenessScore";
|
|
7317
|
+
optional: false;
|
|
7318
|
+
} & {
|
|
7319
|
+
type: "number";
|
|
7320
|
+
}, {
|
|
7321
|
+
name: "missingAspects";
|
|
7322
|
+
optional: false;
|
|
7323
|
+
} & {
|
|
7324
|
+
type: "string[]";
|
|
7325
|
+
}]>;
|
|
7326
|
+
queryRefinerResult: BuildObject<[{
|
|
7327
|
+
name: "refinedQuery";
|
|
7328
|
+
optional: false;
|
|
7329
|
+
} & {
|
|
7330
|
+
type: "string";
|
|
7331
|
+
}]>;
|
|
7332
|
+
questionDecomposerResult: BuildObject<[{
|
|
7333
|
+
name: "subQuestions";
|
|
7334
|
+
optional: false;
|
|
7335
|
+
} & {
|
|
7336
|
+
type: "string[]";
|
|
7337
|
+
}, {
|
|
7338
|
+
name: "decompositionReason";
|
|
7339
|
+
optional: false;
|
|
7340
|
+
} & {
|
|
7341
|
+
type: "string";
|
|
7342
|
+
}]>;
|
|
7343
|
+
evidenceSynthesizerResult: BuildObject<[{
|
|
7344
|
+
name: "synthesizedEvidence";
|
|
7345
|
+
optional: false;
|
|
7346
|
+
} & {
|
|
7347
|
+
type: "string";
|
|
7348
|
+
}, {
|
|
7349
|
+
name: "evidenceGaps";
|
|
7350
|
+
optional: false;
|
|
7351
|
+
} & {
|
|
7352
|
+
type: "string[]";
|
|
7353
|
+
}]>;
|
|
7354
|
+
gapAnalyzerResult: BuildObject<[{
|
|
7355
|
+
name: "needsMoreInfo";
|
|
7356
|
+
optional: false;
|
|
7357
|
+
} & {
|
|
7358
|
+
type: "boolean";
|
|
7359
|
+
}, {
|
|
7360
|
+
name: "focusedQueries";
|
|
7361
|
+
optional: false;
|
|
7362
|
+
} & {
|
|
7363
|
+
type: "string[]";
|
|
7364
|
+
}]>;
|
|
7365
|
+
answerGeneratorResult: BuildObject<[{
|
|
7366
|
+
name: "comprehensiveAnswer";
|
|
7367
|
+
optional: false;
|
|
7368
|
+
} & {
|
|
7369
|
+
type: "string";
|
|
7370
|
+
}, {
|
|
7371
|
+
name: "confidenceLevel";
|
|
7372
|
+
optional: false;
|
|
7373
|
+
} & {
|
|
7374
|
+
type: "number";
|
|
7375
|
+
}]>;
|
|
7376
|
+
qualityValidatorResult: BuildObject<[{
|
|
7377
|
+
name: "qualityScore";
|
|
7378
|
+
optional: false;
|
|
7379
|
+
} & {
|
|
7380
|
+
type: "number";
|
|
7381
|
+
}, {
|
|
7382
|
+
name: "issues";
|
|
7383
|
+
optional: false;
|
|
7384
|
+
} & {
|
|
7385
|
+
type: "string[]";
|
|
7386
|
+
}]>;
|
|
7387
|
+
answerHealerResult: BuildObject<[{
|
|
7388
|
+
name: "healedAnswer";
|
|
7389
|
+
optional: false;
|
|
7390
|
+
} & {
|
|
7391
|
+
type: "string";
|
|
7392
|
+
}]>;
|
|
7393
|
+
}>;
|
|
5745
7394
|
|
|
5746
7395
|
declare const axSpanAttributes: {
|
|
5747
7396
|
LLM_SYSTEM: string;
|
|
@@ -5814,4 +7463,4 @@ declare class AxRateLimiterTokenUsage {
|
|
|
5814
7463
|
acquire(tokens: number): Promise<void>;
|
|
5815
7464
|
}
|
|
5816
7465
|
|
|
5817
|
-
export { AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicErrorEvent, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicPingEvent, type AxAIAnthropicThinkingConfig, type AxAIAnthropicThinkingTokenBudgetLevels, AxAIAnthropicVertexModel, type AxAIArgs, AxAIAzureOpenAI, type AxAIAzureOpenAIArgs, type AxAIAzureOpenAIConfig, AxAICohere, type AxAICohereArgs, type AxAICohereChatRequest, type AxAICohereChatRequestToolResults, type AxAICohereChatResponse, type AxAICohereChatResponseDelta, type AxAICohereChatResponseToolCalls, type AxAICohereConfig, AxAICohereEmbedModel, type AxAICohereEmbedRequest, type AxAICohereEmbedResponse, AxAICohereModel, AxAIDeepSeek, type AxAIDeepSeekArgs, AxAIDeepSeekModel, type AxAIEmbedModels, type AxAIFeatures, AxAIGoogleGemini, type AxAIGoogleGeminiArgs, type AxAIGoogleGeminiBatchEmbedRequest, type AxAIGoogleGeminiBatchEmbedResponse, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, type AxAIGoogleGeminiContentPart, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiEmbedTypes, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiThinkingConfig, type AxAIGoogleGeminiThinkingTokenBudgetLevels, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleSearchRetrieval, type AxAIGoogleVertexBatchEmbedRequest, type AxAIGoogleVertexBatchEmbedResponse, AxAIGrok, type AxAIGrokArgs, type AxAIGrokChatRequest, AxAIGrokEmbedModels, AxAIGrokModel, type AxAIGrokOptionsTools, type AxAIGrokSearchSource, AxAIGroq, type AxAIGroqArgs, AxAIGroqModel, AxAIHuggingFace, type AxAIHuggingFaceArgs, type AxAIHuggingFaceConfig, AxAIHuggingFaceModel, type AxAIHuggingFaceRequest, type AxAIHuggingFaceResponse, type AxAIInputModelList, type AxAIMemory, type AxAIMetricsInstruments, AxAIMistral, type AxAIMistralArgs, type AxAIMistralChatRequest, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelList, type AxAIModelListBase, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIAnnotation, type AxAIOpenAIArgs, AxAIOpenAIBase, type AxAIOpenAIBaseArgs, type AxAIOpenAIChatRequest, type AxAIOpenAIChatResponse, type AxAIOpenAIChatResponseDelta, type AxAIOpenAIConfig, AxAIOpenAIEmbedModel, type AxAIOpenAIEmbedRequest, type AxAIOpenAIEmbedResponse, type AxAIOpenAILogprob, AxAIOpenAIModel, type AxAIOpenAIResponseDelta, AxAIOpenAIResponses, type AxAIOpenAIResponsesArgs, AxAIOpenAIResponsesBase, type AxAIOpenAIResponsesCodeInterpreterToolCall, type AxAIOpenAIResponsesComputerToolCall, type AxAIOpenAIResponsesConfig, type AxAIOpenAIResponsesContentPartAddedEvent, type AxAIOpenAIResponsesContentPartDoneEvent, type AxAIOpenAIResponsesDefineFunctionTool, type AxAIOpenAIResponsesErrorEvent, type AxAIOpenAIResponsesFileSearchCallCompletedEvent, type AxAIOpenAIResponsesFileSearchCallInProgressEvent, type AxAIOpenAIResponsesFileSearchCallSearchingEvent, type AxAIOpenAIResponsesFileSearchToolCall, type AxAIOpenAIResponsesFunctionCallArgumentsDeltaEvent, type AxAIOpenAIResponsesFunctionCallArgumentsDoneEvent, type AxAIOpenAIResponsesFunctionCallItem, type AxAIOpenAIResponsesImageGenerationCallCompletedEvent, type AxAIOpenAIResponsesImageGenerationCallGeneratingEvent, type AxAIOpenAIResponsesImageGenerationCallInProgressEvent, type AxAIOpenAIResponsesImageGenerationCallPartialImageEvent, type AxAIOpenAIResponsesImageGenerationToolCall, AxAIOpenAIResponsesImpl, type AxAIOpenAIResponsesInputAudioContentPart, type AxAIOpenAIResponsesInputContentPart, type AxAIOpenAIResponsesInputFunctionCallItem, type AxAIOpenAIResponsesInputFunctionCallOutputItem, type AxAIOpenAIResponsesInputImageUrlContentPart, type AxAIOpenAIResponsesInputItem, type AxAIOpenAIResponsesInputMessageItem, type AxAIOpenAIResponsesInputTextContentPart, type AxAIOpenAIResponsesLocalShellToolCall, type AxAIOpenAIResponsesMCPCallArgumentsDeltaEvent, type AxAIOpenAIResponsesMCPCallArgumentsDoneEvent, type AxAIOpenAIResponsesMCPCallCompletedEvent, type AxAIOpenAIResponsesMCPCallFailedEvent, type AxAIOpenAIResponsesMCPCallInProgressEvent, type AxAIOpenAIResponsesMCPListToolsCompletedEvent, type AxAIOpenAIResponsesMCPListToolsFailedEvent, type AxAIOpenAIResponsesMCPListToolsInProgressEvent, type AxAIOpenAIResponsesMCPToolCall, AxAIOpenAIResponsesModel, type AxAIOpenAIResponsesOutputItem, type AxAIOpenAIResponsesOutputItemAddedEvent, type AxAIOpenAIResponsesOutputItemDoneEvent, type AxAIOpenAIResponsesOutputMessageItem, type AxAIOpenAIResponsesOutputRefusalContentPart, type AxAIOpenAIResponsesOutputTextAnnotationAddedEvent, type AxAIOpenAIResponsesOutputTextContentPart, type AxAIOpenAIResponsesOutputTextDeltaEvent, type AxAIOpenAIResponsesOutputTextDoneEvent, type AxAIOpenAIResponsesReasoningDeltaEvent, type AxAIOpenAIResponsesReasoningDoneEvent, type AxAIOpenAIResponsesReasoningItem, type AxAIOpenAIResponsesReasoningSummaryDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryDoneEvent, type AxAIOpenAIResponsesReasoningSummaryPart, type AxAIOpenAIResponsesReasoningSummaryPartAddedEvent, type AxAIOpenAIResponsesReasoningSummaryPartDoneEvent, type AxAIOpenAIResponsesReasoningSummaryTextDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryTextDoneEvent, type AxAIOpenAIResponsesRefusalDeltaEvent, type AxAIOpenAIResponsesRefusalDoneEvent, type AxAIOpenAIResponsesRequest, type AxAIOpenAIResponsesResponse, type AxAIOpenAIResponsesResponseCompletedEvent, type AxAIOpenAIResponsesResponseCreatedEvent, type AxAIOpenAIResponsesResponseDelta, type AxAIOpenAIResponsesResponseFailedEvent, type AxAIOpenAIResponsesResponseInProgressEvent, type AxAIOpenAIResponsesResponseIncompleteEvent, type AxAIOpenAIResponsesResponseQueuedEvent, type AxAIOpenAIResponsesStreamEvent, type AxAIOpenAIResponsesStreamEventBase, type AxAIOpenAIResponsesToolCall, type AxAIOpenAIResponsesToolCallBase, type AxAIOpenAIResponsesToolChoice, type AxAIOpenAIResponsesToolDefinition, type AxAIOpenAIResponsesWebSearchCallCompletedEvent, type AxAIOpenAIResponsesWebSearchCallInProgressEvent, type AxAIOpenAIResponsesWebSearchCallSearchingEvent, type AxAIOpenAIResponsesWebSearchToolCall, type AxAIOpenAIUrlCitation, type AxAIOpenAIUsage, AxAIRefusalError, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, AxAIServiceAbortedError, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, type AxAIServiceModelType, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, AxAIWebLLM, type AxAIWebLLMArgs, type AxAIWebLLMChatRequest, type AxAIWebLLMChatResponse, type AxAIWebLLMChatResponseDelta, type AxAIWebLLMConfig, type AxAIWebLLMEmbedModel, type AxAIWebLLMEmbedRequest, type AxAIWebLLMEmbedResponse, AxAIWebLLMModel, type AxAPI, type AxAPIConfig, AxAgent, type AxAgentFeatures, type AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBaseOptimizer, type AxBootstrapCompileOptions, AxBootstrapFewShot, type AxBootstrapOptimizerOptions, AxChainOfThought, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, type AxCheckpointLoadFn, type AxCheckpointSaveFn, type AxCompileOptions, type AxCostTracker, type AxCostTrackerOptions, AxDB, type AxDBArgs, AxDBBase, type AxDBBaseArgs, type AxDBBaseOpOptions, AxDBCloudflare, type AxDBCloudflareArgs, type AxDBCloudflareOpOptions, type AxDBLoaderOptions, AxDBManager, type AxDBManagerArgs, type AxDBMatch, AxDBMemory, type AxDBMemoryArgs, type AxDBMemoryOpOptions, AxDBPinecone, type AxDBPineconeArgs, type AxDBPineconeOpOptions, type AxDBQueryRequest, type AxDBQueryResponse, type AxDBQueryService, type AxDBService, type AxDBState, type AxDBUpsertRequest, type AxDBUpsertResponse, AxDBWeaviate, type AxDBWeaviateArgs, type AxDBWeaviateOpOptions, type AxDataRow, AxDefaultCostTracker, AxDefaultResultReranker, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, type AxErrorCategory, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldDescriptor, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldType, type AxFieldValue, AxFlow, type AxFlowAutoParallelConfig, type AxFlowBranchContext, AxFlowDependencyAnalyzer, type AxFlowDynamicContext, AxFlowExecutionPlanner, type AxFlowExecutionStep, type AxFlowNodeDefinition, type AxFlowParallelBranch, type AxFlowParallelGroup, type AxFlowState, type AxFlowStepFunction, type AxFlowSubContext, AxFlowSubContextImpl, type AxFlowTypedParallelBranch, type AxFlowTypedSubContext, AxFlowTypedSubContextImpl, type AxFlowable, type AxForwardable, type AxFunction, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, type AxFunctionResult, type AxFunctionResultFormatter, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenMetricsInstruments, type AxGenOut, type AxGenStreamingOut, AxGenerateError, type AxGenerateErrorDetails, type AxGenerateResult, AxHFDataLoader, type AxIField, type AxInputFunctionType, AxInstanceRegistry, type AxInternalChatRequest, type AxInternalEmbedRequest, AxLLMRequestTypeValues, type AxLoggerData, type AxLoggerFunction, AxMCPClient, type AxMCPFunctionDescription, AxMCPHTTPSSETransport, type AxMCPInitializeParams, type AxMCPInitializeResult, type AxMCPJSONRPCErrorResponse, type AxMCPJSONRPCNotification, type AxMCPJSONRPCRequest, type AxMCPJSONRPCResponse, type AxMCPJSONRPCSuccessResponse, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, type AxMCPToolsListResult, type AxMCPTransport, AxMemory, type AxMemoryData, type AxMessage, type AxMetricFn, type AxMetricFnArgs, type AxMetricsConfig, AxMiPRO, type AxMiPROCompileOptions, type AxMiPROOptimizerOptions, type AxMiPROResult, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, type AxModelUsage, type AxMultiMetricFn, AxMultiServiceRouter, type AxOptimizationCheckpoint, type AxOptimizationProgress, type AxOptimizationStats, type AxOptimizer, type AxOptimizerArgs, type AxOptimizerLoggerData, type AxOptimizerLoggerFunction, type AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramForwardOptionsWithModels, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramStreamingForwardOptionsWithModels, type AxProgramTrace, type AxProgramUsage, type AxProgrammable, AxPromptTemplate, type AxPromptTemplateOptions, AxRAG, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, type AxRerankerIn, type AxRerankerOut, type AxResponseHandlerArgs, type AxResultPickerFunction, type AxResultPickerFunctionFieldResults, type AxResultPickerFunctionFunctionResults, type AxRewriteIn, type AxRewriteOut, type AxSamplePickerOptions, type AxSetExamplesOptions, AxSignature, type AxSignatureConfig, type AxSignatureTemplateValue, AxSimpleClassifier, AxSimpleClassifierClass, type AxSimpleClassifierForwardOptions, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, AxStringUtil, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable, ax, axAIAnthropicDefaultConfig, axAIAnthropicVertexDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIGrokBestConfig, axAIGrokDefaultConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOllamaDefaultConfig, axAIOllamaDefaultCreativeConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIOpenAIResponsesBestConfig, axAIOpenAIResponsesCreativeConfig, axAIOpenAIResponsesDefaultConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAITogetherDefaultConfig, axAIWebLLMCreativeConfig, axAIWebLLMDefaultConfig, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axCheckMetricsHealth, axCreateDefaultColorLogger, axCreateDefaultOptimizerColorLogger, axCreateDefaultOptimizerTextLogger, axCreateDefaultTextLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGlobals, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axModelInfoTogether, axModelInfoWebLLM, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, f, s };
|
|
7466
|
+
export { AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicErrorEvent, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicPingEvent, type AxAIAnthropicThinkingConfig, type AxAIAnthropicThinkingTokenBudgetLevels, AxAIAnthropicVertexModel, type AxAIArgs, AxAIAzureOpenAI, type AxAIAzureOpenAIArgs, type AxAIAzureOpenAIConfig, AxAICohere, type AxAICohereArgs, type AxAICohereChatRequest, type AxAICohereChatRequestToolResults, type AxAICohereChatResponse, type AxAICohereChatResponseDelta, type AxAICohereChatResponseToolCalls, type AxAICohereConfig, AxAICohereEmbedModel, type AxAICohereEmbedRequest, type AxAICohereEmbedResponse, AxAICohereModel, AxAIDeepSeek, type AxAIDeepSeekArgs, AxAIDeepSeekModel, type AxAIEmbedModels, type AxAIFeatures, AxAIGoogleGemini, type AxAIGoogleGeminiArgs, type AxAIGoogleGeminiBatchEmbedRequest, type AxAIGoogleGeminiBatchEmbedResponse, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, type AxAIGoogleGeminiContentPart, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiEmbedTypes, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiThinkingConfig, type AxAIGoogleGeminiThinkingTokenBudgetLevels, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleSearchRetrieval, type AxAIGoogleVertexBatchEmbedRequest, type AxAIGoogleVertexBatchEmbedResponse, AxAIGrok, type AxAIGrokArgs, type AxAIGrokChatRequest, AxAIGrokEmbedModels, AxAIGrokModel, type AxAIGrokOptionsTools, type AxAIGrokSearchSource, AxAIGroq, type AxAIGroqArgs, AxAIGroqModel, AxAIHuggingFace, type AxAIHuggingFaceArgs, type AxAIHuggingFaceConfig, AxAIHuggingFaceModel, type AxAIHuggingFaceRequest, type AxAIHuggingFaceResponse, type AxAIInputModelList, type AxAIMemory, type AxAIMetricsInstruments, AxAIMistral, type AxAIMistralArgs, type AxAIMistralChatRequest, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelList, type AxAIModelListBase, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIAnnotation, type AxAIOpenAIArgs, AxAIOpenAIBase, type AxAIOpenAIBaseArgs, type AxAIOpenAIChatRequest, type AxAIOpenAIChatResponse, type AxAIOpenAIChatResponseDelta, type AxAIOpenAIConfig, AxAIOpenAIEmbedModel, type AxAIOpenAIEmbedRequest, type AxAIOpenAIEmbedResponse, type AxAIOpenAILogprob, AxAIOpenAIModel, type AxAIOpenAIResponseDelta, AxAIOpenAIResponses, type AxAIOpenAIResponsesArgs, AxAIOpenAIResponsesBase, type AxAIOpenAIResponsesCodeInterpreterToolCall, type AxAIOpenAIResponsesComputerToolCall, type AxAIOpenAIResponsesConfig, type AxAIOpenAIResponsesContentPartAddedEvent, type AxAIOpenAIResponsesContentPartDoneEvent, type AxAIOpenAIResponsesDefineFunctionTool, type AxAIOpenAIResponsesErrorEvent, type AxAIOpenAIResponsesFileSearchCallCompletedEvent, type AxAIOpenAIResponsesFileSearchCallInProgressEvent, type AxAIOpenAIResponsesFileSearchCallSearchingEvent, type AxAIOpenAIResponsesFileSearchToolCall, type AxAIOpenAIResponsesFunctionCallArgumentsDeltaEvent, type AxAIOpenAIResponsesFunctionCallArgumentsDoneEvent, type AxAIOpenAIResponsesFunctionCallItem, type AxAIOpenAIResponsesImageGenerationCallCompletedEvent, type AxAIOpenAIResponsesImageGenerationCallGeneratingEvent, type AxAIOpenAIResponsesImageGenerationCallInProgressEvent, type AxAIOpenAIResponsesImageGenerationCallPartialImageEvent, type AxAIOpenAIResponsesImageGenerationToolCall, AxAIOpenAIResponsesImpl, type AxAIOpenAIResponsesInputAudioContentPart, type AxAIOpenAIResponsesInputContentPart, type AxAIOpenAIResponsesInputFunctionCallItem, type AxAIOpenAIResponsesInputFunctionCallOutputItem, type AxAIOpenAIResponsesInputImageUrlContentPart, type AxAIOpenAIResponsesInputItem, type AxAIOpenAIResponsesInputMessageItem, type AxAIOpenAIResponsesInputTextContentPart, type AxAIOpenAIResponsesLocalShellToolCall, type AxAIOpenAIResponsesMCPCallArgumentsDeltaEvent, type AxAIOpenAIResponsesMCPCallArgumentsDoneEvent, type AxAIOpenAIResponsesMCPCallCompletedEvent, type AxAIOpenAIResponsesMCPCallFailedEvent, type AxAIOpenAIResponsesMCPCallInProgressEvent, type AxAIOpenAIResponsesMCPListToolsCompletedEvent, type AxAIOpenAIResponsesMCPListToolsFailedEvent, type AxAIOpenAIResponsesMCPListToolsInProgressEvent, type AxAIOpenAIResponsesMCPToolCall, AxAIOpenAIResponsesModel, type AxAIOpenAIResponsesOutputItem, type AxAIOpenAIResponsesOutputItemAddedEvent, type AxAIOpenAIResponsesOutputItemDoneEvent, type AxAIOpenAIResponsesOutputMessageItem, type AxAIOpenAIResponsesOutputRefusalContentPart, type AxAIOpenAIResponsesOutputTextAnnotationAddedEvent, type AxAIOpenAIResponsesOutputTextContentPart, type AxAIOpenAIResponsesOutputTextDeltaEvent, type AxAIOpenAIResponsesOutputTextDoneEvent, type AxAIOpenAIResponsesReasoningDeltaEvent, type AxAIOpenAIResponsesReasoningDoneEvent, type AxAIOpenAIResponsesReasoningItem, type AxAIOpenAIResponsesReasoningSummaryDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryDoneEvent, type AxAIOpenAIResponsesReasoningSummaryPart, type AxAIOpenAIResponsesReasoningSummaryPartAddedEvent, type AxAIOpenAIResponsesReasoningSummaryPartDoneEvent, type AxAIOpenAIResponsesReasoningSummaryTextDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryTextDoneEvent, type AxAIOpenAIResponsesRefusalDeltaEvent, type AxAIOpenAIResponsesRefusalDoneEvent, type AxAIOpenAIResponsesRequest, type AxAIOpenAIResponsesResponse, type AxAIOpenAIResponsesResponseCompletedEvent, type AxAIOpenAIResponsesResponseCreatedEvent, type AxAIOpenAIResponsesResponseDelta, type AxAIOpenAIResponsesResponseFailedEvent, type AxAIOpenAIResponsesResponseInProgressEvent, type AxAIOpenAIResponsesResponseIncompleteEvent, type AxAIOpenAIResponsesResponseQueuedEvent, type AxAIOpenAIResponsesStreamEvent, type AxAIOpenAIResponsesStreamEventBase, type AxAIOpenAIResponsesToolCall, type AxAIOpenAIResponsesToolCallBase, type AxAIOpenAIResponsesToolChoice, type AxAIOpenAIResponsesToolDefinition, type AxAIOpenAIResponsesWebSearchCallCompletedEvent, type AxAIOpenAIResponsesWebSearchCallInProgressEvent, type AxAIOpenAIResponsesWebSearchCallSearchingEvent, type AxAIOpenAIResponsesWebSearchToolCall, type AxAIOpenAIUrlCitation, type AxAIOpenAIUsage, AxAIRefusalError, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, AxAIServiceAbortedError, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, type AxAIServiceModelType, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, AxAIWebLLM, type AxAIWebLLMArgs, type AxAIWebLLMChatRequest, type AxAIWebLLMChatResponse, type AxAIWebLLMChatResponseDelta, type AxAIWebLLMConfig, type AxAIWebLLMEmbedModel, type AxAIWebLLMEmbedRequest, type AxAIWebLLMEmbedResponse, AxAIWebLLMModel, type AxAPI, type AxAPIConfig, AxAgent, type AxAgentConfig, type AxAgentFeatures, type AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBaseOptimizer, type AxBootstrapCompileOptions, AxBootstrapFewShot, type AxBootstrapOptimizerOptions, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, type AxCheckpointLoadFn, type AxCheckpointSaveFn, type AxCompileOptions, AxContentProcessingError, type AxContentProcessingServices, type AxCostTracker, type AxCostTrackerOptions, AxDB, type AxDBArgs, AxDBBase, type AxDBBaseArgs, type AxDBBaseOpOptions, AxDBCloudflare, type AxDBCloudflareArgs, type AxDBCloudflareOpOptions, type AxDBLoaderOptions, AxDBManager, type AxDBManagerArgs, type AxDBMatch, AxDBMemory, type AxDBMemoryArgs, type AxDBMemoryOpOptions, AxDBPinecone, type AxDBPineconeArgs, type AxDBPineconeOpOptions, type AxDBQueryRequest, type AxDBQueryResponse, type AxDBQueryService, type AxDBService, type AxDBState, type AxDBUpsertRequest, type AxDBUpsertResponse, AxDBWeaviate, type AxDBWeaviateArgs, type AxDBWeaviateOpOptions, type AxDataRow, AxDefaultCostTracker, AxDefaultResultReranker, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, type AxErrorCategory, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldType, type AxFieldValue, AxFlow, type AxFlowAutoParallelConfig, type AxFlowBranchContext, type AxFlowBranchEvaluationData, type AxFlowCompleteData, AxFlowDependencyAnalyzer, type AxFlowDynamicContext, type AxFlowErrorData, AxFlowExecutionPlanner, type AxFlowExecutionStep, type AxFlowLogData, type AxFlowLoggerData, type AxFlowLoggerFunction, type AxFlowNodeDefinition, type AxFlowParallelBranch, type AxFlowParallelGroup, type AxFlowParallelGroupCompleteData, type AxFlowParallelGroupStartData, type AxFlowStartData, type AxFlowState, type AxFlowStepCompleteData, type AxFlowStepFunction, type AxFlowStepStartData, type AxFlowSubContext, AxFlowSubContextImpl, type AxFlowTypedParallelBranch, type AxFlowTypedSubContext, AxFlowTypedSubContextImpl, type AxFlowable, type AxFluentFieldInfo, AxFluentFieldType, type AxForwardable, type AxFunction, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, type AxFunctionResult, type AxFunctionResultFormatter, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenMetricsInstruments, type AxGenOut, type AxGenStreamingOut, AxGenerateError, type AxGenerateErrorDetails, type AxGenerateResult, AxHFDataLoader, type AxIField, type AxInputFunctionType, AxInstanceRegistry, type AxInternalChatRequest, type AxInternalEmbedRequest, AxLLMRequestTypeValues, type AxLoggerData, type AxLoggerFunction, AxMCPClient, type AxMCPFunctionDescription, AxMCPHTTPSSETransport, type AxMCPInitializeParams, type AxMCPInitializeResult, type AxMCPJSONRPCErrorResponse, type AxMCPJSONRPCNotification, type AxMCPJSONRPCRequest, type AxMCPJSONRPCResponse, type AxMCPJSONRPCSuccessResponse, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, type AxMCPToolsListResult, type AxMCPTransport, AxMediaNotSupportedError, AxMemory, type AxMemoryData, type AxMessage, type AxMetricFn, type AxMetricFnArgs, type AxMetricsConfig, AxMiPRO, type AxMiPROCompileOptions, type AxMiPROOptimizerOptions, type AxMiPROResult, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, type AxModelUsage, type AxMultiMetricFn, type AxMultiProviderConfig, AxMultiServiceRouter, type AxOptimizationCheckpoint, type AxOptimizationProgress, type AxOptimizationStats, type AxOptimizer, type AxOptimizerArgs, type AxOptimizerLoggerData, type AxOptimizerLoggerFunction, type AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramForwardOptionsWithModels, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramStreamingForwardOptionsWithModels, type AxProgramTrace, type AxProgramUsage, type AxProgrammable, AxPromptTemplate, type AxPromptTemplateOptions, AxProviderRouter, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, type AxRerankerIn, type AxRerankerOut, type AxResponseHandlerArgs, type AxResultPickerFunction, type AxResultPickerFunctionFieldResults, type AxResultPickerFunctionFunctionResults, type AxRewriteIn, type AxRewriteOut, type AxRoutingResult, type AxSamplePickerOptions, type AxSetExamplesOptions, AxSignature, AxSignatureBuilder, type AxSignatureConfig, AxSimpleClassifier, AxSimpleClassifierClass, type AxSimpleClassifierForwardOptions, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, AxStringUtil, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable, agent, ai, ax, axAIAnthropicDefaultConfig, axAIAnthropicVertexDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIGrokBestConfig, axAIGrokDefaultConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOllamaDefaultConfig, axAIOllamaDefaultCreativeConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIOpenAIResponsesBestConfig, axAIOpenAIResponsesCreativeConfig, axAIOpenAIResponsesDefaultConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAITogetherDefaultConfig, axAIWebLLMCreativeConfig, axAIWebLLMDefaultConfig, axAnalyzeChatPromptRequirements, axAnalyzeRequestRequirements, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axCheckMetricsHealth, axCreateDefaultColorLogger, axCreateDefaultOptimizerColorLogger, axCreateDefaultOptimizerTextLogger, axCreateDefaultTextLogger, axCreateFlowColorLogger, axCreateFlowTextLogger, axDefaultFlowLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axGetCompatibilityReport, axGetFormatCompatibility, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGetProvidersWithMediaSupport, axGlobals, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axModelInfoTogether, axModelInfoWebLLM, axProcessContentForProvider, axRAG, axScoreProvidersForRequest, axSelectOptimalProvider, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, axValidateProviderCapabilities, f, flow, s };
|