@ax-llm/ax 13.0.9 → 13.0.11
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 +51 -50
- package/index.cjs.map +1 -1
- package/index.d.cts +194 -171
- package/index.d.ts +194 -171
- package/index.js +51 -50
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -73,18 +73,18 @@ declare class AxAIRefusalError extends Error {
|
|
|
73
73
|
toString(): string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
type AxAIInputModelList<TModel, TEmbedModel> = (AxAIModelListBase & {
|
|
76
|
+
type AxAIInputModelList<TModel, TEmbedModel, TModelKey> = (AxAIModelListBase<TModelKey> & {
|
|
77
77
|
isInternal?: boolean;
|
|
78
78
|
} & ({
|
|
79
79
|
model: TModel;
|
|
80
80
|
} | {
|
|
81
81
|
embedModel: TEmbedModel;
|
|
82
82
|
}))[];
|
|
83
|
-
type AxAIModelListBase = {
|
|
84
|
-
key:
|
|
83
|
+
type AxAIModelListBase<TModelKey> = {
|
|
84
|
+
key: TModelKey;
|
|
85
85
|
description: string;
|
|
86
86
|
};
|
|
87
|
-
type AxAIModelList = (AxAIModelListBase & ({
|
|
87
|
+
type AxAIModelList<TModelKey> = (AxAIModelListBase<TModelKey> & ({
|
|
88
88
|
model: string;
|
|
89
89
|
} | {
|
|
90
90
|
embedModel: string;
|
|
@@ -301,6 +301,10 @@ type AxLoggerData = {
|
|
|
301
301
|
value: AxChatResponseResult & {
|
|
302
302
|
delta?: string;
|
|
303
303
|
};
|
|
304
|
+
} | {
|
|
305
|
+
name: 'ChatResponseStreamingDoneResult';
|
|
306
|
+
index: number;
|
|
307
|
+
value: AxChatResponseResult;
|
|
304
308
|
} | {
|
|
305
309
|
name: 'FunctionError';
|
|
306
310
|
index: number;
|
|
@@ -360,8 +364,8 @@ type AxAIServiceOptions = {
|
|
|
360
364
|
abortSignal?: AbortSignal;
|
|
361
365
|
logger?: AxLoggerFunction;
|
|
362
366
|
};
|
|
363
|
-
type AxAIServiceActionOptions<TModel = unknown, TEmbedModel = unknown> = {
|
|
364
|
-
ai?: Readonly<AxAIService<TModel, TEmbedModel>>;
|
|
367
|
+
type AxAIServiceActionOptions<TModel = unknown, TEmbedModel = unknown, TModelKey = string> = {
|
|
368
|
+
ai?: Readonly<AxAIService<TModel, TEmbedModel, TModelKey>>;
|
|
365
369
|
sessionId?: string;
|
|
366
370
|
traceId?: string | undefined;
|
|
367
371
|
timeout?: number;
|
|
@@ -374,18 +378,18 @@ type AxAIServiceActionOptions<TModel = unknown, TEmbedModel = unknown> = {
|
|
|
374
378
|
stepIndex?: number;
|
|
375
379
|
functionResultFormatter?: (result: unknown) => string;
|
|
376
380
|
};
|
|
377
|
-
interface AxAIService<TModel = unknown, TEmbedModel = unknown> {
|
|
381
|
+
interface AxAIService<TModel = unknown, TEmbedModel = unknown, TModelKey = string> {
|
|
378
382
|
getId(): string;
|
|
379
383
|
getName(): string;
|
|
380
384
|
getFeatures(model?: TModel): AxAIFeatures;
|
|
381
|
-
getModelList(): AxAIModelList | undefined;
|
|
385
|
+
getModelList(): AxAIModelList<TModelKey> | undefined;
|
|
382
386
|
getMetrics(): AxAIServiceMetrics;
|
|
383
387
|
getLogger(): AxLoggerFunction;
|
|
384
388
|
getLastUsedChatModel(): TModel | undefined;
|
|
385
389
|
getLastUsedEmbedModel(): TEmbedModel | undefined;
|
|
386
390
|
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
387
|
-
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
388
|
-
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
391
|
+
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel, TModelKey>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
392
|
+
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel, TModelKey>>): Promise<AxEmbedResponse>;
|
|
389
393
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
390
394
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
391
395
|
}
|
|
@@ -406,7 +410,7 @@ interface AxAIFeatures {
|
|
|
406
410
|
hasThinkingBudget?: boolean;
|
|
407
411
|
hasShowThoughts?: boolean;
|
|
408
412
|
}
|
|
409
|
-
interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
413
|
+
interface AxBaseAIArgs<TModel, TEmbedModel, TModelKey> {
|
|
410
414
|
name: string;
|
|
411
415
|
apiURL: string;
|
|
412
416
|
headers: () => Promise<Record<string, string>>;
|
|
@@ -417,11 +421,11 @@ interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
|
417
421
|
}>;
|
|
418
422
|
options?: Readonly<AxAIServiceOptions>;
|
|
419
423
|
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
420
|
-
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
424
|
+
models?: AxAIInputModelList<TModel, TEmbedModel, TModelKey>;
|
|
421
425
|
}
|
|
422
426
|
declare const axBaseAIDefaultConfig: () => AxModelConfig;
|
|
423
427
|
declare const axBaseAIDefaultCreativeConfig: () => AxModelConfig;
|
|
424
|
-
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse> implements AxAIService<TModel, TEmbedModel> {
|
|
428
|
+
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse, TModelKey> implements AxAIService<TModel, TEmbedModel, TModelKey> {
|
|
425
429
|
private readonly aiImpl;
|
|
426
430
|
private debug;
|
|
427
431
|
private rt?;
|
|
@@ -446,7 +450,7 @@ declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatRe
|
|
|
446
450
|
protected headers: () => Promise<Record<string, string>>;
|
|
447
451
|
protected supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
448
452
|
private metrics;
|
|
449
|
-
constructor(aiImpl: Readonly<AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse>>, { name, apiURL, headers, modelInfo, defaults, options, supportFor, models, }: Readonly<AxBaseAIArgs<TModel, TEmbedModel>>);
|
|
453
|
+
constructor(aiImpl: Readonly<AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse>>, { name, apiURL, headers, modelInfo, defaults, options, supportFor, models, }: Readonly<AxBaseAIArgs<TModel, TEmbedModel, TModelKey>>);
|
|
450
454
|
private getMetricsInstruments;
|
|
451
455
|
setName(name: string): void;
|
|
452
456
|
getId(): string;
|
|
@@ -455,7 +459,7 @@ declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatRe
|
|
|
455
459
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
456
460
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
457
461
|
getLogger(): AxLoggerFunction;
|
|
458
|
-
getModelList(): AxAIModelList
|
|
462
|
+
getModelList(): AxAIModelList<TModelKey>;
|
|
459
463
|
getName(): string;
|
|
460
464
|
getFeatures(model?: TModel): AxAIFeatures;
|
|
461
465
|
getLastUsedChatModel(): TModel | undefined;
|
|
@@ -478,11 +482,11 @@ declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatRe
|
|
|
478
482
|
private recordChatMetrics;
|
|
479
483
|
private recordEmbedMetrics;
|
|
480
484
|
getMetrics(): AxAIServiceMetrics;
|
|
481
|
-
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
485
|
+
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel, TModelKey>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
482
486
|
private _chat1;
|
|
483
487
|
private cleanupFunctionSchema;
|
|
484
488
|
private _chat2;
|
|
485
|
-
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
489
|
+
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel, TModelKey>>): Promise<AxEmbedResponse>;
|
|
486
490
|
private _embed1;
|
|
487
491
|
private _embed2;
|
|
488
492
|
private buildHeaders;
|
|
@@ -725,17 +729,17 @@ type AxAIAnthropicChatResponseDelta = AxAIAnthropicMessageStartEvent | AxAIAnthr
|
|
|
725
729
|
|
|
726
730
|
declare const axAIAnthropicDefaultConfig: () => AxAIAnthropicConfig;
|
|
727
731
|
declare const axAIAnthropicVertexDefaultConfig: () => AxAIAnthropicConfig;
|
|
728
|
-
interface AxAIAnthropicArgs {
|
|
732
|
+
interface AxAIAnthropicArgs<TModelKey = string> {
|
|
729
733
|
name: 'anthropic';
|
|
730
734
|
apiKey?: string | (() => Promise<string>);
|
|
731
735
|
projectId?: string;
|
|
732
736
|
region?: string;
|
|
733
737
|
config?: Readonly<Partial<AxAIAnthropicConfig>>;
|
|
734
738
|
options?: Readonly<AxAIServiceOptions>;
|
|
735
|
-
models?: AxAIInputModelList<AxAIAnthropicModel | AxAIAnthropicVertexModel, undefined>;
|
|
739
|
+
models?: AxAIInputModelList<AxAIAnthropicModel | AxAIAnthropicVertexModel, undefined, TModelKey>;
|
|
736
740
|
}
|
|
737
|
-
declare class AxAIAnthropic extends AxBaseAI<AxAIAnthropicModel | AxAIAnthropicVertexModel, unknown, AxAIAnthropicChatRequest, unknown, AxAIAnthropicChatResponse, AxAIAnthropicChatResponseDelta, unknown> {
|
|
738
|
-
constructor({ apiKey, projectId, region, config, options, models, }: Readonly<Omit<AxAIAnthropicArgs
|
|
741
|
+
declare class AxAIAnthropic<TModelKey = string> extends AxBaseAI<AxAIAnthropicModel | AxAIAnthropicVertexModel, unknown, AxAIAnthropicChatRequest, unknown, AxAIAnthropicChatResponse, AxAIAnthropicChatResponseDelta, unknown, TModelKey> {
|
|
742
|
+
constructor({ apiKey, projectId, region, config, options, models, }: Readonly<Omit<AxAIAnthropicArgs<TModelKey>, 'name'>>);
|
|
739
743
|
}
|
|
740
744
|
|
|
741
745
|
declare const axModelInfoAnthropic: AxModelInfo[];
|
|
@@ -986,13 +990,13 @@ declare const axAIOpenAIDefaultConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, A
|
|
|
986
990
|
declare const axAIOpenAIBestConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
987
991
|
declare const axAIOpenAICreativeConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
988
992
|
declare const axAIOpenAIFastConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
989
|
-
interface AxAIOpenAIArgs<TName = 'openai', TModel = AxAIOpenAIModel, TEmbedModel = AxAIOpenAIEmbedModel, TChatReq extends AxAIOpenAIChatRequest<TModel> = AxAIOpenAIChatRequest<TModel>> extends Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TChatReq>, 'config' | 'supportFor' | 'modelInfo'> {
|
|
993
|
+
interface AxAIOpenAIArgs<TName = 'openai', TModel = AxAIOpenAIModel, TEmbedModel = AxAIOpenAIEmbedModel, TModelKey = string, TChatReq extends AxAIOpenAIChatRequest<TModel> = AxAIOpenAIChatRequest<TModel>> extends Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>, 'config' | 'supportFor' | 'modelInfo'> {
|
|
990
994
|
name: TName;
|
|
991
995
|
modelInfo?: AxModelInfo[];
|
|
992
|
-
config?: Partial<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TChatReq>['config']>;
|
|
996
|
+
config?: Partial<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>['config']>;
|
|
993
997
|
}
|
|
994
998
|
type ChatReqUpdater<TModel, TChatReq extends AxAIOpenAIChatRequest<TModel>> = (req: Readonly<TChatReq>) => TChatReq;
|
|
995
|
-
interface AxAIOpenAIBaseArgs<TModel, TEmbedModel, TChatReq extends AxAIOpenAIChatRequest<TModel>> {
|
|
999
|
+
interface AxAIOpenAIBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq extends AxAIOpenAIChatRequest<TModel>> {
|
|
996
1000
|
apiKey: string;
|
|
997
1001
|
apiURL?: string;
|
|
998
1002
|
config: Readonly<AxAIOpenAIConfig<TModel, TEmbedModel>>;
|
|
@@ -1000,15 +1004,15 @@ interface AxAIOpenAIBaseArgs<TModel, TEmbedModel, TChatReq extends AxAIOpenAICha
|
|
|
1000
1004
|
streamingUsage?: boolean;
|
|
1001
1005
|
}>;
|
|
1002
1006
|
modelInfo: Readonly<AxModelInfo[]>;
|
|
1003
|
-
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
1007
|
+
models?: AxAIInputModelList<TModel, TEmbedModel, TModelKey>;
|
|
1004
1008
|
chatReqUpdater?: ChatReqUpdater<TModel, TChatReq>;
|
|
1005
1009
|
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
1006
1010
|
}
|
|
1007
|
-
declare class AxAIOpenAIBase<TModel, TEmbedModel, TChatReq extends AxAIOpenAIChatRequest<TModel> = AxAIOpenAIChatRequest<TModel>> extends AxBaseAI<TModel, TEmbedModel, AxAIOpenAIChatRequest<TModel>, AxAIOpenAIEmbedRequest<TEmbedModel>, AxAIOpenAIChatResponse, AxAIOpenAIChatResponseDelta, AxAIOpenAIEmbedResponse> {
|
|
1008
|
-
constructor({ apiKey, config, options, apiURL, modelInfo, models, chatReqUpdater, supportFor, }: Readonly<Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TChatReq>, 'name'>>);
|
|
1011
|
+
declare class AxAIOpenAIBase<TModel, TEmbedModel, TModelKey, TChatReq extends AxAIOpenAIChatRequest<TModel> = AxAIOpenAIChatRequest<TModel>> extends AxBaseAI<TModel, TEmbedModel, AxAIOpenAIChatRequest<TModel>, AxAIOpenAIEmbedRequest<TEmbedModel>, AxAIOpenAIChatResponse, AxAIOpenAIChatResponseDelta, AxAIOpenAIEmbedResponse, TModelKey> {
|
|
1012
|
+
constructor({ apiKey, config, options, apiURL, modelInfo, models, chatReqUpdater, supportFor, }: Readonly<Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>, 'name'>>);
|
|
1009
1013
|
}
|
|
1010
|
-
declare class AxAIOpenAI extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbedModel> {
|
|
1011
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIArgs, 'name'>>);
|
|
1014
|
+
declare class AxAIOpenAI<TModelKey = string> extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> {
|
|
1015
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
1012
1016
|
}
|
|
1013
1017
|
|
|
1014
1018
|
declare const axAIAzureOpenAIDefaultConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
@@ -1016,20 +1020,20 @@ declare const axAIAzureOpenAICreativeConfig: () => AxAIOpenAIConfig<AxAIOpenAIMo
|
|
|
1016
1020
|
declare const axAIAzureOpenAIFastConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
1017
1021
|
declare const axAIAzureOpenAIBestConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
1018
1022
|
type AxAIAzureOpenAIConfig = AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
1019
|
-
type AxAIAzureOpenAIArgs = AxAIOpenAIArgs<'azure-openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel> & {
|
|
1023
|
+
type AxAIAzureOpenAIArgs<TModelKey = string> = AxAIOpenAIArgs<'azure-openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> & {
|
|
1020
1024
|
resourceName: string;
|
|
1021
1025
|
deploymentName: string;
|
|
1022
1026
|
version?: string;
|
|
1023
1027
|
};
|
|
1024
|
-
declare class AxAIAzureOpenAI extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbedModel> {
|
|
1025
|
-
constructor({ apiKey, resourceName, deploymentName, version, config, options, models, modelInfo, }: Readonly<Omit<AxAIAzureOpenAIArgs
|
|
1028
|
+
declare class AxAIAzureOpenAI<TModelKey = string> extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> {
|
|
1029
|
+
constructor({ apiKey, resourceName, deploymentName, version, config, options, models, modelInfo, }: Readonly<Omit<AxAIAzureOpenAIArgs<TModelKey>, 'name'>>);
|
|
1026
1030
|
}
|
|
1027
1031
|
|
|
1028
1032
|
/**
|
|
1029
1033
|
* Options for the balancer.
|
|
1030
1034
|
*/
|
|
1031
|
-
type AxBalancerOptions = {
|
|
1032
|
-
comparator?: (a: AxAIService, b: AxAIService) => number;
|
|
1035
|
+
type AxBalancerOptions<TModelKey = string> = {
|
|
1036
|
+
comparator?: (a: AxAIService<unknown, unknown, TModelKey>, b: AxAIService<unknown, unknown, TModelKey>) => number;
|
|
1033
1037
|
debug?: boolean;
|
|
1034
1038
|
initialBackoffMs?: number;
|
|
1035
1039
|
maxBackoffMs?: number;
|
|
@@ -1038,7 +1042,7 @@ type AxBalancerOptions = {
|
|
|
1038
1042
|
/**
|
|
1039
1043
|
* Balancer that rotates through services.
|
|
1040
1044
|
*/
|
|
1041
|
-
declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
1045
|
+
declare class AxBalancer<TModelKey = string> implements AxAIService<unknown, unknown, TModelKey> {
|
|
1042
1046
|
private services;
|
|
1043
1047
|
private currentServiceIndex;
|
|
1044
1048
|
private currentService;
|
|
@@ -1047,7 +1051,7 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1047
1051
|
private maxBackoffMs;
|
|
1048
1052
|
private maxRetries;
|
|
1049
1053
|
private serviceFailures;
|
|
1050
|
-
constructor(services: readonly AxAIService[], options?: AxBalancerOptions);
|
|
1054
|
+
constructor(services: readonly AxAIService<unknown, unknown, TModelKey>[], options?: AxBalancerOptions<TModelKey>);
|
|
1051
1055
|
getLastUsedChatModel(): unknown;
|
|
1052
1056
|
getLastUsedEmbedModel(): unknown;
|
|
1053
1057
|
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
@@ -1058,8 +1062,8 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1058
1062
|
/**
|
|
1059
1063
|
* Service comparator that sorts services by cost.
|
|
1060
1064
|
*/
|
|
1061
|
-
static metricComparator: (a: AxAIService, b: AxAIService) => number;
|
|
1062
|
-
getModelList(): AxAIModelList | undefined;
|
|
1065
|
+
static metricComparator: <TModelKey_1 = string>(a: AxAIService<unknown, unknown, TModelKey_1>, b: AxAIService<unknown, unknown, TModelKey_1>) => number;
|
|
1066
|
+
getModelList(): AxAIModelList<TModelKey> | undefined;
|
|
1063
1067
|
private getNextService;
|
|
1064
1068
|
private reset;
|
|
1065
1069
|
getName(): string;
|
|
@@ -1069,8 +1073,8 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1069
1073
|
private canRetryService;
|
|
1070
1074
|
private handleFailure;
|
|
1071
1075
|
private handleSuccess;
|
|
1072
|
-
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions
|
|
1073
|
-
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions
|
|
1076
|
+
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown, TModelKey>> | undefined): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1077
|
+
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions<unknown, unknown, TModelKey>> | undefined): Promise<AxEmbedResponse>;
|
|
1074
1078
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
1075
1079
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
1076
1080
|
getLogger(): AxLoggerFunction;
|
|
@@ -1177,15 +1181,15 @@ type AxAICohereEmbedResponse = {
|
|
|
1177
1181
|
|
|
1178
1182
|
declare const axAICohereDefaultConfig: () => AxAICohereConfig;
|
|
1179
1183
|
declare const axAICohereCreativeConfig: () => AxAICohereConfig;
|
|
1180
|
-
interface AxAICohereArgs {
|
|
1184
|
+
interface AxAICohereArgs<TModelKey = string> {
|
|
1181
1185
|
name: 'cohere';
|
|
1182
1186
|
apiKey: string;
|
|
1183
1187
|
config?: Readonly<Partial<AxAICohereConfig>>;
|
|
1184
1188
|
options?: Readonly<AxAIServiceOptions>;
|
|
1185
|
-
models?: AxAIInputModelList<AxAICohereModel, AxAICohereEmbedModel>;
|
|
1189
|
+
models?: AxAIInputModelList<AxAICohereModel, AxAICohereEmbedModel, TModelKey>;
|
|
1186
1190
|
}
|
|
1187
|
-
declare class AxAICohere extends AxBaseAI<AxAICohereModel, AxAICohereEmbedModel, AxAICohereChatRequest, AxAICohereEmbedRequest, AxAICohereChatResponse, AxAICohereChatResponseDelta, AxAICohereEmbedResponse> {
|
|
1188
|
-
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAICohereArgs
|
|
1191
|
+
declare class AxAICohere<TModelKey = string> extends AxBaseAI<AxAICohereModel, AxAICohereEmbedModel, AxAICohereChatRequest, AxAICohereEmbedRequest, AxAICohereChatResponse, AxAICohereChatResponseDelta, AxAICohereEmbedResponse, TModelKey> {
|
|
1192
|
+
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAICohereArgs<TModelKey>, 'name'>>);
|
|
1189
1193
|
}
|
|
1190
1194
|
|
|
1191
1195
|
declare const axModelInfoCohere: AxModelInfo[];
|
|
@@ -1202,9 +1206,9 @@ declare enum AxAIDeepSeekModel {
|
|
|
1202
1206
|
type DeepSeekConfig = AxAIOpenAIConfig<AxAIDeepSeekModel, undefined>;
|
|
1203
1207
|
declare const axAIDeepSeekDefaultConfig: () => DeepSeekConfig;
|
|
1204
1208
|
declare const axAIDeepSeekCodeConfig: () => DeepSeekConfig;
|
|
1205
|
-
type AxAIDeepSeekArgs = AxAIOpenAIArgs<'deepseek', AxAIDeepSeekModel, undefined>;
|
|
1206
|
-
declare class AxAIDeepSeek extends AxAIOpenAIBase<AxAIDeepSeekModel, undefined> {
|
|
1207
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIDeepSeekArgs
|
|
1209
|
+
type AxAIDeepSeekArgs<TModelKey = string> = AxAIOpenAIArgs<'deepseek', AxAIDeepSeekModel, undefined, TModelKey>;
|
|
1210
|
+
declare class AxAIDeepSeek<TModelKey = string> extends AxAIOpenAIBase<AxAIDeepSeekModel, undefined, TModelKey> {
|
|
1211
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIDeepSeekArgs<TModelKey>, 'name'>>);
|
|
1208
1212
|
}
|
|
1209
1213
|
|
|
1210
1214
|
declare const axModelInfoDeepSeek: AxModelInfo[];
|
|
@@ -1447,7 +1451,7 @@ interface AxAIGoogleGeminiOptionsTools {
|
|
|
1447
1451
|
googleSearch?: boolean;
|
|
1448
1452
|
urlContext?: boolean;
|
|
1449
1453
|
}
|
|
1450
|
-
interface AxAIGoogleGeminiArgs {
|
|
1454
|
+
interface AxAIGoogleGeminiArgs<TModelKey = string> {
|
|
1451
1455
|
name: 'google-gemini';
|
|
1452
1456
|
apiKey?: string | (() => Promise<string>);
|
|
1453
1457
|
projectId?: string;
|
|
@@ -1455,14 +1459,14 @@ interface AxAIGoogleGeminiArgs {
|
|
|
1455
1459
|
endpointId?: string;
|
|
1456
1460
|
config?: Readonly<Partial<AxAIGoogleGeminiConfig>>;
|
|
1457
1461
|
options?: Readonly<AxAIServiceOptions & AxAIGoogleGeminiOptionsTools>;
|
|
1458
|
-
models?: AxAIInputModelList<AxAIGoogleGeminiModel, AxAIGoogleGeminiEmbedModel>;
|
|
1462
|
+
models?: AxAIInputModelList<AxAIGoogleGeminiModel, AxAIGoogleGeminiEmbedModel, TModelKey>;
|
|
1459
1463
|
modelInfo?: AxModelInfo[];
|
|
1460
1464
|
}
|
|
1461
1465
|
/**
|
|
1462
1466
|
* AxAIGoogleGemini: AI Service
|
|
1463
1467
|
*/
|
|
1464
|
-
declare class AxAIGoogleGemini extends AxBaseAI<AxAIGoogleGeminiModel, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiChatRequest, AxAIGoogleGeminiBatchEmbedRequest | AxAIGoogleVertexBatchEmbedRequest, AxAIGoogleGeminiChatResponse, AxAIGoogleGeminiChatResponseDelta, AxAIGoogleGeminiBatchEmbedResponse | AxAIGoogleVertexBatchEmbedResponse> {
|
|
1465
|
-
constructor({ apiKey, projectId, region, endpointId, config, options, models, modelInfo, }: Readonly<Omit<AxAIGoogleGeminiArgs
|
|
1468
|
+
declare class AxAIGoogleGemini<TModelKey = string> extends AxBaseAI<AxAIGoogleGeminiModel, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiChatRequest, AxAIGoogleGeminiBatchEmbedRequest | AxAIGoogleVertexBatchEmbedRequest, AxAIGoogleGeminiChatResponse, AxAIGoogleGeminiChatResponseDelta, AxAIGoogleGeminiBatchEmbedResponse | AxAIGoogleVertexBatchEmbedResponse, TModelKey> {
|
|
1469
|
+
constructor({ apiKey, projectId, region, endpointId, config, options, models, modelInfo, }: Readonly<Omit<AxAIGoogleGeminiArgs<TModelKey>, 'name'>>);
|
|
1466
1470
|
}
|
|
1467
1471
|
|
|
1468
1472
|
/**
|
|
@@ -1477,14 +1481,14 @@ declare enum AxAIGroqModel {
|
|
|
1477
1481
|
Gemma2_9B = "gemma2-9b-it"
|
|
1478
1482
|
}
|
|
1479
1483
|
|
|
1480
|
-
type AxAIGroqArgs = AxAIOpenAIArgs<'groq', AxAIGroqModel, undefined> & {
|
|
1484
|
+
type AxAIGroqArgs<TModelKey = string> = AxAIOpenAIArgs<'groq', AxAIGroqModel, undefined, TModelKey> & {
|
|
1481
1485
|
options?: Readonly<AxAIServiceOptions> & {
|
|
1482
1486
|
tokensPerMinute?: number;
|
|
1483
1487
|
};
|
|
1484
1488
|
modelInfo?: AxModelInfo[];
|
|
1485
1489
|
};
|
|
1486
|
-
declare class AxAIGroq extends AxAIOpenAIBase<AxAIGroqModel, undefined> {
|
|
1487
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIGroqArgs
|
|
1490
|
+
declare class AxAIGroq<TModelKey = string> extends AxAIOpenAIBase<AxAIGroqModel, undefined, TModelKey> {
|
|
1491
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIGroqArgs<TModelKey>, 'name'>>);
|
|
1488
1492
|
setOptions: (options: Readonly<AxAIServiceOptions>) => void;
|
|
1489
1493
|
private newRateLimiter;
|
|
1490
1494
|
}
|
|
@@ -1530,15 +1534,15 @@ type AxAIHuggingFaceResponse = {
|
|
|
1530
1534
|
|
|
1531
1535
|
declare const axAIHuggingFaceDefaultConfig: () => AxAIHuggingFaceConfig;
|
|
1532
1536
|
declare const axAIHuggingFaceCreativeConfig: () => AxAIHuggingFaceConfig;
|
|
1533
|
-
interface AxAIHuggingFaceArgs {
|
|
1537
|
+
interface AxAIHuggingFaceArgs<TModelKey = string> {
|
|
1534
1538
|
name: 'huggingface';
|
|
1535
1539
|
apiKey: string;
|
|
1536
1540
|
config?: Readonly<Partial<AxAIHuggingFaceConfig>>;
|
|
1537
1541
|
options?: Readonly<AxAIServiceOptions>;
|
|
1538
|
-
models?: AxAIInputModelList<AxAIHuggingFaceModel, undefined>;
|
|
1542
|
+
models?: AxAIInputModelList<AxAIHuggingFaceModel, undefined, TModelKey>;
|
|
1539
1543
|
}
|
|
1540
|
-
declare class AxAIHuggingFace extends AxBaseAI<AxAIHuggingFaceModel, unknown, AxAIHuggingFaceRequest, unknown, AxAIHuggingFaceResponse, unknown, unknown> {
|
|
1541
|
-
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAIHuggingFaceArgs
|
|
1544
|
+
declare class AxAIHuggingFace<TModelKey = string> extends AxBaseAI<AxAIHuggingFaceModel, unknown, AxAIHuggingFaceRequest, unknown, AxAIHuggingFaceResponse, unknown, unknown, TModelKey> {
|
|
1545
|
+
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAIHuggingFaceArgs<TModelKey>, 'name'>>);
|
|
1542
1546
|
}
|
|
1543
1547
|
|
|
1544
1548
|
/**
|
|
@@ -1622,20 +1626,20 @@ type AxAIMistralChatRequest = Omit<AxAIOpenAIChatRequest<AxAIMistralModel>, 'max
|
|
|
1622
1626
|
tool_call_id: string;
|
|
1623
1627
|
})[];
|
|
1624
1628
|
};
|
|
1625
|
-
type AxAIMistralArgs = AxAIOpenAIArgs<'mistral', AxAIMistralModel, AxAIMistralEmbedModels> & {
|
|
1629
|
+
type AxAIMistralArgs<TModelKey = string> = AxAIOpenAIArgs<'mistral', AxAIMistralModel, AxAIMistralEmbedModels, TModelKey> & {
|
|
1626
1630
|
options?: Readonly<AxAIServiceOptions> & {
|
|
1627
1631
|
tokensPerMinute?: number;
|
|
1628
1632
|
};
|
|
1629
1633
|
modelInfo?: AxModelInfo[];
|
|
1630
1634
|
};
|
|
1631
|
-
declare class AxAIMistral extends AxAIOpenAIBase<AxAIMistralModel, AxAIMistralEmbedModels> {
|
|
1632
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIMistralArgs
|
|
1635
|
+
declare class AxAIMistral<TModelKey = string> extends AxAIOpenAIBase<AxAIMistralModel, AxAIMistralEmbedModels, TModelKey> {
|
|
1636
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIMistralArgs<TModelKey>, 'name'>>);
|
|
1633
1637
|
private updateMessages;
|
|
1634
1638
|
}
|
|
1635
1639
|
|
|
1636
1640
|
declare const axModelInfoMistral: AxModelInfo[];
|
|
1637
1641
|
|
|
1638
|
-
type AxMockAIServiceConfig = {
|
|
1642
|
+
type AxMockAIServiceConfig<TModelKey = string> = {
|
|
1639
1643
|
name?: string;
|
|
1640
1644
|
id?: string;
|
|
1641
1645
|
modelInfo?: Partial<AxModelInfoWithProvider>;
|
|
@@ -1644,7 +1648,7 @@ type AxMockAIServiceConfig = {
|
|
|
1644
1648
|
functions?: boolean;
|
|
1645
1649
|
streaming?: boolean;
|
|
1646
1650
|
};
|
|
1647
|
-
models?: AxAIModelList
|
|
1651
|
+
models?: AxAIModelList<TModelKey>;
|
|
1648
1652
|
options?: AxAIServiceOptions;
|
|
1649
1653
|
chatResponse?: AxChatResponse | ReadableStream<AxChatResponse> | (() => Promise<AxChatResponse | ReadableStream<AxChatResponse>>) | ((req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>) => Promise<AxChatResponse | ReadableStream<AxChatResponse>>);
|
|
1650
1654
|
embedResponse?: AxEmbedResponse | ((req: Readonly<AxEmbedRequest>) => AxEmbedResponse | Promise<AxEmbedResponse>);
|
|
@@ -1652,10 +1656,10 @@ type AxMockAIServiceConfig = {
|
|
|
1652
1656
|
errorMessage?: string;
|
|
1653
1657
|
latencyMs?: number;
|
|
1654
1658
|
};
|
|
1655
|
-
declare class AxMockAIService implements AxAIService {
|
|
1659
|
+
declare class AxMockAIService<TModelKey = string> implements AxAIService<unknown, unknown, TModelKey> {
|
|
1656
1660
|
private readonly config;
|
|
1657
1661
|
private metrics;
|
|
1658
|
-
constructor(config?: AxMockAIServiceConfig);
|
|
1662
|
+
constructor(config?: AxMockAIServiceConfig<TModelKey>);
|
|
1659
1663
|
getLastUsedChatModel(): unknown;
|
|
1660
1664
|
getLastUsedEmbedModel(): unknown;
|
|
1661
1665
|
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
@@ -1665,23 +1669,23 @@ declare class AxMockAIService implements AxAIService {
|
|
|
1665
1669
|
functions: boolean;
|
|
1666
1670
|
streaming: boolean;
|
|
1667
1671
|
};
|
|
1668
|
-
getModelList(): AxAIModelList | undefined;
|
|
1672
|
+
getModelList(): AxAIModelList<TModelKey> | undefined;
|
|
1669
1673
|
getMetrics(): AxAIServiceMetrics;
|
|
1670
|
-
chat(req: Readonly<AxChatRequest<unknown>>, _options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1671
|
-
embed(req: Readonly<AxEmbedRequest>, _options?: Readonly<AxAIServiceActionOptions
|
|
1674
|
+
chat(req: Readonly<AxChatRequest<unknown>>, _options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown, TModelKey>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1675
|
+
embed(req: Readonly<AxEmbedRequest>, _options?: Readonly<AxAIServiceActionOptions<unknown, unknown, TModelKey>>): Promise<AxEmbedResponse>;
|
|
1672
1676
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
1673
1677
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
1674
1678
|
getLogger(): AxLoggerFunction;
|
|
1675
1679
|
private updateMetrics;
|
|
1676
1680
|
}
|
|
1677
1681
|
|
|
1678
|
-
type AxAIServiceListItem<TModel = unknown, TEmbedModel = unknown> = {
|
|
1679
|
-
key:
|
|
1680
|
-
service: AxAIService<TModel, TEmbedModel>;
|
|
1682
|
+
type AxAIServiceListItem<TModel = unknown, TEmbedModel = unknown, TModelKey = string> = {
|
|
1683
|
+
key: TModelKey;
|
|
1684
|
+
service: AxAIService<TModel, TEmbedModel, TModelKey>;
|
|
1681
1685
|
description: string;
|
|
1682
1686
|
isInternal?: boolean;
|
|
1683
1687
|
};
|
|
1684
|
-
declare class AxMultiServiceRouter implements AxAIService<
|
|
1688
|
+
declare class AxMultiServiceRouter<TModelKey = string> implements AxAIService<unknown, unknown, TModelKey> {
|
|
1685
1689
|
private options?;
|
|
1686
1690
|
private lastUsedService?;
|
|
1687
1691
|
private services;
|
|
@@ -1690,18 +1694,18 @@ declare class AxMultiServiceRouter implements AxAIService<string, string> {
|
|
|
1690
1694
|
* It validates that each service provides a unique set of model keys,
|
|
1691
1695
|
* then builds a lookup (map) for routing the chat/embed requests.
|
|
1692
1696
|
*/
|
|
1693
|
-
constructor(services: (AxAIServiceListItem<
|
|
1694
|
-
getLastUsedChatModel():
|
|
1695
|
-
getLastUsedEmbedModel():
|
|
1697
|
+
constructor(services: (AxAIServiceListItem<unknown, unknown, TModelKey> | AxAIService<unknown, unknown, TModelKey>)[]);
|
|
1698
|
+
getLastUsedChatModel(): unknown | undefined;
|
|
1699
|
+
getLastUsedEmbedModel(): unknown | undefined;
|
|
1696
1700
|
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
1697
1701
|
/**
|
|
1698
1702
|
* Delegates the chat call to the service matching the provided model key.
|
|
1699
1703
|
*/
|
|
1700
|
-
chat(req: Readonly<AxChatRequest<string>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<
|
|
1704
|
+
chat(req: Readonly<AxChatRequest<string>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown, TModelKey>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1701
1705
|
/**
|
|
1702
1706
|
* Delegates the embed call to the service matching the provided embed model key.
|
|
1703
1707
|
*/
|
|
1704
|
-
embed(req: Readonly<AxEmbedRequest<string>>, options?: Readonly<AxAIServiceActionOptions<
|
|
1708
|
+
embed(req: Readonly<AxEmbedRequest<string>>, options?: Readonly<AxAIServiceActionOptions<unknown, unknown, TModelKey>>): Promise<AxEmbedResponse>;
|
|
1705
1709
|
/**
|
|
1706
1710
|
* Returns a composite ID built from the IDs of the underlying services.
|
|
1707
1711
|
*/
|
|
@@ -1713,12 +1717,12 @@ declare class AxMultiServiceRouter implements AxAIService<string, string> {
|
|
|
1713
1717
|
/**
|
|
1714
1718
|
* Aggregates all available models across the underlying services.
|
|
1715
1719
|
*/
|
|
1716
|
-
getModelList(): AxAIModelList
|
|
1720
|
+
getModelList(): AxAIModelList<TModelKey>;
|
|
1717
1721
|
/**
|
|
1718
1722
|
* If a model key is provided, delegate to the corresponding service's features.
|
|
1719
1723
|
* Otherwise, returns a default feature set.
|
|
1720
1724
|
*/
|
|
1721
|
-
getFeatures(model?:
|
|
1725
|
+
getFeatures(model?: TModelKey): {
|
|
1722
1726
|
functions: boolean;
|
|
1723
1727
|
streaming: boolean;
|
|
1724
1728
|
functionCot?: boolean;
|
|
@@ -1748,19 +1752,19 @@ declare class AxMultiServiceRouter implements AxAIService<string, string> {
|
|
|
1748
1752
|
* @param key - The model key
|
|
1749
1753
|
* @param entry - The service entry to set
|
|
1750
1754
|
*/
|
|
1751
|
-
setServiceEntry(key:
|
|
1755
|
+
setServiceEntry(key: TModelKey, entry: {
|
|
1752
1756
|
isInternal?: boolean;
|
|
1753
1757
|
description: string;
|
|
1754
1758
|
model?: string;
|
|
1755
1759
|
embedModel?: string;
|
|
1756
|
-
service: AxAIService<
|
|
1760
|
+
service: AxAIService<unknown, unknown, TModelKey>;
|
|
1757
1761
|
}): void;
|
|
1758
1762
|
}
|
|
1759
1763
|
|
|
1760
1764
|
type AxAIOllamaAIConfig = AxAIOpenAIConfig<string, string>;
|
|
1761
1765
|
declare const axAIOllamaDefaultConfig: () => AxAIOllamaAIConfig;
|
|
1762
1766
|
declare const axAIOllamaDefaultCreativeConfig: () => AxAIOllamaAIConfig;
|
|
1763
|
-
type AxAIOllamaArgs = AxAIOpenAIArgs<'ollama', string, string> & {
|
|
1767
|
+
type AxAIOllamaArgs<TModelKey = string> = AxAIOpenAIArgs<'ollama', string, string, TModelKey> & {
|
|
1764
1768
|
model?: string;
|
|
1765
1769
|
embedModel?: string;
|
|
1766
1770
|
url?: string;
|
|
@@ -1768,8 +1772,8 @@ type AxAIOllamaArgs = AxAIOpenAIArgs<'ollama', string, string> & {
|
|
|
1768
1772
|
/**
|
|
1769
1773
|
* OllamaAI: AI Service
|
|
1770
1774
|
*/
|
|
1771
|
-
declare class AxAIOllama extends AxAIOpenAIBase<string, string> {
|
|
1772
|
-
constructor({ apiKey, url, config, options, models, }: Readonly<Omit<AxAIOllamaArgs
|
|
1775
|
+
declare class AxAIOllama<TModelKey = string> extends AxAIOpenAIBase<string, string, TModelKey> {
|
|
1776
|
+
constructor({ apiKey, url, config, options, models, }: Readonly<Omit<AxAIOllamaArgs<TModelKey>, 'name'>>);
|
|
1773
1777
|
}
|
|
1774
1778
|
|
|
1775
1779
|
/**
|
|
@@ -2298,7 +2302,7 @@ Readonly<AxAIOpenAIEmbedResponse>> {
|
|
|
2298
2302
|
declare const axAIOpenAIResponsesDefaultConfig: () => AxAIOpenAIResponsesConfig<AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel>;
|
|
2299
2303
|
declare const axAIOpenAIResponsesBestConfig: () => AxAIOpenAIResponsesConfig<AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel>;
|
|
2300
2304
|
declare const axAIOpenAIResponsesCreativeConfig: () => AxAIOpenAIResponsesConfig<AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel>;
|
|
2301
|
-
interface AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> {
|
|
2305
|
+
interface AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TModelKey, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> {
|
|
2302
2306
|
apiKey: string;
|
|
2303
2307
|
config: AxAIOpenAIResponsesConfig<TModel, TEmbedModel>;
|
|
2304
2308
|
options?: {
|
|
@@ -2306,27 +2310,27 @@ interface AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TResponsesReq extends
|
|
|
2306
2310
|
} & AxAIServiceOptions;
|
|
2307
2311
|
apiURL?: string;
|
|
2308
2312
|
modelInfo?: ReadonlyArray<AxModelInfo>;
|
|
2309
|
-
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
2313
|
+
models?: AxAIInputModelList<TModel, TEmbedModel, TModelKey>;
|
|
2310
2314
|
responsesReqUpdater?: (req: Readonly<TResponsesReq>) => Readonly<TResponsesReq>;
|
|
2311
2315
|
supportFor?: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
2312
2316
|
}
|
|
2313
2317
|
/**
|
|
2314
2318
|
* Base class for OpenAI AI services using the /v1/responses API endpoint
|
|
2315
2319
|
*/
|
|
2316
|
-
declare class AxAIOpenAIResponsesBase<TModel, TEmbedModel, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> extends AxBaseAI<TModel, TEmbedModel, AxAIOpenAIResponsesRequest<TModel>, AxAIOpenAIEmbedRequest<TEmbedModel>, AxAIOpenAIResponsesResponse, AxAIOpenAIResponsesResponseDelta, AxAIOpenAIEmbedResponse> {
|
|
2317
|
-
constructor({ apiKey, config, options, apiURL, modelInfo, models, responsesReqUpdater, supportFor, }: Readonly<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TResponsesReq>>);
|
|
2320
|
+
declare class AxAIOpenAIResponsesBase<TModel, TEmbedModel, TModelKey, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> extends AxBaseAI<TModel, TEmbedModel, AxAIOpenAIResponsesRequest<TModel>, AxAIOpenAIEmbedRequest<TEmbedModel>, AxAIOpenAIResponsesResponse, AxAIOpenAIResponsesResponseDelta, AxAIOpenAIEmbedResponse, TModelKey> {
|
|
2321
|
+
constructor({ apiKey, config, options, apiURL, modelInfo, models, responsesReqUpdater, supportFor, }: Readonly<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TModelKey, TResponsesReq>>);
|
|
2318
2322
|
}
|
|
2319
2323
|
/**
|
|
2320
2324
|
* Ready-to-use implementation of the OpenAI Responses API client
|
|
2321
2325
|
* This class uses OpenAI's /v1/responses API endpoint which supports text, image, and audio inputs
|
|
2322
2326
|
*/
|
|
2323
|
-
interface AxAIOpenAIResponsesArgs<TName = 'openai-responses', TModel = AxAIOpenAIResponsesModel, TEmbedModel = AxAIOpenAIEmbedModel, TChatReq extends AxAIOpenAIResponsesRequest<TModel> = AxAIOpenAIResponsesRequest<TModel>> extends Omit<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TChatReq>, 'config' | 'supportFor' | 'modelInfo'> {
|
|
2327
|
+
interface AxAIOpenAIResponsesArgs<TName = 'openai-responses', TModel = AxAIOpenAIResponsesModel, TEmbedModel = AxAIOpenAIEmbedModel, TModelKey = string, TChatReq extends AxAIOpenAIResponsesRequest<TModel> = AxAIOpenAIResponsesRequest<TModel>> extends Omit<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>, 'config' | 'supportFor' | 'modelInfo'> {
|
|
2324
2328
|
name: TName;
|
|
2325
2329
|
modelInfo?: AxModelInfo[];
|
|
2326
|
-
config?: Partial<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TChatReq>['config']>;
|
|
2330
|
+
config?: Partial<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>['config']>;
|
|
2327
2331
|
}
|
|
2328
|
-
declare class AxAIOpenAIResponses extends AxAIOpenAIResponsesBase<AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, AxAIOpenAIResponsesRequest<AxAIOpenAIResponsesModel>> {
|
|
2329
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIResponsesArgs, 'name'>>);
|
|
2332
|
+
declare class AxAIOpenAIResponses<TModelKey = string> extends AxAIOpenAIResponsesBase<AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, TModelKey, AxAIOpenAIResponsesRequest<AxAIOpenAIResponsesModel>> {
|
|
2333
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIResponsesArgs<'openai-responses', AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
2330
2334
|
}
|
|
2331
2335
|
|
|
2332
2336
|
declare enum AxAIRekaModel {
|
|
@@ -2400,7 +2404,7 @@ declare const axAIRekaDefaultConfig: () => AxAIRekaConfig;
|
|
|
2400
2404
|
declare const axAIRekaBestConfig: () => AxAIRekaConfig;
|
|
2401
2405
|
declare const axAIRekaCreativeConfig: () => AxAIRekaConfig;
|
|
2402
2406
|
declare const axAIRekaFastConfig: () => AxAIRekaConfig;
|
|
2403
|
-
interface AxAIRekaArgs {
|
|
2407
|
+
interface AxAIRekaArgs<TModelKey = string> {
|
|
2404
2408
|
name: 'reka';
|
|
2405
2409
|
apiKey: string;
|
|
2406
2410
|
apiURL?: string;
|
|
@@ -2409,10 +2413,10 @@ interface AxAIRekaArgs {
|
|
|
2409
2413
|
streamingUsage?: boolean;
|
|
2410
2414
|
}>;
|
|
2411
2415
|
modelInfo?: Readonly<AxModelInfo[]>;
|
|
2412
|
-
models?: AxAIInputModelList<AxAIRekaModel, undefined>;
|
|
2416
|
+
models?: AxAIInputModelList<AxAIRekaModel, undefined, TModelKey>;
|
|
2413
2417
|
}
|
|
2414
|
-
declare class AxAIReka extends AxBaseAI<AxAIRekaModel, undefined, AxAIRekaChatRequest, unknown, AxAIRekaChatResponse, AxAIRekaChatResponseDelta, unknown> {
|
|
2415
|
-
constructor({ apiKey, config, options, apiURL, modelInfo, models, }: Readonly<Omit<AxAIRekaArgs
|
|
2418
|
+
declare class AxAIReka<TModelKey = string> extends AxBaseAI<AxAIRekaModel, undefined, AxAIRekaChatRequest, unknown, AxAIRekaChatResponse, AxAIRekaChatResponseDelta, unknown, TModelKey> {
|
|
2419
|
+
constructor({ apiKey, config, options, apiURL, modelInfo, models, }: Readonly<Omit<AxAIRekaArgs<TModelKey>, 'name'>>);
|
|
2416
2420
|
}
|
|
2417
2421
|
|
|
2418
2422
|
/**
|
|
@@ -2422,9 +2426,9 @@ declare const axModelInfoReka: AxModelInfo[];
|
|
|
2422
2426
|
|
|
2423
2427
|
type TogetherAIConfig = AxAIOpenAIConfig<string, unknown>;
|
|
2424
2428
|
declare const axAITogetherDefaultConfig: () => TogetherAIConfig;
|
|
2425
|
-
type AxAITogetherArgs = AxAIOpenAIArgs<'together', string, unknown>;
|
|
2426
|
-
declare class AxAITogether extends AxAIOpenAIBase<string, unknown> {
|
|
2427
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAITogetherArgs
|
|
2429
|
+
type AxAITogetherArgs<TModelKey> = AxAIOpenAIArgs<'together', string, unknown, TModelKey>;
|
|
2430
|
+
declare class AxAITogether<TModelKey = string> extends AxAIOpenAIBase<string, unknown, TModelKey> {
|
|
2431
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAITogetherArgs<TModelKey>, 'name'>>);
|
|
2428
2432
|
}
|
|
2429
2433
|
|
|
2430
2434
|
declare const axModelInfoTogether: AxModelInfo[];
|
|
@@ -2443,30 +2447,6 @@ declare function axValidateChatRequestMessage(item: AxChatRequestMessage): void;
|
|
|
2443
2447
|
*/
|
|
2444
2448
|
declare function axValidateChatResponseResult(results: Readonly<AxChatResponseResult[]> | Readonly<AxChatResponseResult>): void;
|
|
2445
2449
|
|
|
2446
|
-
type AxAIArgs = AxAIOpenAIArgs | AxAIOpenAIResponsesArgs | AxAIAzureOpenAIArgs | AxAITogetherArgs | AxAIAnthropicArgs | AxAIGroqArgs | AxAIGoogleGeminiArgs | AxAICohereArgs | AxAIHuggingFaceArgs | AxAIMistralArgs | AxAIDeepSeekArgs | AxAIOllamaArgs | AxAIRekaArgs;
|
|
2447
|
-
type AxAIModels = AxAIOpenAIModel | AxAIAnthropicModel | AxAIGroqModel | AxAIGoogleGeminiModel | AxAICohereModel | AxAIHuggingFaceModel | AxAIMistralModel | AxAIDeepSeekModel;
|
|
2448
|
-
type AxAIEmbedModels = AxAIOpenAIEmbedModel | AxAIGoogleGeminiEmbedModel | AxAICohereEmbedModel;
|
|
2449
|
-
declare class AxAI implements AxAIService {
|
|
2450
|
-
private ai;
|
|
2451
|
-
constructor(options: Readonly<AxAIArgs>);
|
|
2452
|
-
getName(): string;
|
|
2453
|
-
getId(): string;
|
|
2454
|
-
getFeatures(model?: string): {
|
|
2455
|
-
functions: boolean;
|
|
2456
|
-
streaming: boolean;
|
|
2457
|
-
};
|
|
2458
|
-
getModelList(): AxAIModelList | undefined;
|
|
2459
|
-
getLastUsedChatModel(): unknown;
|
|
2460
|
-
getLastUsedEmbedModel(): unknown;
|
|
2461
|
-
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
2462
|
-
getMetrics(): AxAIServiceMetrics;
|
|
2463
|
-
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
2464
|
-
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions & AxAIServiceActionOptions>): Promise<AxEmbedResponse>;
|
|
2465
|
-
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
2466
|
-
getOptions(): Readonly<AxAIServiceOptions>;
|
|
2467
|
-
getLogger(): AxLoggerFunction;
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
2450
|
declare enum AxAIGrokModel {
|
|
2471
2451
|
Grok3 = "grok-3",
|
|
2472
2452
|
Grok3Mini = "grok-3-mini",
|
|
@@ -2508,14 +2488,38 @@ type AxAIGrokChatRequest = AxAIOpenAIChatRequest<AxAIGrokModel> & {
|
|
|
2508
2488
|
sources?: AxAIGrokSearchSource[];
|
|
2509
2489
|
};
|
|
2510
2490
|
};
|
|
2511
|
-
type AxAIGrokArgs = AxAIOpenAIArgs<'grok', AxAIGrokModel, AxAIGrokEmbedModels, AxAIGrokChatRequest> & {
|
|
2491
|
+
type AxAIGrokArgs<TModelKey = string> = AxAIOpenAIArgs<'grok', AxAIGrokModel, AxAIGrokEmbedModels, TModelKey, AxAIGrokChatRequest> & {
|
|
2512
2492
|
options?: Readonly<AxAIServiceOptions & AxAIGrokOptionsTools> & {
|
|
2513
2493
|
tokensPerMinute?: number;
|
|
2514
2494
|
};
|
|
2515
2495
|
modelInfo?: AxModelInfo[];
|
|
2516
2496
|
};
|
|
2517
|
-
declare class AxAIGrok extends AxAIOpenAIBase<AxAIGrokModel, AxAIGrokEmbedModels, AxAIGrokChatRequest> {
|
|
2518
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIGrokArgs
|
|
2497
|
+
declare class AxAIGrok<TModelKey = string> extends AxAIOpenAIBase<AxAIGrokModel, AxAIGrokEmbedModels, TModelKey, AxAIGrokChatRequest> {
|
|
2498
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIGrokArgs<TModelKey>, 'name'>>);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
type AxAIArgs<TModelKey> = AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> | AxAIOpenAIResponsesArgs<'openai-responses', AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, TModelKey> | AxAIAzureOpenAIArgs<TModelKey> | AxAITogetherArgs<TModelKey> | AxAIAnthropicArgs<TModelKey> | AxAIGroqArgs<TModelKey> | AxAIGoogleGeminiArgs<TModelKey> | AxAICohereArgs<TModelKey> | AxAIHuggingFaceArgs<TModelKey> | AxAIMistralArgs<TModelKey> | AxAIDeepSeekArgs<TModelKey> | AxAIOllamaArgs<TModelKey> | AxAIRekaArgs<TModelKey> | AxAIGrokArgs<TModelKey>;
|
|
2502
|
+
type AxAIModels = AxAIOpenAIModel | AxAIAnthropicModel | AxAIGroqModel | AxAIGoogleGeminiModel | AxAICohereModel | AxAIHuggingFaceModel | AxAIMistralModel | AxAIDeepSeekModel | AxAIGrokModel;
|
|
2503
|
+
type AxAIEmbedModels = AxAIOpenAIEmbedModel | AxAIGoogleGeminiEmbedModel | AxAICohereEmbedModel;
|
|
2504
|
+
declare class AxAI<TModelKey = string> implements AxAIService<unknown, unknown, TModelKey> {
|
|
2505
|
+
private ai;
|
|
2506
|
+
constructor(options: Readonly<AxAIArgs<TModelKey>>);
|
|
2507
|
+
getName(): string;
|
|
2508
|
+
getId(): string;
|
|
2509
|
+
getFeatures(model?: string): {
|
|
2510
|
+
functions: boolean;
|
|
2511
|
+
streaming: boolean;
|
|
2512
|
+
};
|
|
2513
|
+
getModelList(): AxAIModelList<TModelKey> | undefined;
|
|
2514
|
+
getLastUsedChatModel(): unknown;
|
|
2515
|
+
getLastUsedEmbedModel(): unknown;
|
|
2516
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
2517
|
+
getMetrics(): AxAIServiceMetrics;
|
|
2518
|
+
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown, TModelKey>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
2519
|
+
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions<unknown, unknown, TModelKey>>): Promise<AxEmbedResponse>;
|
|
2520
|
+
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
2521
|
+
getOptions(): Readonly<AxAIServiceOptions>;
|
|
2522
|
+
getLogger(): AxLoggerFunction;
|
|
2519
2523
|
}
|
|
2520
2524
|
|
|
2521
2525
|
declare const axModelInfoGrok: AxModelInfo[];
|
|
@@ -2941,13 +2945,13 @@ type AxResultPickerFunctionFunctionResults = {
|
|
|
2941
2945
|
}[];
|
|
2942
2946
|
};
|
|
2943
2947
|
type AxResultPickerFunction<OUT extends AxGenOut> = (data: AxResultPickerFunctionFieldResults<OUT> | AxResultPickerFunctionFunctionResults) => number | Promise<number>;
|
|
2944
|
-
type AxProgramForwardOptions = {
|
|
2948
|
+
type AxProgramForwardOptions<MODEL> = {
|
|
2945
2949
|
maxRetries?: number;
|
|
2946
2950
|
maxSteps?: number;
|
|
2947
2951
|
mem?: AxAIMemory;
|
|
2948
2952
|
ai?: AxAIService;
|
|
2949
2953
|
modelConfig?: AxModelConfig;
|
|
2950
|
-
model?:
|
|
2954
|
+
model?: MODEL;
|
|
2951
2955
|
sessionId?: string;
|
|
2952
2956
|
traceId?: string | undefined;
|
|
2953
2957
|
tracer?: Tracer;
|
|
@@ -2974,7 +2978,7 @@ type AxProgramForwardOptions = {
|
|
|
2974
2978
|
excludeContentFromTrace?: boolean;
|
|
2975
2979
|
strictMode?: boolean;
|
|
2976
2980
|
};
|
|
2977
|
-
type AxProgramStreamingForwardOptions = Omit<AxProgramForwardOptions
|
|
2981
|
+
type AxProgramStreamingForwardOptions<MODEL> = Omit<AxProgramForwardOptions<MODEL>, 'stream'>;
|
|
2978
2982
|
type AxGenDeltaOut<OUT extends AxGenOut> = {
|
|
2979
2983
|
version: number;
|
|
2980
2984
|
index: number;
|
|
@@ -2982,9 +2986,9 @@ type AxGenDeltaOut<OUT extends AxGenOut> = {
|
|
|
2982
2986
|
};
|
|
2983
2987
|
type AxGenStreamingOut<OUT extends AxGenOut> = AsyncGenerator<AxGenDeltaOut<OUT>, void, unknown>;
|
|
2984
2988
|
type AxSetExamplesOptions = {};
|
|
2985
|
-
interface AxForwardable<IN extends AxGenIn, OUT extends AxGenOut> {
|
|
2986
|
-
forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions
|
|
2987
|
-
streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions
|
|
2989
|
+
interface AxForwardable<IN extends AxGenIn, OUT extends AxGenOut, TModelKey> {
|
|
2990
|
+
forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions<TModelKey>>): Promise<OUT>;
|
|
2991
|
+
streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions<TModelKey>>): AxGenStreamingOut<OUT>;
|
|
2988
2992
|
}
|
|
2989
2993
|
interface AxTunable<IN extends AxGenIn, OUT extends AxGenOut> {
|
|
2990
2994
|
setExamples: (examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>) => void;
|
|
@@ -2997,7 +3001,7 @@ interface AxUsable {
|
|
|
2997
3001
|
getUsage: () => AxProgramUsage[];
|
|
2998
3002
|
resetUsage: () => void;
|
|
2999
3003
|
}
|
|
3000
|
-
interface AxProgrammable<IN extends AxGenIn, OUT extends AxGenOut> extends AxForwardable<IN, OUT>, AxTunable<IN, OUT>, AxUsable {
|
|
3004
|
+
interface AxProgrammable<IN extends AxGenIn, OUT extends AxGenOut, TModelKey = string> extends AxForwardable<IN, OUT, TModelKey>, AxTunable<IN, OUT>, AxUsable {
|
|
3001
3005
|
getSignature: () => AxSignature;
|
|
3002
3006
|
}
|
|
3003
3007
|
type AxProgramUsage = AxChatResponse['modelUsage'] & {
|
|
@@ -3111,7 +3115,7 @@ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOu
|
|
|
3111
3115
|
private streamingFieldProcessors;
|
|
3112
3116
|
private excludeContentFromTrace;
|
|
3113
3117
|
private thoughtFieldName;
|
|
3114
|
-
constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>, options?: Readonly<AxProgramForwardOptions
|
|
3118
|
+
constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>, options?: Readonly<AxProgramForwardOptions<any>>);
|
|
3115
3119
|
private getSignatureName;
|
|
3116
3120
|
private getMetricsInstruments;
|
|
3117
3121
|
updateMeter(meter?: Meter): void;
|
|
@@ -3124,9 +3128,9 @@ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOu
|
|
|
3124
3128
|
private forwardSendRequest;
|
|
3125
3129
|
private forwardCore;
|
|
3126
3130
|
private _forward2;
|
|
3127
|
-
_forward1(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options: Readonly<AxProgramForwardOptions
|
|
3128
|
-
forward
|
|
3129
|
-
streamingForward
|
|
3131
|
+
_forward1(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options: Readonly<AxProgramForwardOptions<any>>): AxGenStreamingOut<OUT>;
|
|
3132
|
+
forward<T extends Readonly<AxAIService>>(ai: T, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>>): Promise<OUT>;
|
|
3133
|
+
streamingForward<T extends Readonly<AxAIService>>(ai: T, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>>): AxGenStreamingOut<OUT>;
|
|
3130
3134
|
setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;
|
|
3131
3135
|
private isDebug;
|
|
3132
3136
|
private getLogger;
|
|
@@ -3197,8 +3201,8 @@ declare class AxDBManager {
|
|
|
3197
3201
|
}
|
|
3198
3202
|
|
|
3199
3203
|
declare class AxDefaultResultReranker extends AxGen<AxRerankerIn, AxRerankerOut> {
|
|
3200
|
-
constructor(options?: Readonly<AxProgramForwardOptions
|
|
3201
|
-
forward:
|
|
3204
|
+
constructor(options?: Readonly<AxProgramForwardOptions<string>>);
|
|
3205
|
+
forward: <T extends Readonly<AxAIService>>(ai: T, input: Readonly<AxRerankerIn>, options?: Readonly<AxProgramForwardOptions<NonNullable<ReturnType<T["getModelList"]>>[number]["key"]>>) => Promise<AxRerankerOut>;
|
|
3202
3206
|
}
|
|
3203
3207
|
|
|
3204
3208
|
interface AxApacheTikaArgs {
|
|
@@ -4289,11 +4293,11 @@ interface AxFlowNodeDefinition {
|
|
|
4289
4293
|
}
|
|
4290
4294
|
type AxFlowStepFunction = (state: AxFlowState, context: Readonly<{
|
|
4291
4295
|
mainAi: AxAIService;
|
|
4292
|
-
mainOptions?: AxProgramForwardOptions
|
|
4296
|
+
mainOptions?: AxProgramForwardOptions<string>;
|
|
4293
4297
|
}>) => Promise<AxFlowState> | AxFlowState;
|
|
4294
|
-
interface AxFlowDynamicContext {
|
|
4295
|
-
ai?:
|
|
4296
|
-
options?: AxProgramForwardOptions
|
|
4298
|
+
interface AxFlowDynamicContext<T extends Readonly<AxAIService>> {
|
|
4299
|
+
ai?: T;
|
|
4300
|
+
options?: AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>;
|
|
4297
4301
|
}
|
|
4298
4302
|
type GetGenIn<T extends AxProgrammable<AxGenIn, AxGenOut>> = T extends AxProgrammable<infer IN, AxGenOut> ? IN : never;
|
|
4299
4303
|
type GetGenOut<T extends AxProgrammable<AxGenIn, AxGenOut>> = T extends AxProgrammable<AxGenIn, infer OUT> ? OUT : never;
|
|
@@ -4310,20 +4314,20 @@ interface AxFlowable<IN extends AxGenIn, OUT extends AxGenOut> extends AxProgram
|
|
|
4310
4314
|
}
|
|
4311
4315
|
type AxFlowTypedParallelBranch<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> = (subFlow: AxFlowTypedSubContext<TNodes, TState>) => AxFlowTypedSubContext<TNodes, AxFlowState>;
|
|
4312
4316
|
interface AxFlowTypedSubContext<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> {
|
|
4313
|
-
execute<TNodeName extends keyof TNodes & string
|
|
4317
|
+
execute<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlowTypedSubContext<TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
4314
4318
|
map<TNewState extends AxFlowState>(transform: (state: TState) => TNewState): AxFlowTypedSubContext<TNodes, TNewState>;
|
|
4315
4319
|
executeSteps(initialState: TState, context: Readonly<{
|
|
4316
4320
|
mainAi: AxAIService;
|
|
4317
|
-
mainOptions?: AxProgramForwardOptions
|
|
4321
|
+
mainOptions?: AxProgramForwardOptions<string>;
|
|
4318
4322
|
}>): Promise<AxFlowState>;
|
|
4319
4323
|
}
|
|
4320
4324
|
type AxFlowParallelBranch = (subFlow: AxFlowSubContext) => AxFlowSubContext;
|
|
4321
4325
|
interface AxFlowSubContext {
|
|
4322
|
-
execute(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext): this;
|
|
4326
|
+
execute<TAI extends Readonly<AxAIService>>(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext<TAI>): this;
|
|
4323
4327
|
map(transform: (state: AxFlowState) => AxFlowState): this;
|
|
4324
|
-
executeSteps(initialState: AxFlowState, context: Readonly<{
|
|
4325
|
-
mainAi:
|
|
4326
|
-
mainOptions?: AxProgramForwardOptions
|
|
4328
|
+
executeSteps<TAI extends Readonly<AxAIService>>(initialState: AxFlowState, context: Readonly<{
|
|
4329
|
+
mainAi: TAI;
|
|
4330
|
+
mainOptions?: AxProgramForwardOptions<NonNullable<ReturnType<TAI['getModelList']>>[number]['key']>;
|
|
4327
4331
|
}>): Promise<AxFlowState>;
|
|
4328
4332
|
}
|
|
4329
4333
|
interface AxFlowBranchContext {
|
|
@@ -4597,6 +4601,8 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4597
4601
|
private readonly autoParallelConfig;
|
|
4598
4602
|
private readonly executionPlanner;
|
|
4599
4603
|
private program?;
|
|
4604
|
+
private nodeUsage;
|
|
4605
|
+
private nodeTraces;
|
|
4600
4606
|
/**
|
|
4601
4607
|
* Converts a string to camelCase for valid field names
|
|
4602
4608
|
*/
|
|
@@ -4636,7 +4642,26 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4636
4642
|
setDemos(demos: readonly AxProgramDemos<IN, OUT>[]): void;
|
|
4637
4643
|
getUsage(): AxProgramUsage[];
|
|
4638
4644
|
resetUsage(): void;
|
|
4639
|
-
|
|
4645
|
+
/**
|
|
4646
|
+
* Resets trace tracking for the flow.
|
|
4647
|
+
* This is called automatically on each forward/streamingForward call.
|
|
4648
|
+
*/
|
|
4649
|
+
resetTraces(): void;
|
|
4650
|
+
/**
|
|
4651
|
+
* Gets a detailed usage report broken down by node name.
|
|
4652
|
+
* This provides visibility into which nodes are consuming the most tokens.
|
|
4653
|
+
*
|
|
4654
|
+
* @returns Object mapping node names to their usage statistics
|
|
4655
|
+
*/
|
|
4656
|
+
getUsageReport(): Record<string, AxProgramUsage[]>;
|
|
4657
|
+
/**
|
|
4658
|
+
* Gets a detailed trace report broken down by node name.
|
|
4659
|
+
* This provides visibility into the execution traces for each node.
|
|
4660
|
+
*
|
|
4661
|
+
* @returns Object mapping node names to their trace data
|
|
4662
|
+
*/
|
|
4663
|
+
getTracesReport(): Record<string, AxProgramTrace<any, any>[]>;
|
|
4664
|
+
streamingForward<T extends Readonly<AxAIService>>(ai: T, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>>): AxGenStreamingOut<OUT>;
|
|
4640
4665
|
/**
|
|
4641
4666
|
* Executes the flow with the given AI service and input values.
|
|
4642
4667
|
*
|
|
@@ -4667,7 +4692,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4667
4692
|
* @param options - Optional forward options to use as defaults (includes autoParallel override)
|
|
4668
4693
|
* @returns Promise that resolves to the final output
|
|
4669
4694
|
*/
|
|
4670
|
-
forward
|
|
4695
|
+
forward<T extends Readonly<AxAIService>>(ai: T, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']> & {
|
|
4671
4696
|
autoParallel?: boolean;
|
|
4672
4697
|
}>): Promise<OUT>;
|
|
4673
4698
|
/**
|
|
@@ -4676,7 +4701,6 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4676
4701
|
*
|
|
4677
4702
|
* @param name - The name of the node
|
|
4678
4703
|
* @param signature - Signature string in the same format as AxSignature
|
|
4679
|
-
* @param options - Optional program forward options (same as AxGen)
|
|
4680
4704
|
* @returns New AxFlow instance with updated TNodes type
|
|
4681
4705
|
*
|
|
4682
4706
|
* @example
|
|
@@ -4685,7 +4709,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4685
4709
|
* flow.node('analyzer', 'text:string -> analysis:string, confidence:number', { debug: true })
|
|
4686
4710
|
* ```
|
|
4687
4711
|
*/
|
|
4688
|
-
node<TName extends string, TSig extends string>(name: TName, signature: TSig
|
|
4712
|
+
node<TName extends string, TSig extends string>(name: TName, signature: TSig): AxFlow<IN, OUT, TNodes & {
|
|
4689
4713
|
[K in TName]: InferAxGen<TSig>;
|
|
4690
4714
|
}, // Add new node to registry
|
|
4691
4715
|
TState>;
|
|
@@ -4695,7 +4719,6 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4695
4719
|
*
|
|
4696
4720
|
* @param name - The name of the node
|
|
4697
4721
|
* @param signature - AxSignature instance to use for this node
|
|
4698
|
-
* @param options - Optional program forward options (same as AxGen)
|
|
4699
4722
|
* @returns New AxFlow instance with updated TNodes type
|
|
4700
4723
|
*
|
|
4701
4724
|
* @example
|
|
@@ -4704,7 +4727,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4704
4727
|
* flow.node('summarizer', sig, { temperature: 0.1 })
|
|
4705
4728
|
* ```
|
|
4706
4729
|
*/
|
|
4707
|
-
node<TName extends string>(name: TName, signature: AxSignature
|
|
4730
|
+
node<TName extends string>(name: TName, signature: AxSignature): AxFlow<IN, OUT, TNodes & {
|
|
4708
4731
|
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
4709
4732
|
}, // Add new node to registry
|
|
4710
4733
|
TState>;
|
|
@@ -4743,10 +4766,10 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4743
4766
|
/**
|
|
4744
4767
|
* Short alias for node() - supports signature strings, AxSignature instances, AxGen instances, and program classes
|
|
4745
4768
|
*/
|
|
4746
|
-
n<TName extends string, TSig extends string>(name: TName, signature: TSig
|
|
4769
|
+
n<TName extends string, TSig extends string>(name: TName, signature: TSig): AxFlow<IN, OUT, TNodes & {
|
|
4747
4770
|
[K in TName]: InferAxGen<TSig>;
|
|
4748
4771
|
}, TState>;
|
|
4749
|
-
n<TName extends string>(name: TName, signature: AxSignature
|
|
4772
|
+
n<TName extends string>(name: TName, signature: AxSignature): AxFlow<IN, OUT, TNodes & {
|
|
4750
4773
|
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
4751
4774
|
}, TState>;
|
|
4752
4775
|
n<TName extends string, TProgram extends new () => AxProgrammable<any, any>>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & {
|
|
@@ -4831,11 +4854,11 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4831
4854
|
* flow.execute('summarizer', state => ({ text: state.originalText }), { ai: cheapAI })
|
|
4832
4855
|
* ```
|
|
4833
4856
|
*/
|
|
4834
|
-
execute<TNodeName extends keyof TNodes & string
|
|
4857
|
+
execute<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
4835
4858
|
/**
|
|
4836
4859
|
* Short alias for execute()
|
|
4837
4860
|
*/
|
|
4838
|
-
e<TNodeName extends keyof TNodes & string
|
|
4861
|
+
e<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
4839
4862
|
/**
|
|
4840
4863
|
* Starts a conditional branch based on a predicate function.
|
|
4841
4864
|
*
|
|
@@ -5046,12 +5069,12 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
5046
5069
|
declare class AxFlowSubContextImpl implements AxFlowSubContext {
|
|
5047
5070
|
private readonly nodeGenerators;
|
|
5048
5071
|
private readonly steps;
|
|
5049
|
-
constructor(nodeGenerators: Map<string, AxForwardable<AxGenIn, AxGenOut> & AxTunable<AxGenIn, AxGenOut> & AxUsable>);
|
|
5050
|
-
execute(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext): this;
|
|
5072
|
+
constructor(nodeGenerators: Map<string, AxForwardable<AxGenIn, AxGenOut, string> & AxTunable<AxGenIn, AxGenOut> & AxUsable>);
|
|
5073
|
+
execute<TAI extends Readonly<AxAIService>>(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext<TAI>): this;
|
|
5051
5074
|
map(transform: (state: AxFlowState) => AxFlowState): this;
|
|
5052
5075
|
executeSteps(initialState: AxFlowState, context: Readonly<{
|
|
5053
5076
|
mainAi: AxAIService;
|
|
5054
|
-
mainOptions?: AxProgramForwardOptions
|
|
5077
|
+
mainOptions?: AxProgramForwardOptions<string>;
|
|
5055
5078
|
}>): Promise<AxFlowState>;
|
|
5056
5079
|
}
|
|
5057
5080
|
/**
|
|
@@ -5061,11 +5084,11 @@ declare class AxFlowTypedSubContextImpl<TNodes extends Record<string, AxGen<any,
|
|
|
5061
5084
|
private readonly nodeGenerators;
|
|
5062
5085
|
private readonly steps;
|
|
5063
5086
|
constructor(nodeGenerators: Map<string, AxGen<AxGenIn, AxGenOut> | AxProgram<AxGenIn, AxGenOut>>);
|
|
5064
|
-
execute<TNodeName extends keyof TNodes & string
|
|
5087
|
+
execute<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlowTypedSubContext<TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
5065
5088
|
map<TNewState extends AxFlowState>(transform: (state: TState) => TNewState): AxFlowTypedSubContext<TNodes, TNewState>;
|
|
5066
5089
|
executeSteps(initialState: TState, context: Readonly<{
|
|
5067
5090
|
mainAi: AxAIService;
|
|
5068
|
-
mainOptions?: AxProgramForwardOptions
|
|
5091
|
+
mainOptions?: AxProgramForwardOptions<string>;
|
|
5069
5092
|
}>): Promise<AxFlowState>;
|
|
5070
5093
|
}
|
|
5071
5094
|
|
|
@@ -5405,7 +5428,7 @@ interface AxAgentic<IN extends AxGenIn, OUT extends AxGenOut> extends AxProgramm
|
|
|
5405
5428
|
getFunction(): AxFunction;
|
|
5406
5429
|
getFeatures(): AxAgentFeatures;
|
|
5407
5430
|
}
|
|
5408
|
-
type AxAgentOptions = Omit<AxProgramForwardOptions
|
|
5431
|
+
type AxAgentOptions = Omit<AxProgramForwardOptions<string>, 'functions'> & {
|
|
5409
5432
|
disableSmartModelRouting?: boolean;
|
|
5410
5433
|
/** List of field names that should not be automatically passed from parent to child agents */
|
|
5411
5434
|
excludeFieldsFromPassthrough?: string[];
|
|
@@ -5456,8 +5479,8 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
5456
5479
|
* Initializes the agent's execution context, processing child agents and their functions.
|
|
5457
5480
|
*/
|
|
5458
5481
|
private init;
|
|
5459
|
-
forward
|
|
5460
|
-
streamingForward
|
|
5482
|
+
forward<T extends Readonly<AxAIService>>(parentAi: T, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>>): Promise<OUT>;
|
|
5483
|
+
streamingForward<T extends Readonly<AxAIService>>(parentAi: T, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>>): AxGenStreamingOut<OUT>;
|
|
5461
5484
|
/**
|
|
5462
5485
|
* Updates the agent's description.
|
|
5463
5486
|
* This updates both the stored description and the function's description.
|
|
@@ -5473,7 +5496,7 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
5473
5496
|
}
|
|
5474
5497
|
|
|
5475
5498
|
declare class AxChainOfThought<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxGen<IN, OUT> {
|
|
5476
|
-
constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxProgramForwardOptions & {
|
|
5499
|
+
constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxProgramForwardOptions<string> & {
|
|
5477
5500
|
setVisibleReasoning?: boolean;
|
|
5478
5501
|
}>);
|
|
5479
5502
|
}
|
|
@@ -5487,16 +5510,16 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
5487
5510
|
private genQuery;
|
|
5488
5511
|
private queryFn;
|
|
5489
5512
|
private maxHops;
|
|
5490
|
-
constructor(queryFn: (query: string) => Promise<string>, options: Readonly<AxProgramForwardOptions & {
|
|
5513
|
+
constructor(queryFn: (query: string) => Promise<string>, options: Readonly<AxProgramForwardOptions<string> & {
|
|
5491
5514
|
maxHops?: number;
|
|
5492
5515
|
}>);
|
|
5493
|
-
forward
|
|
5516
|
+
forward<T extends Readonly<AxAIService>>(ai: T, values: {
|
|
5494
5517
|
context: string[];
|
|
5495
5518
|
question: string;
|
|
5496
5519
|
} | AxMessage<{
|
|
5497
5520
|
context: string[];
|
|
5498
5521
|
question: string;
|
|
5499
|
-
}>[], options?: Readonly<AxProgramForwardOptions
|
|
5522
|
+
}>[], options?: Readonly<AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>>): Promise<{
|
|
5500
5523
|
answer: string;
|
|
5501
5524
|
}>;
|
|
5502
5525
|
}
|