@ax-llm/ax 11.0.37 → 11.0.39
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 +98 -8
- package/index.cjs.map +1 -1
- package/index.d.cts +99 -77
- package/index.d.ts +99 -77
- package/index.js +98 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReadableStream as ReadableStream$1 } from 'stream/web';
|
|
2
|
-
import { ReadableStream } from 'node:stream/web';
|
|
1
|
+
import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
|
|
3
2
|
import { Span, Tracer } from '@opentelemetry/api';
|
|
3
|
+
import { ReadableStream } from 'stream/web';
|
|
4
4
|
|
|
5
5
|
interface RetryConfig {
|
|
6
6
|
maxRetries: number;
|
|
@@ -61,6 +61,76 @@ declare class AxAIServiceAuthenticationError extends AxAIServiceError {
|
|
|
61
61
|
constructor(url: string, requestBody?: unknown, context?: Record<string, unknown>);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
interface AxAIFeatures {
|
|
65
|
+
functions: boolean;
|
|
66
|
+
streaming: boolean;
|
|
67
|
+
functionCot?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
70
|
+
name: string;
|
|
71
|
+
apiURL: string;
|
|
72
|
+
headers: () => Promise<Record<string, string>>;
|
|
73
|
+
modelInfo: Readonly<AxModelInfo[]>;
|
|
74
|
+
defaults: Readonly<{
|
|
75
|
+
model: TModel;
|
|
76
|
+
embedModel?: TEmbedModel;
|
|
77
|
+
}>;
|
|
78
|
+
options?: Readonly<AxAIServiceOptions>;
|
|
79
|
+
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
80
|
+
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
81
|
+
}
|
|
82
|
+
declare const axBaseAIDefaultConfig: () => AxModelConfig;
|
|
83
|
+
declare const axBaseAIDefaultCreativeConfig: () => AxModelConfig;
|
|
84
|
+
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse> implements AxAIService<TModel, TEmbedModel> {
|
|
85
|
+
private readonly aiImpl;
|
|
86
|
+
private debug;
|
|
87
|
+
private rt?;
|
|
88
|
+
private fetch?;
|
|
89
|
+
private tracer?;
|
|
90
|
+
private models?;
|
|
91
|
+
private modelInfo;
|
|
92
|
+
private modelUsage?;
|
|
93
|
+
private embedModelUsage?;
|
|
94
|
+
private defaults;
|
|
95
|
+
private lastUsedModelConfig?;
|
|
96
|
+
private lastUsedChatModel?;
|
|
97
|
+
private lastUsedEmbedModel?;
|
|
98
|
+
protected apiURL: string;
|
|
99
|
+
protected name: string;
|
|
100
|
+
protected id: string;
|
|
101
|
+
protected headers: () => Promise<Record<string, string>>;
|
|
102
|
+
protected supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
103
|
+
private metrics;
|
|
104
|
+
constructor(aiImpl: Readonly<AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse>>, { name, apiURL, headers, modelInfo, defaults, options, supportFor, models, }: Readonly<AxBaseAIArgs<TModel, TEmbedModel>>);
|
|
105
|
+
setName(name: string): void;
|
|
106
|
+
getId(): string;
|
|
107
|
+
setAPIURL(apiURL: string): void;
|
|
108
|
+
setHeaders(headers: () => Promise<Record<string, string>>): void;
|
|
109
|
+
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
110
|
+
getOptions(): Readonly<AxAIServiceOptions>;
|
|
111
|
+
getModelList(): AxAIModelList | undefined;
|
|
112
|
+
getName(): string;
|
|
113
|
+
getFeatures(model?: TModel): AxAIFeatures;
|
|
114
|
+
getLastUsedChatModel(): TModel | undefined;
|
|
115
|
+
getLastUsedEmbedModel(): TEmbedModel | undefined;
|
|
116
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
117
|
+
private calculatePercentile;
|
|
118
|
+
private updateLatencyMetrics;
|
|
119
|
+
private updateErrorMetrics;
|
|
120
|
+
getMetrics(): AxAIServiceMetrics;
|
|
121
|
+
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
122
|
+
private _chat1;
|
|
123
|
+
private cleanupFunctionSchema;
|
|
124
|
+
private _chat2;
|
|
125
|
+
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
126
|
+
private _embed1;
|
|
127
|
+
private _embed2;
|
|
128
|
+
private buildHeaders;
|
|
129
|
+
private getModelByKey;
|
|
130
|
+
private getModel;
|
|
131
|
+
private getEmbedModel;
|
|
132
|
+
}
|
|
133
|
+
|
|
64
134
|
type AxAIInputModelList<TModel, TEmbedModel> = (AxAIModelListBase & {
|
|
65
135
|
isInternal?: boolean;
|
|
66
136
|
} & ({
|
|
@@ -249,9 +319,9 @@ type AxEmbedRequest<TEmbedModel = string> = {
|
|
|
249
319
|
embedModel?: TEmbedModel;
|
|
250
320
|
};
|
|
251
321
|
type AxInternalEmbedRequest<TEmbedModel> = Omit<AxEmbedRequest, 'embedModel'> & Required<Pick<AxEmbedRequest<TEmbedModel>, 'embedModel'>>;
|
|
252
|
-
type AxRateLimiterFunction = <T = unknown>(reqFunc: () => Promise<T | ReadableStream<T>>, info: Readonly<{
|
|
322
|
+
type AxRateLimiterFunction = <T = unknown>(reqFunc: () => Promise<T | ReadableStream$1<T>>, info: Readonly<{
|
|
253
323
|
modelUsage?: AxModelUsage;
|
|
254
|
-
}>) => Promise<T | ReadableStream<T>>;
|
|
324
|
+
}>) => Promise<T | ReadableStream$1<T>>;
|
|
255
325
|
type AxAIPromptConfig = {
|
|
256
326
|
stream?: boolean;
|
|
257
327
|
};
|
|
@@ -275,7 +345,10 @@ interface AxAIService<TModel = unknown, TEmbedModel = unknown> {
|
|
|
275
345
|
getFeatures(model?: TModel): AxAIFeatures;
|
|
276
346
|
getModelList(): AxAIModelList | undefined;
|
|
277
347
|
getMetrics(): AxAIServiceMetrics;
|
|
278
|
-
|
|
348
|
+
getLastUsedChatModel(): TModel | undefined;
|
|
349
|
+
getLastUsedEmbedModel(): TEmbedModel | undefined;
|
|
350
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
351
|
+
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream$1<AxChatResponse>>;
|
|
279
352
|
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
280
353
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
281
354
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -290,70 +363,6 @@ interface AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TCha
|
|
|
290
363
|
getTokenUsage(): AxTokenUsage | undefined;
|
|
291
364
|
}
|
|
292
365
|
|
|
293
|
-
interface AxAIFeatures {
|
|
294
|
-
functions: boolean;
|
|
295
|
-
streaming: boolean;
|
|
296
|
-
functionCot?: boolean;
|
|
297
|
-
}
|
|
298
|
-
interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
299
|
-
name: string;
|
|
300
|
-
apiURL: string;
|
|
301
|
-
headers: () => Promise<Record<string, string>>;
|
|
302
|
-
modelInfo: Readonly<AxModelInfo[]>;
|
|
303
|
-
defaults: Readonly<{
|
|
304
|
-
model: TModel;
|
|
305
|
-
embedModel?: TEmbedModel;
|
|
306
|
-
}>;
|
|
307
|
-
options?: Readonly<AxAIServiceOptions>;
|
|
308
|
-
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
309
|
-
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
310
|
-
}
|
|
311
|
-
declare const axBaseAIDefaultConfig: () => AxModelConfig;
|
|
312
|
-
declare const axBaseAIDefaultCreativeConfig: () => AxModelConfig;
|
|
313
|
-
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse> implements AxAIService<TModel, TEmbedModel> {
|
|
314
|
-
private readonly aiImpl;
|
|
315
|
-
private debug;
|
|
316
|
-
private rt?;
|
|
317
|
-
private fetch?;
|
|
318
|
-
private tracer?;
|
|
319
|
-
private models?;
|
|
320
|
-
private modelInfo;
|
|
321
|
-
private modelUsage?;
|
|
322
|
-
private embedModelUsage?;
|
|
323
|
-
private defaults;
|
|
324
|
-
protected apiURL: string;
|
|
325
|
-
protected name: string;
|
|
326
|
-
protected id: string;
|
|
327
|
-
protected headers: () => Promise<Record<string, string>>;
|
|
328
|
-
protected supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
329
|
-
private metrics;
|
|
330
|
-
constructor(aiImpl: Readonly<AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse>>, { name, apiURL, headers, modelInfo, defaults, options, supportFor, models, }: Readonly<AxBaseAIArgs<TModel, TEmbedModel>>);
|
|
331
|
-
setName(name: string): void;
|
|
332
|
-
getId(): string;
|
|
333
|
-
setAPIURL(apiURL: string): void;
|
|
334
|
-
setHeaders(headers: () => Promise<Record<string, string>>): void;
|
|
335
|
-
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
336
|
-
getOptions(): Readonly<AxAIServiceOptions>;
|
|
337
|
-
getModelList(): AxAIModelList | undefined;
|
|
338
|
-
getName(): string;
|
|
339
|
-
getFeatures(model?: TModel): AxAIFeatures;
|
|
340
|
-
private calculatePercentile;
|
|
341
|
-
private updateLatencyMetrics;
|
|
342
|
-
private updateErrorMetrics;
|
|
343
|
-
getMetrics(): AxAIServiceMetrics;
|
|
344
|
-
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream$1<AxChatResponse>>;
|
|
345
|
-
private _chat1;
|
|
346
|
-
private cleanupFunctionSchema;
|
|
347
|
-
private _chat2;
|
|
348
|
-
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
349
|
-
private _embed1;
|
|
350
|
-
private _embed2;
|
|
351
|
-
private buildHeaders;
|
|
352
|
-
private getModelByKey;
|
|
353
|
-
private getModel;
|
|
354
|
-
private getEmbedModel;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
366
|
declare enum AxAIAnthropicModel {
|
|
358
367
|
Claude37Sonnet = "claude-3-7-sonnet-latest",
|
|
359
368
|
Claude35Sonnet = "claude-3-5-sonnet-latest",
|
|
@@ -1358,8 +1367,11 @@ declare class AxAI implements AxAIService {
|
|
|
1358
1367
|
streaming: boolean;
|
|
1359
1368
|
};
|
|
1360
1369
|
getModelList(): AxAIModelList | undefined;
|
|
1370
|
+
getLastUsedChatModel(): unknown;
|
|
1371
|
+
getLastUsedEmbedModel(): unknown;
|
|
1372
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
1361
1373
|
getMetrics(): AxAIServiceMetrics;
|
|
1362
|
-
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions>): Promise<AxChatResponse | ReadableStream
|
|
1374
|
+
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1363
1375
|
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions & AxAIServiceActionOptions>): Promise<AxEmbedResponse>;
|
|
1364
1376
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
1365
1377
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -1931,6 +1943,9 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1931
1943
|
private maxRetries;
|
|
1932
1944
|
private serviceFailures;
|
|
1933
1945
|
constructor(services: readonly AxAIService[], options?: AxBalancerOptions);
|
|
1946
|
+
getLastUsedChatModel(): unknown;
|
|
1947
|
+
getLastUsedEmbedModel(): unknown;
|
|
1948
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
1934
1949
|
/**
|
|
1935
1950
|
* Service comparator that respects the input order of services.
|
|
1936
1951
|
*/
|
|
@@ -1949,7 +1964,7 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1949
1964
|
private canRetryService;
|
|
1950
1965
|
private handleFailure;
|
|
1951
1966
|
private handleSuccess;
|
|
1952
|
-
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions> | undefined): Promise<AxChatResponse | ReadableStream
|
|
1967
|
+
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions> | undefined): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1953
1968
|
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions> | undefined): Promise<AxEmbedResponse>;
|
|
1954
1969
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
1955
1970
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -2524,7 +2539,7 @@ type AxMockAIServiceConfig = {
|
|
|
2524
2539
|
};
|
|
2525
2540
|
models?: AxAIModelList;
|
|
2526
2541
|
options?: AxAIServiceOptions;
|
|
2527
|
-
chatResponse?: AxChatResponse | ReadableStream
|
|
2542
|
+
chatResponse?: AxChatResponse | ReadableStream<AxChatResponse> | (() => Promise<AxChatResponse | ReadableStream<AxChatResponse>>) | ((req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>) => Promise<AxChatResponse | ReadableStream<AxChatResponse>>);
|
|
2528
2543
|
embedResponse?: AxEmbedResponse | ((req: Readonly<AxEmbedRequest>) => AxEmbedResponse | Promise<AxEmbedResponse>);
|
|
2529
2544
|
shouldError?: boolean;
|
|
2530
2545
|
errorMessage?: string;
|
|
@@ -2534,6 +2549,9 @@ declare class AxMockAIService implements AxAIService {
|
|
|
2534
2549
|
private readonly config;
|
|
2535
2550
|
private metrics;
|
|
2536
2551
|
constructor(config?: AxMockAIServiceConfig);
|
|
2552
|
+
getLastUsedChatModel(): unknown;
|
|
2553
|
+
getLastUsedEmbedModel(): unknown;
|
|
2554
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
2537
2555
|
getName(): string;
|
|
2538
2556
|
getId(): string;
|
|
2539
2557
|
getFeatures(_model?: string): {
|
|
@@ -2542,7 +2560,7 @@ declare class AxMockAIService implements AxAIService {
|
|
|
2542
2560
|
};
|
|
2543
2561
|
getModelList(): AxAIModelList | undefined;
|
|
2544
2562
|
getMetrics(): AxAIServiceMetrics;
|
|
2545
|
-
chat(req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>): Promise<AxChatResponse | ReadableStream
|
|
2563
|
+
chat(req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
2546
2564
|
embed(req: Readonly<AxEmbedRequest>, _options?: Readonly<AxAIServiceActionOptions>): Promise<AxEmbedResponse>;
|
|
2547
2565
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
2548
2566
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -2810,25 +2828,29 @@ declare class AxMCPStdioTransport implements AxMCPTransport {
|
|
|
2810
2828
|
connect(): Promise<void>;
|
|
2811
2829
|
}
|
|
2812
2830
|
|
|
2813
|
-
type AxAIServiceListItem = {
|
|
2831
|
+
type AxAIServiceListItem<TModel = unknown, TEmbedModel = unknown> = {
|
|
2814
2832
|
key: string;
|
|
2815
|
-
service: AxAIService
|
|
2833
|
+
service: AxAIService<TModel, TEmbedModel>;
|
|
2816
2834
|
description: string;
|
|
2817
2835
|
isInternal?: boolean;
|
|
2818
2836
|
};
|
|
2819
2837
|
declare class AxMultiServiceRouter implements AxAIService<string, string> {
|
|
2820
2838
|
private options?;
|
|
2839
|
+
private lastUsedService?;
|
|
2821
2840
|
private services;
|
|
2822
2841
|
/**
|
|
2823
2842
|
* Constructs a new multi-service router.
|
|
2824
2843
|
* It validates that each service provides a unique set of model keys,
|
|
2825
2844
|
* then builds a lookup (map) for routing the chat/embed requests.
|
|
2826
2845
|
*/
|
|
2827
|
-
constructor(services: (AxAIServiceListItem | AxAIService)[]);
|
|
2846
|
+
constructor(services: (AxAIServiceListItem<string, string> | AxAIService<string, string>)[]);
|
|
2847
|
+
getLastUsedChatModel(): string | undefined;
|
|
2848
|
+
getLastUsedEmbedModel(): string | undefined;
|
|
2849
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
2828
2850
|
/**
|
|
2829
2851
|
* Delegates the chat call to the service matching the provided model key.
|
|
2830
2852
|
*/
|
|
2831
|
-
chat(req: Readonly<AxChatRequest<string>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<string, string>>): Promise<AxChatResponse | ReadableStream
|
|
2853
|
+
chat(req: Readonly<AxChatRequest<string>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<string, string>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
2832
2854
|
/**
|
|
2833
2855
|
* Delegates the embed call to the service matching the provided embed model key.
|
|
2834
2856
|
*/
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReadableStream as ReadableStream$1 } from 'stream/web';
|
|
2
|
-
import { ReadableStream } from 'node:stream/web';
|
|
1
|
+
import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
|
|
3
2
|
import { Span, Tracer } from '@opentelemetry/api';
|
|
3
|
+
import { ReadableStream } from 'stream/web';
|
|
4
4
|
|
|
5
5
|
interface RetryConfig {
|
|
6
6
|
maxRetries: number;
|
|
@@ -61,6 +61,76 @@ declare class AxAIServiceAuthenticationError extends AxAIServiceError {
|
|
|
61
61
|
constructor(url: string, requestBody?: unknown, context?: Record<string, unknown>);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
interface AxAIFeatures {
|
|
65
|
+
functions: boolean;
|
|
66
|
+
streaming: boolean;
|
|
67
|
+
functionCot?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
70
|
+
name: string;
|
|
71
|
+
apiURL: string;
|
|
72
|
+
headers: () => Promise<Record<string, string>>;
|
|
73
|
+
modelInfo: Readonly<AxModelInfo[]>;
|
|
74
|
+
defaults: Readonly<{
|
|
75
|
+
model: TModel;
|
|
76
|
+
embedModel?: TEmbedModel;
|
|
77
|
+
}>;
|
|
78
|
+
options?: Readonly<AxAIServiceOptions>;
|
|
79
|
+
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
80
|
+
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
81
|
+
}
|
|
82
|
+
declare const axBaseAIDefaultConfig: () => AxModelConfig;
|
|
83
|
+
declare const axBaseAIDefaultCreativeConfig: () => AxModelConfig;
|
|
84
|
+
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse> implements AxAIService<TModel, TEmbedModel> {
|
|
85
|
+
private readonly aiImpl;
|
|
86
|
+
private debug;
|
|
87
|
+
private rt?;
|
|
88
|
+
private fetch?;
|
|
89
|
+
private tracer?;
|
|
90
|
+
private models?;
|
|
91
|
+
private modelInfo;
|
|
92
|
+
private modelUsage?;
|
|
93
|
+
private embedModelUsage?;
|
|
94
|
+
private defaults;
|
|
95
|
+
private lastUsedModelConfig?;
|
|
96
|
+
private lastUsedChatModel?;
|
|
97
|
+
private lastUsedEmbedModel?;
|
|
98
|
+
protected apiURL: string;
|
|
99
|
+
protected name: string;
|
|
100
|
+
protected id: string;
|
|
101
|
+
protected headers: () => Promise<Record<string, string>>;
|
|
102
|
+
protected supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
103
|
+
private metrics;
|
|
104
|
+
constructor(aiImpl: Readonly<AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse>>, { name, apiURL, headers, modelInfo, defaults, options, supportFor, models, }: Readonly<AxBaseAIArgs<TModel, TEmbedModel>>);
|
|
105
|
+
setName(name: string): void;
|
|
106
|
+
getId(): string;
|
|
107
|
+
setAPIURL(apiURL: string): void;
|
|
108
|
+
setHeaders(headers: () => Promise<Record<string, string>>): void;
|
|
109
|
+
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
110
|
+
getOptions(): Readonly<AxAIServiceOptions>;
|
|
111
|
+
getModelList(): AxAIModelList | undefined;
|
|
112
|
+
getName(): string;
|
|
113
|
+
getFeatures(model?: TModel): AxAIFeatures;
|
|
114
|
+
getLastUsedChatModel(): TModel | undefined;
|
|
115
|
+
getLastUsedEmbedModel(): TEmbedModel | undefined;
|
|
116
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
117
|
+
private calculatePercentile;
|
|
118
|
+
private updateLatencyMetrics;
|
|
119
|
+
private updateErrorMetrics;
|
|
120
|
+
getMetrics(): AxAIServiceMetrics;
|
|
121
|
+
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
122
|
+
private _chat1;
|
|
123
|
+
private cleanupFunctionSchema;
|
|
124
|
+
private _chat2;
|
|
125
|
+
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
126
|
+
private _embed1;
|
|
127
|
+
private _embed2;
|
|
128
|
+
private buildHeaders;
|
|
129
|
+
private getModelByKey;
|
|
130
|
+
private getModel;
|
|
131
|
+
private getEmbedModel;
|
|
132
|
+
}
|
|
133
|
+
|
|
64
134
|
type AxAIInputModelList<TModel, TEmbedModel> = (AxAIModelListBase & {
|
|
65
135
|
isInternal?: boolean;
|
|
66
136
|
} & ({
|
|
@@ -249,9 +319,9 @@ type AxEmbedRequest<TEmbedModel = string> = {
|
|
|
249
319
|
embedModel?: TEmbedModel;
|
|
250
320
|
};
|
|
251
321
|
type AxInternalEmbedRequest<TEmbedModel> = Omit<AxEmbedRequest, 'embedModel'> & Required<Pick<AxEmbedRequest<TEmbedModel>, 'embedModel'>>;
|
|
252
|
-
type AxRateLimiterFunction = <T = unknown>(reqFunc: () => Promise<T | ReadableStream<T>>, info: Readonly<{
|
|
322
|
+
type AxRateLimiterFunction = <T = unknown>(reqFunc: () => Promise<T | ReadableStream$1<T>>, info: Readonly<{
|
|
253
323
|
modelUsage?: AxModelUsage;
|
|
254
|
-
}>) => Promise<T | ReadableStream<T>>;
|
|
324
|
+
}>) => Promise<T | ReadableStream$1<T>>;
|
|
255
325
|
type AxAIPromptConfig = {
|
|
256
326
|
stream?: boolean;
|
|
257
327
|
};
|
|
@@ -275,7 +345,10 @@ interface AxAIService<TModel = unknown, TEmbedModel = unknown> {
|
|
|
275
345
|
getFeatures(model?: TModel): AxAIFeatures;
|
|
276
346
|
getModelList(): AxAIModelList | undefined;
|
|
277
347
|
getMetrics(): AxAIServiceMetrics;
|
|
278
|
-
|
|
348
|
+
getLastUsedChatModel(): TModel | undefined;
|
|
349
|
+
getLastUsedEmbedModel(): TEmbedModel | undefined;
|
|
350
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
351
|
+
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream$1<AxChatResponse>>;
|
|
279
352
|
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
280
353
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
281
354
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -290,70 +363,6 @@ interface AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TCha
|
|
|
290
363
|
getTokenUsage(): AxTokenUsage | undefined;
|
|
291
364
|
}
|
|
292
365
|
|
|
293
|
-
interface AxAIFeatures {
|
|
294
|
-
functions: boolean;
|
|
295
|
-
streaming: boolean;
|
|
296
|
-
functionCot?: boolean;
|
|
297
|
-
}
|
|
298
|
-
interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
299
|
-
name: string;
|
|
300
|
-
apiURL: string;
|
|
301
|
-
headers: () => Promise<Record<string, string>>;
|
|
302
|
-
modelInfo: Readonly<AxModelInfo[]>;
|
|
303
|
-
defaults: Readonly<{
|
|
304
|
-
model: TModel;
|
|
305
|
-
embedModel?: TEmbedModel;
|
|
306
|
-
}>;
|
|
307
|
-
options?: Readonly<AxAIServiceOptions>;
|
|
308
|
-
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
309
|
-
models?: AxAIInputModelList<TModel, TEmbedModel>;
|
|
310
|
-
}
|
|
311
|
-
declare const axBaseAIDefaultConfig: () => AxModelConfig;
|
|
312
|
-
declare const axBaseAIDefaultCreativeConfig: () => AxModelConfig;
|
|
313
|
-
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse> implements AxAIService<TModel, TEmbedModel> {
|
|
314
|
-
private readonly aiImpl;
|
|
315
|
-
private debug;
|
|
316
|
-
private rt?;
|
|
317
|
-
private fetch?;
|
|
318
|
-
private tracer?;
|
|
319
|
-
private models?;
|
|
320
|
-
private modelInfo;
|
|
321
|
-
private modelUsage?;
|
|
322
|
-
private embedModelUsage?;
|
|
323
|
-
private defaults;
|
|
324
|
-
protected apiURL: string;
|
|
325
|
-
protected name: string;
|
|
326
|
-
protected id: string;
|
|
327
|
-
protected headers: () => Promise<Record<string, string>>;
|
|
328
|
-
protected supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
329
|
-
private metrics;
|
|
330
|
-
constructor(aiImpl: Readonly<AxAIServiceImpl<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse>>, { name, apiURL, headers, modelInfo, defaults, options, supportFor, models, }: Readonly<AxBaseAIArgs<TModel, TEmbedModel>>);
|
|
331
|
-
setName(name: string): void;
|
|
332
|
-
getId(): string;
|
|
333
|
-
setAPIURL(apiURL: string): void;
|
|
334
|
-
setHeaders(headers: () => Promise<Record<string, string>>): void;
|
|
335
|
-
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
336
|
-
getOptions(): Readonly<AxAIServiceOptions>;
|
|
337
|
-
getModelList(): AxAIModelList | undefined;
|
|
338
|
-
getName(): string;
|
|
339
|
-
getFeatures(model?: TModel): AxAIFeatures;
|
|
340
|
-
private calculatePercentile;
|
|
341
|
-
private updateLatencyMetrics;
|
|
342
|
-
private updateErrorMetrics;
|
|
343
|
-
getMetrics(): AxAIServiceMetrics;
|
|
344
|
-
chat(req: Readonly<AxChatRequest<TModel>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxChatResponse | ReadableStream$1<AxChatResponse>>;
|
|
345
|
-
private _chat1;
|
|
346
|
-
private cleanupFunctionSchema;
|
|
347
|
-
private _chat2;
|
|
348
|
-
embed(req: Readonly<AxEmbedRequest<TEmbedModel>>, options?: Readonly<AxAIServiceActionOptions<TModel, TEmbedModel>>): Promise<AxEmbedResponse>;
|
|
349
|
-
private _embed1;
|
|
350
|
-
private _embed2;
|
|
351
|
-
private buildHeaders;
|
|
352
|
-
private getModelByKey;
|
|
353
|
-
private getModel;
|
|
354
|
-
private getEmbedModel;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
366
|
declare enum AxAIAnthropicModel {
|
|
358
367
|
Claude37Sonnet = "claude-3-7-sonnet-latest",
|
|
359
368
|
Claude35Sonnet = "claude-3-5-sonnet-latest",
|
|
@@ -1358,8 +1367,11 @@ declare class AxAI implements AxAIService {
|
|
|
1358
1367
|
streaming: boolean;
|
|
1359
1368
|
};
|
|
1360
1369
|
getModelList(): AxAIModelList | undefined;
|
|
1370
|
+
getLastUsedChatModel(): unknown;
|
|
1371
|
+
getLastUsedEmbedModel(): unknown;
|
|
1372
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
1361
1373
|
getMetrics(): AxAIServiceMetrics;
|
|
1362
|
-
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions>): Promise<AxChatResponse | ReadableStream
|
|
1374
|
+
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1363
1375
|
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions & AxAIServiceActionOptions>): Promise<AxEmbedResponse>;
|
|
1364
1376
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
1365
1377
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -1931,6 +1943,9 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1931
1943
|
private maxRetries;
|
|
1932
1944
|
private serviceFailures;
|
|
1933
1945
|
constructor(services: readonly AxAIService[], options?: AxBalancerOptions);
|
|
1946
|
+
getLastUsedChatModel(): unknown;
|
|
1947
|
+
getLastUsedEmbedModel(): unknown;
|
|
1948
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
1934
1949
|
/**
|
|
1935
1950
|
* Service comparator that respects the input order of services.
|
|
1936
1951
|
*/
|
|
@@ -1949,7 +1964,7 @@ declare class AxBalancer implements AxAIService<unknown, unknown> {
|
|
|
1949
1964
|
private canRetryService;
|
|
1950
1965
|
private handleFailure;
|
|
1951
1966
|
private handleSuccess;
|
|
1952
|
-
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions> | undefined): Promise<AxChatResponse | ReadableStream
|
|
1967
|
+
chat(req: Readonly<AxChatRequest>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions> | undefined): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
1953
1968
|
embed(req: Readonly<AxEmbedRequest>, options?: Readonly<AxAIServiceActionOptions> | undefined): Promise<AxEmbedResponse>;
|
|
1954
1969
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
1955
1970
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -2524,7 +2539,7 @@ type AxMockAIServiceConfig = {
|
|
|
2524
2539
|
};
|
|
2525
2540
|
models?: AxAIModelList;
|
|
2526
2541
|
options?: AxAIServiceOptions;
|
|
2527
|
-
chatResponse?: AxChatResponse | ReadableStream
|
|
2542
|
+
chatResponse?: AxChatResponse | ReadableStream<AxChatResponse> | (() => Promise<AxChatResponse | ReadableStream<AxChatResponse>>) | ((req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>) => Promise<AxChatResponse | ReadableStream<AxChatResponse>>);
|
|
2528
2543
|
embedResponse?: AxEmbedResponse | ((req: Readonly<AxEmbedRequest>) => AxEmbedResponse | Promise<AxEmbedResponse>);
|
|
2529
2544
|
shouldError?: boolean;
|
|
2530
2545
|
errorMessage?: string;
|
|
@@ -2534,6 +2549,9 @@ declare class AxMockAIService implements AxAIService {
|
|
|
2534
2549
|
private readonly config;
|
|
2535
2550
|
private metrics;
|
|
2536
2551
|
constructor(config?: AxMockAIServiceConfig);
|
|
2552
|
+
getLastUsedChatModel(): unknown;
|
|
2553
|
+
getLastUsedEmbedModel(): unknown;
|
|
2554
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
2537
2555
|
getName(): string;
|
|
2538
2556
|
getId(): string;
|
|
2539
2557
|
getFeatures(_model?: string): {
|
|
@@ -2542,7 +2560,7 @@ declare class AxMockAIService implements AxAIService {
|
|
|
2542
2560
|
};
|
|
2543
2561
|
getModelList(): AxAIModelList | undefined;
|
|
2544
2562
|
getMetrics(): AxAIServiceMetrics;
|
|
2545
|
-
chat(req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>): Promise<AxChatResponse | ReadableStream
|
|
2563
|
+
chat(req: Readonly<AxChatRequest<unknown>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<unknown, unknown>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
2546
2564
|
embed(req: Readonly<AxEmbedRequest>, _options?: Readonly<AxAIServiceActionOptions>): Promise<AxEmbedResponse>;
|
|
2547
2565
|
setOptions(options: Readonly<AxAIServiceOptions>): void;
|
|
2548
2566
|
getOptions(): Readonly<AxAIServiceOptions>;
|
|
@@ -2810,25 +2828,29 @@ declare class AxMCPStdioTransport implements AxMCPTransport {
|
|
|
2810
2828
|
connect(): Promise<void>;
|
|
2811
2829
|
}
|
|
2812
2830
|
|
|
2813
|
-
type AxAIServiceListItem = {
|
|
2831
|
+
type AxAIServiceListItem<TModel = unknown, TEmbedModel = unknown> = {
|
|
2814
2832
|
key: string;
|
|
2815
|
-
service: AxAIService
|
|
2833
|
+
service: AxAIService<TModel, TEmbedModel>;
|
|
2816
2834
|
description: string;
|
|
2817
2835
|
isInternal?: boolean;
|
|
2818
2836
|
};
|
|
2819
2837
|
declare class AxMultiServiceRouter implements AxAIService<string, string> {
|
|
2820
2838
|
private options?;
|
|
2839
|
+
private lastUsedService?;
|
|
2821
2840
|
private services;
|
|
2822
2841
|
/**
|
|
2823
2842
|
* Constructs a new multi-service router.
|
|
2824
2843
|
* It validates that each service provides a unique set of model keys,
|
|
2825
2844
|
* then builds a lookup (map) for routing the chat/embed requests.
|
|
2826
2845
|
*/
|
|
2827
|
-
constructor(services: (AxAIServiceListItem | AxAIService)[]);
|
|
2846
|
+
constructor(services: (AxAIServiceListItem<string, string> | AxAIService<string, string>)[]);
|
|
2847
|
+
getLastUsedChatModel(): string | undefined;
|
|
2848
|
+
getLastUsedEmbedModel(): string | undefined;
|
|
2849
|
+
getLastUsedModelConfig(): AxModelConfig | undefined;
|
|
2828
2850
|
/**
|
|
2829
2851
|
* Delegates the chat call to the service matching the provided model key.
|
|
2830
2852
|
*/
|
|
2831
|
-
chat(req: Readonly<AxChatRequest<string>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<string, string>>): Promise<AxChatResponse | ReadableStream
|
|
2853
|
+
chat(req: Readonly<AxChatRequest<string>>, options?: Readonly<AxAIPromptConfig & AxAIServiceActionOptions<string, string>>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
|
|
2832
2854
|
/**
|
|
2833
2855
|
* Delegates the embed call to the service matching the provided embed model key.
|
|
2834
2856
|
*/
|