@ax-llm/ax 11.0.26 → 11.0.28
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 +2223 -47
- package/index.cjs.map +1 -1
- package/index.d.cts +306 -2
- package/index.d.ts +306 -2
- package/index.js +2183 -50
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -300,6 +300,8 @@ interface AxBaseAIArgs<TModel, TEmbedModel> {
|
|
|
300
300
|
supportFor: AxAIFeatures | ((model: TModel) => AxAIFeatures);
|
|
301
301
|
models?: AxAIInputModelList<TModel>;
|
|
302
302
|
}
|
|
303
|
+
declare const axBaseAIDefaultConfig: () => AxModelConfig;
|
|
304
|
+
declare const axBaseAIDefaultCreativeConfig: () => AxModelConfig;
|
|
303
305
|
declare class AxBaseAI<TModel, TEmbedModel, TChatRequest, TEmbedRequest, TChatResponse, TChatResponseDelta, TEmbedResponse> implements AxAIService<TModel, TEmbedModel> {
|
|
304
306
|
private readonly aiImpl;
|
|
305
307
|
private debug;
|
|
@@ -536,6 +538,7 @@ interface AxAIAnthropicErrorEvent {
|
|
|
536
538
|
}
|
|
537
539
|
type AxAIAnthropicChatResponseDelta = AxAIAnthropicMessageStartEvent | AxAIAnthropicContentBlockStartEvent | AxAIAnthropicContentBlockDeltaEvent | AxAIAnthropicContentBlockStopEvent | AxAIAnthropicMessageDeltaEvent | AxAIAnthropicMessageStopEvent | AxAIAnthropicPingEvent | AxAIAnthropicErrorEvent;
|
|
538
540
|
|
|
541
|
+
declare const axAIAnthropicDefaultConfig: () => AxAIAnthropicConfig;
|
|
539
542
|
interface AxAIAnthropicArgs {
|
|
540
543
|
name: 'anthropic';
|
|
541
544
|
apiKey?: string;
|
|
@@ -732,6 +735,10 @@ type AxAIOpenAIEmbedResponse = {
|
|
|
732
735
|
usage: AxAIOpenAIUsage;
|
|
733
736
|
};
|
|
734
737
|
|
|
738
|
+
declare const axAIOpenAIDefaultConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
739
|
+
declare const axAIOpenAIBestConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
740
|
+
declare const axAIOpenAICreativeConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
741
|
+
declare const axAIOpenAIFastConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
735
742
|
interface AxAIOpenAIArgs<TName = 'openai', TModel = AxAIOpenAIModel, TEmbedModel = AxAIOpenAIEmbedModel> extends Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel>, 'config' | 'modelInfo'> {
|
|
736
743
|
name: TName;
|
|
737
744
|
config?: Partial<AxAIOpenAIBaseArgs<TModel, TEmbedModel>['config']>;
|
|
@@ -753,6 +760,10 @@ declare class AxAIOpenAI extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbed
|
|
|
753
760
|
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAIOpenAIArgs, 'name' | 'modelInfo'>>);
|
|
754
761
|
}
|
|
755
762
|
|
|
763
|
+
declare const axAIAzureOpenAIDefaultConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
764
|
+
declare const axAIAzureOpenAICreativeConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
765
|
+
declare const axAIAzureOpenAIFastConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
766
|
+
declare const axAIAzureOpenAIBestConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
756
767
|
type AxAIAzureOpenAIConfig = AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
757
768
|
type AxAIAzureOpenAIArgs = AxAIOpenAIArgs<'azure-openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel> & {
|
|
758
769
|
resourceName: string;
|
|
@@ -862,6 +873,8 @@ type AxAICohereEmbedResponse = {
|
|
|
862
873
|
embeddings: number[][];
|
|
863
874
|
};
|
|
864
875
|
|
|
876
|
+
declare const axAICohereDefaultConfig: () => AxAICohereConfig;
|
|
877
|
+
declare const axAICohereCreativeConfig: () => AxAICohereConfig;
|
|
865
878
|
interface AxAICohereArgs {
|
|
866
879
|
name: 'cohere';
|
|
867
880
|
apiKey: string;
|
|
@@ -881,6 +894,9 @@ declare enum AxAIDeepSeekModel {
|
|
|
881
894
|
DeepSeekCoder = "deepseek-coder"
|
|
882
895
|
}
|
|
883
896
|
|
|
897
|
+
type DeepSeekConfig = AxAIOpenAIConfig<AxAIDeepSeekModel, undefined>;
|
|
898
|
+
declare const axAIDeepSeekDefaultConfig: () => DeepSeekConfig;
|
|
899
|
+
declare const axAIDeepSeekCodeConfig: () => DeepSeekConfig;
|
|
884
900
|
type AxAIDeepSeekArgs = AxAIOpenAIArgs<'deepseek', AxAIDeepSeekModel, undefined>;
|
|
885
901
|
declare class AxAIDeepSeek extends AxAIOpenAIBase<AxAIDeepSeekModel, undefined> {
|
|
886
902
|
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAIDeepSeekArgs, 'name'>>);
|
|
@@ -1066,6 +1082,11 @@ type AxAIGoogleVertexBatchEmbedResponse = {
|
|
|
1066
1082
|
}[];
|
|
1067
1083
|
};
|
|
1068
1084
|
|
|
1085
|
+
/**
|
|
1086
|
+
* AxAIGoogleGemini: Default Model options for text generation
|
|
1087
|
+
*/
|
|
1088
|
+
declare const axAIGoogleGeminiDefaultConfig: () => AxAIGoogleGeminiConfig;
|
|
1089
|
+
declare const axAIGoogleGeminiDefaultCreativeConfig: () => AxAIGoogleGeminiConfig;
|
|
1069
1090
|
interface AxAIGoogleGeminiOptionsTools {
|
|
1070
1091
|
codeExecution?: boolean;
|
|
1071
1092
|
googleSearchRetrieval?: {
|
|
@@ -1143,6 +1164,8 @@ type AxAIHuggingFaceResponse = {
|
|
|
1143
1164
|
generated_text: string;
|
|
1144
1165
|
};
|
|
1145
1166
|
|
|
1167
|
+
declare const axAIHuggingFaceDefaultConfig: () => AxAIHuggingFaceConfig;
|
|
1168
|
+
declare const axAIHuggingFaceCreativeConfig: () => AxAIHuggingFaceConfig;
|
|
1146
1169
|
interface AxAIHuggingFaceArgs {
|
|
1147
1170
|
name: 'huggingface';
|
|
1148
1171
|
apiKey: string;
|
|
@@ -1168,6 +1191,9 @@ declare enum AxAIMistralEmbedModels {
|
|
|
1168
1191
|
MistralEmbed = "mistral-embed"
|
|
1169
1192
|
}
|
|
1170
1193
|
|
|
1194
|
+
type AxAIMistralConfig = AxAIOpenAIConfig<AxAIMistralModel, AxAIMistralEmbedModels>;
|
|
1195
|
+
declare const axAIMistralDefaultConfig: () => AxAIMistralConfig;
|
|
1196
|
+
declare const axAIMistralBestConfig: () => AxAIMistralConfig;
|
|
1171
1197
|
type AxAIMistralArgs = AxAIOpenAIArgs<'mistral', AxAIMistralModel, AxAIMistralEmbedModels> & {
|
|
1172
1198
|
options?: Readonly<AxAIServiceOptions> & {
|
|
1173
1199
|
tokensPerMinute?: number;
|
|
@@ -1178,6 +1204,8 @@ declare class AxAIMistral extends AxAIOpenAIBase<AxAIMistralModel, AxAIMistralEm
|
|
|
1178
1204
|
}
|
|
1179
1205
|
|
|
1180
1206
|
type AxAIOllamaAIConfig = AxAIOpenAIConfig<string, string>;
|
|
1207
|
+
declare const axAIOllamaDefaultConfig: () => AxAIOllamaAIConfig;
|
|
1208
|
+
declare const axAIOllamaDefaultCreativeConfig: () => AxAIOllamaAIConfig;
|
|
1181
1209
|
type AxAIOllamaArgs = AxAIOpenAIArgs<'ollama', string, string> & {
|
|
1182
1210
|
model?: string;
|
|
1183
1211
|
embedModel?: string;
|
|
@@ -1257,6 +1285,10 @@ type AxAIRekaChatResponseDelta = {
|
|
|
1257
1285
|
usage?: AxAIRekaUsage;
|
|
1258
1286
|
};
|
|
1259
1287
|
|
|
1288
|
+
declare const axAIRekaDefaultConfig: () => AxAIRekaConfig;
|
|
1289
|
+
declare const axAIRekaBestConfig: () => AxAIRekaConfig;
|
|
1290
|
+
declare const axAIRekaCreativeConfig: () => AxAIRekaConfig;
|
|
1291
|
+
declare const axAIRekaFastConfig: () => AxAIRekaConfig;
|
|
1260
1292
|
interface AxAIRekaArgs {
|
|
1261
1293
|
name: 'reka';
|
|
1262
1294
|
apiKey: string;
|
|
@@ -1272,6 +1304,8 @@ declare class AxAIReka extends AxBaseAI<AxAIRekaModel, undefined, AxAIRekaChatRe
|
|
|
1272
1304
|
constructor({ apiKey, config, options, apiURL, modelInfo, models, }: Readonly<Omit<AxAIRekaArgs, 'name'>>);
|
|
1273
1305
|
}
|
|
1274
1306
|
|
|
1307
|
+
type TogetherAIConfig = AxAIOpenAIConfig<string, unknown>;
|
|
1308
|
+
declare const axAITogetherDefaultConfig: () => TogetherAIConfig;
|
|
1275
1309
|
type AxAITogetherArgs = AxAIOpenAIArgs<'together', string, unknown>;
|
|
1276
1310
|
declare class AxAITogether extends AxAIOpenAIBase<string, unknown> {
|
|
1277
1311
|
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAITogetherArgs, 'name'>>);
|
|
@@ -1907,19 +1941,48 @@ type AxOptimizerArgs<IN extends AxGenIn, OUT extends AxGenOut> = {
|
|
|
1907
1941
|
maxRounds?: number;
|
|
1908
1942
|
maxExamples?: number;
|
|
1909
1943
|
maxDemos?: number;
|
|
1944
|
+
batchSize?: number;
|
|
1945
|
+
earlyStoppingPatience?: number;
|
|
1946
|
+
teacherAI?: AxAIService;
|
|
1947
|
+
costMonitoring?: boolean;
|
|
1948
|
+
maxTokensPerGeneration?: number;
|
|
1949
|
+
verboseMode?: boolean;
|
|
1950
|
+
debugMode?: boolean;
|
|
1910
1951
|
};
|
|
1911
1952
|
};
|
|
1953
|
+
interface AxOptimizationStats {
|
|
1954
|
+
totalCalls: number;
|
|
1955
|
+
successfulDemos: number;
|
|
1956
|
+
estimatedTokenUsage: number;
|
|
1957
|
+
earlyStopped: boolean;
|
|
1958
|
+
earlyStopping?: {
|
|
1959
|
+
bestScoreRound: number;
|
|
1960
|
+
patienceExhausted: boolean;
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1912
1963
|
declare class AxBootstrapFewShot<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> {
|
|
1913
1964
|
private ai;
|
|
1965
|
+
private teacherAI?;
|
|
1914
1966
|
private program;
|
|
1915
1967
|
private examples;
|
|
1916
1968
|
private maxRounds;
|
|
1917
1969
|
private maxDemos;
|
|
1918
1970
|
private maxExamples;
|
|
1971
|
+
private batchSize;
|
|
1972
|
+
private earlyStoppingPatience;
|
|
1973
|
+
private costMonitoring;
|
|
1974
|
+
private maxTokensPerGeneration;
|
|
1975
|
+
private verboseMode;
|
|
1976
|
+
private debugMode;
|
|
1919
1977
|
private traces;
|
|
1978
|
+
private stats;
|
|
1920
1979
|
constructor({ ai, program, examples, options, }: Readonly<AxOptimizerArgs<IN, OUT>>);
|
|
1921
1980
|
private compileRound;
|
|
1922
|
-
compile(metricFn: AxMetricFn, options?: Readonly<AxOptimizerArgs<IN, OUT>['options']>): Promise<
|
|
1981
|
+
compile(metricFn: AxMetricFn, options?: Readonly<AxOptimizerArgs<IN, OUT>['options']>): Promise<{
|
|
1982
|
+
demos: AxProgramDemos[];
|
|
1983
|
+
stats: AxOptimizationStats;
|
|
1984
|
+
}>;
|
|
1985
|
+
getStats(): AxOptimizationStats;
|
|
1923
1986
|
}
|
|
1924
1987
|
|
|
1925
1988
|
type AxDBUpsertRequest = {
|
|
@@ -2257,6 +2320,40 @@ declare class AxJSInterpreter {
|
|
|
2257
2320
|
toFunction(): AxFunction;
|
|
2258
2321
|
}
|
|
2259
2322
|
|
|
2323
|
+
declare const axSpanAttributes: {
|
|
2324
|
+
LLM_SYSTEM: string;
|
|
2325
|
+
LLM_REQUEST_MODEL: string;
|
|
2326
|
+
LLM_REQUEST_MAX_TOKENS: string;
|
|
2327
|
+
LLM_REQUEST_TEMPERATURE: string;
|
|
2328
|
+
LLM_REQUEST_TOP_K: string;
|
|
2329
|
+
LLM_REQUEST_FREQUENCY_PENALTY: string;
|
|
2330
|
+
LLM_REQUEST_PRESENCE_PENALTY: string;
|
|
2331
|
+
LLM_REQUEST_STOP_SEQUENCES: string;
|
|
2332
|
+
LLM_REQUEST_LLM_IS_STREAMING: string;
|
|
2333
|
+
LLM_REQUEST_TOP_P: string;
|
|
2334
|
+
LLM_USAGE_PROMPT_TOKENS: string;
|
|
2335
|
+
LLM_USAGE_COMPLETION_TOKENS: string;
|
|
2336
|
+
DB_SYSTEM: string;
|
|
2337
|
+
DB_TABLE: string;
|
|
2338
|
+
DB_NAMESPACE: string;
|
|
2339
|
+
DB_ID: string;
|
|
2340
|
+
DB_QUERY_TEXT: string;
|
|
2341
|
+
DB_VECTOR: string;
|
|
2342
|
+
DB_OPERATION_NAME: string;
|
|
2343
|
+
DB_VECTOR_QUERY_TOP_K: string;
|
|
2344
|
+
DB_QUERY_EMBEDDINGS: string;
|
|
2345
|
+
DB_QUERY_RESULT: string;
|
|
2346
|
+
DB_QUERY_EMBEDDINGS_VECTOR: string;
|
|
2347
|
+
DB_QUERY_RESULT_ID: string;
|
|
2348
|
+
DB_QUERY_RESULT_SCORE: string;
|
|
2349
|
+
DB_QUERY_RESULT_DISTANCE: string;
|
|
2350
|
+
DB_QUERY_RESULT_METADATA: string;
|
|
2351
|
+
DB_QUERY_RESULT_VECTOR: string;
|
|
2352
|
+
DB_QUERY_RESULT_DOCUMENT: string;
|
|
2353
|
+
};
|
|
2354
|
+
declare const axSpanEvents: {
|
|
2355
|
+
LLM_PROMPT: string;
|
|
2356
|
+
};
|
|
2260
2357
|
declare enum AxLLMRequestTypeValues {
|
|
2261
2358
|
COMPLETION = "completion",
|
|
2262
2359
|
CHAT = "chat",
|
|
@@ -2271,6 +2368,123 @@ declare enum AxSpanKindValues {
|
|
|
2271
2368
|
UNKNOWN = "unknown"
|
|
2272
2369
|
}
|
|
2273
2370
|
|
|
2371
|
+
interface AxMiPROOptions {
|
|
2372
|
+
numCandidates?: number;
|
|
2373
|
+
initTemperature?: number;
|
|
2374
|
+
maxBootstrappedDemos?: number;
|
|
2375
|
+
maxLabeledDemos?: number;
|
|
2376
|
+
numTrials?: number;
|
|
2377
|
+
minibatch?: boolean;
|
|
2378
|
+
minibatchSize?: number;
|
|
2379
|
+
minibatchFullEvalSteps?: number;
|
|
2380
|
+
programAwareProposer?: boolean;
|
|
2381
|
+
dataAwareProposer?: boolean;
|
|
2382
|
+
viewDataBatchSize?: number;
|
|
2383
|
+
tipAwareProposer?: boolean;
|
|
2384
|
+
fewshotAwareProposer?: boolean;
|
|
2385
|
+
seed?: number;
|
|
2386
|
+
verbose?: boolean;
|
|
2387
|
+
earlyStoppingTrials?: number;
|
|
2388
|
+
minImprovementThreshold?: number;
|
|
2389
|
+
}
|
|
2390
|
+
declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> {
|
|
2391
|
+
private ai;
|
|
2392
|
+
private program;
|
|
2393
|
+
private examples;
|
|
2394
|
+
private maxBootstrappedDemos;
|
|
2395
|
+
private maxLabeledDemos;
|
|
2396
|
+
private numCandidates;
|
|
2397
|
+
private initTemperature;
|
|
2398
|
+
private numTrials;
|
|
2399
|
+
private minibatch;
|
|
2400
|
+
private minibatchSize;
|
|
2401
|
+
private minibatchFullEvalSteps;
|
|
2402
|
+
private programAwareProposer;
|
|
2403
|
+
private dataAwareProposer;
|
|
2404
|
+
private viewDataBatchSize;
|
|
2405
|
+
private tipAwareProposer;
|
|
2406
|
+
private fewshotAwareProposer;
|
|
2407
|
+
private seed?;
|
|
2408
|
+
private verbose;
|
|
2409
|
+
private bootstrapper;
|
|
2410
|
+
private earlyStoppingTrials;
|
|
2411
|
+
private minImprovementThreshold;
|
|
2412
|
+
constructor({ ai, program, examples, options, }: Readonly<AxOptimizerArgs<IN, OUT>> & {
|
|
2413
|
+
options?: AxMiPROOptions;
|
|
2414
|
+
});
|
|
2415
|
+
/**
|
|
2416
|
+
* Configures the optimizer for light, medium, or heavy optimization
|
|
2417
|
+
* @param level The optimization level: "light", "medium", or "heavy"
|
|
2418
|
+
*/
|
|
2419
|
+
configureAuto(level: 'light' | 'medium' | 'heavy'): void;
|
|
2420
|
+
/**
|
|
2421
|
+
* Generates creative tips for instruction generation
|
|
2422
|
+
*/
|
|
2423
|
+
private generateTips;
|
|
2424
|
+
/**
|
|
2425
|
+
* Generates instruction candidates for each predictor in the program
|
|
2426
|
+
* @returns Array of generated instruction candidates
|
|
2427
|
+
*/
|
|
2428
|
+
private proposeInstructionCandidates;
|
|
2429
|
+
/**
|
|
2430
|
+
* Generates a summary of the program structure for instruction proposal
|
|
2431
|
+
*/
|
|
2432
|
+
private generateProgramSummary;
|
|
2433
|
+
/**
|
|
2434
|
+
* Generates a summary of the dataset for instruction proposal
|
|
2435
|
+
*/
|
|
2436
|
+
private generateDataSummary;
|
|
2437
|
+
/**
|
|
2438
|
+
* Generates a specific instruction candidate
|
|
2439
|
+
*/
|
|
2440
|
+
private generateInstruction;
|
|
2441
|
+
/**
|
|
2442
|
+
* Bootstraps few-shot examples for the program
|
|
2443
|
+
*/
|
|
2444
|
+
private bootstrapFewShotExamples;
|
|
2445
|
+
/**
|
|
2446
|
+
* Selects labeled examples directly from the training set
|
|
2447
|
+
*/
|
|
2448
|
+
private selectLabeledExamples;
|
|
2449
|
+
/**
|
|
2450
|
+
* Runs Bayesian optimization to find the best combination of few-shot examples and instructions
|
|
2451
|
+
*/
|
|
2452
|
+
private runBayesianOptimization;
|
|
2453
|
+
/**
|
|
2454
|
+
* Evaluates a configuration on the validation set
|
|
2455
|
+
*/
|
|
2456
|
+
private evaluateConfig;
|
|
2457
|
+
/**
|
|
2458
|
+
* Run full evaluation on the entire validation set
|
|
2459
|
+
*/
|
|
2460
|
+
private fullEvaluation;
|
|
2461
|
+
/**
|
|
2462
|
+
* Implements a Bayesian-inspired selection of the next configuration to try
|
|
2463
|
+
* This is a simplified version using Upper Confidence Bound (UCB) strategy
|
|
2464
|
+
*/
|
|
2465
|
+
private selectNextConfiguration;
|
|
2466
|
+
/**
|
|
2467
|
+
* Applies a configuration to a program instance
|
|
2468
|
+
*/
|
|
2469
|
+
private applyConfigToProgram;
|
|
2470
|
+
/**
|
|
2471
|
+
* Sets instruction to a program
|
|
2472
|
+
* Note: Workaround since setInstruction may not be available directly
|
|
2473
|
+
*/
|
|
2474
|
+
private setInstructionToProgram;
|
|
2475
|
+
/**
|
|
2476
|
+
* The main compile method to run MIPROv2 optimization
|
|
2477
|
+
* @param metricFn Evaluation metric function
|
|
2478
|
+
* @param options Optional configuration options
|
|
2479
|
+
* @returns The optimized program
|
|
2480
|
+
*/
|
|
2481
|
+
compile(metricFn: AxMetricFn, options?: Readonly<{
|
|
2482
|
+
valset?: readonly AxExample[];
|
|
2483
|
+
teacher?: Readonly<AxProgram<IN, OUT>>;
|
|
2484
|
+
auto?: 'light' | 'medium' | 'heavy';
|
|
2485
|
+
}>): Promise<Readonly<AxProgram<IN, OUT>>>;
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2274
2488
|
type AxMockAIServiceConfig = {
|
|
2275
2489
|
name?: string;
|
|
2276
2490
|
id?: string;
|
|
@@ -2395,6 +2609,49 @@ declare class AxEmbeddingAdapter {
|
|
|
2395
2609
|
toFunction(): AxFunction;
|
|
2396
2610
|
}
|
|
2397
2611
|
|
|
2612
|
+
/**
|
|
2613
|
+
* Calculates the Exact Match (EM) score between a prediction and ground truth.
|
|
2614
|
+
*
|
|
2615
|
+
* The EM score is a strict metric used in machine learning to assess if the predicted
|
|
2616
|
+
* answer matches the ground truth exactly, commonly used in tasks like question answering.
|
|
2617
|
+
*
|
|
2618
|
+
* @param prediction The predicted text.
|
|
2619
|
+
* @param groundTruth The actual correct text.
|
|
2620
|
+
* @returns A boolean indicating if the prediction exactly matches the ground truth.
|
|
2621
|
+
*/
|
|
2622
|
+
declare function emScore(prediction: string, groundTruth: string): boolean;
|
|
2623
|
+
/**
|
|
2624
|
+
* Calculates the F1 score between a prediction and ground truth.
|
|
2625
|
+
*
|
|
2626
|
+
* The F1 score is a harmonic mean of precision and recall, widely used in NLP to measure
|
|
2627
|
+
* a model's accuracy in considering both false positives and false negatives, offering a
|
|
2628
|
+
* balance for evaluating classification models.
|
|
2629
|
+
*
|
|
2630
|
+
* @param prediction The predicted text.
|
|
2631
|
+
* @param groundTruth The actual correct text.
|
|
2632
|
+
* @returns The F1 score as a number.
|
|
2633
|
+
*/
|
|
2634
|
+
declare function f1Score(prediction: string, groundTruth: string): number;
|
|
2635
|
+
/**
|
|
2636
|
+
* Calculates a novel F1 score, taking into account a history of interaction and excluding stopwords.
|
|
2637
|
+
*
|
|
2638
|
+
* This metric extends the F1 score by considering contextual relevance and filtering out common words
|
|
2639
|
+
* that might skew the assessment of the prediction's quality, especially in conversational models or
|
|
2640
|
+
* when historical context is relevant.
|
|
2641
|
+
*
|
|
2642
|
+
* @param history The historical context or preceding interactions.
|
|
2643
|
+
* @param prediction The predicted text.
|
|
2644
|
+
* @param groundTruth The actual correct text.
|
|
2645
|
+
* @param returnRecall Optionally return the recall score instead of F1.
|
|
2646
|
+
* @returns The novel F1 or recall score as a number.
|
|
2647
|
+
*/
|
|
2648
|
+
declare function novelF1ScoreOptimized(history: string, prediction: string, groundTruth: string, returnRecall?: boolean): number;
|
|
2649
|
+
declare const AxEvalUtil: {
|
|
2650
|
+
emScore: typeof emScore;
|
|
2651
|
+
f1Score: typeof f1Score;
|
|
2652
|
+
novelF1ScoreOptimized: typeof novelF1ScoreOptimized;
|
|
2653
|
+
};
|
|
2654
|
+
|
|
2398
2655
|
declare class AxInstanceRegistry<T> {
|
|
2399
2656
|
private reg;
|
|
2400
2657
|
constructor();
|
|
@@ -2613,4 +2870,51 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
2613
2870
|
}>;
|
|
2614
2871
|
}
|
|
2615
2872
|
|
|
2616
|
-
|
|
2873
|
+
declare const AxStringUtil: {
|
|
2874
|
+
trimNonAlphaNum: (str: string) => string;
|
|
2875
|
+
splitIntoTwo: (str: string, separator: Readonly<RegExp | string>) => string[];
|
|
2876
|
+
dedup: (seq: readonly string[]) => string[];
|
|
2877
|
+
extractIdAndText: (input: string) => {
|
|
2878
|
+
id: number;
|
|
2879
|
+
text: string;
|
|
2880
|
+
};
|
|
2881
|
+
extractIndexPrefixedText: (input: string) => string;
|
|
2882
|
+
batchArray: <T>(arr: readonly T[], size: number) => T[][];
|
|
2883
|
+
};
|
|
2884
|
+
|
|
2885
|
+
declare const axModelInfoAnthropic: AxModelInfo[];
|
|
2886
|
+
|
|
2887
|
+
declare const axModelInfoCohere: AxModelInfo[];
|
|
2888
|
+
|
|
2889
|
+
declare const axModelInfoDeepSeek: AxModelInfo[];
|
|
2890
|
+
|
|
2891
|
+
/**
|
|
2892
|
+
* AxAIGoogleGemini: Model information
|
|
2893
|
+
*/
|
|
2894
|
+
declare const axModelInfoGoogleGemini: AxModelInfo[];
|
|
2895
|
+
|
|
2896
|
+
/**
|
|
2897
|
+
* AxAIGroq: Model information
|
|
2898
|
+
*/
|
|
2899
|
+
declare const axModelInfoGroq: AxModelInfo[];
|
|
2900
|
+
|
|
2901
|
+
/**
|
|
2902
|
+
* HuggingFace: Model information
|
|
2903
|
+
*/
|
|
2904
|
+
declare const axModelInfoHuggingFace: AxModelInfo[];
|
|
2905
|
+
|
|
2906
|
+
declare const axModelInfoMistral: AxModelInfo[];
|
|
2907
|
+
|
|
2908
|
+
/**
|
|
2909
|
+
* OpenAI: Model information
|
|
2910
|
+
*/
|
|
2911
|
+
declare const axModelInfoOpenAI: AxModelInfo[];
|
|
2912
|
+
|
|
2913
|
+
/**
|
|
2914
|
+
* OpenAI: Model information
|
|
2915
|
+
*/
|
|
2916
|
+
declare const axModelInfoReka: AxModelInfo[];
|
|
2917
|
+
|
|
2918
|
+
declare const axModelInfoTogether: AxModelInfo[];
|
|
2919
|
+
|
|
2920
|
+
export { AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicErrorEvent, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicPingEvent, AxAIAnthropicVertexModel, type AxAIArgs, AxAIAzureOpenAI, type AxAIAzureOpenAIArgs, type AxAIAzureOpenAIConfig, AxAICohere, type AxAICohereArgs, type AxAICohereChatRequest, type AxAICohereChatRequestToolResults, type AxAICohereChatResponse, type AxAICohereChatResponseDelta, type AxAICohereChatResponseToolCalls, type AxAICohereConfig, AxAICohereEmbedModel, type AxAICohereEmbedRequest, type AxAICohereEmbedResponse, AxAICohereModel, AxAIDeepSeek, type AxAIDeepSeekArgs, AxAIDeepSeekModel, type AxAIEmbedModels, type AxAIFeatures, AxAIGoogleGemini, type AxAIGoogleGeminiArgs, type AxAIGoogleGeminiBatchEmbedRequest, type AxAIGoogleGeminiBatchEmbedResponse, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, AxAIGoogleGeminiEmbedModel, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleSearchRetrieval, type AxAIGoogleVertexBatchEmbedRequest, type AxAIGoogleVertexBatchEmbedResponse, AxAIGroq, type AxAIGroqArgs, AxAIGroqModel, AxAIHuggingFace, type AxAIHuggingFaceArgs, type AxAIHuggingFaceConfig, AxAIHuggingFaceModel, type AxAIHuggingFaceRequest, type AxAIHuggingFaceResponse, type AxAIInputModelList, type AxAIMemory, AxAIMistral, type AxAIMistralArgs, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelList, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIArgs, AxAIOpenAIBase, type AxAIOpenAIBaseArgs, type AxAIOpenAIChatRequest, type AxAIOpenAIChatResponse, type AxAIOpenAIChatResponseDelta, type AxAIOpenAIConfig, AxAIOpenAIEmbedModel, type AxAIOpenAIEmbedRequest, type AxAIOpenAIEmbedResponse, type AxAIOpenAILogprob, AxAIOpenAIModel, type AxAIOpenAIResponseDelta, type AxAIOpenAIUsage, type AxAIPromptConfig, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, type AxAPI, type AxAPIConfig, AxAgent, type AxAgentFeatures, type AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBootstrapFewShot, AxChainOfThought, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, AxDB, type AxDBArgs, AxDBBase, type AxDBBaseArgs, type AxDBBaseOpOptions, AxDBCloudflare, type AxDBCloudflareArgs, type AxDBCloudflareOpOptions, type AxDBLoaderOptions, AxDBManager, type AxDBManagerArgs, type AxDBMatch, AxDBMemory, type AxDBMemoryArgs, type AxDBMemoryOpOptions, AxDBPinecone, type AxDBPineconeArgs, type AxDBPineconeOpOptions, type AxDBQueryRequest, type AxDBQueryResponse, type AxDBQueryService, type AxDBService, type AxDBState, type AxDBUpsertRequest, type AxDBUpsertResponse, AxDBWeaviate, type AxDBWeaviateArgs, type AxDBWeaviateOpOptions, type AxDataRow, AxDefaultQueryRewriter, AxDefaultResultReranker, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldValue, type AxFunction, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenOptions, type AxGenOut, type AxGenStreamingOut, type AxGenerateResult, AxHFDataLoader, type AxIField, type AxInputFunctionType, AxInstanceRegistry, type AxInternalChatRequest, type AxInternalEmbedRequest, AxJSInterpreter, AxJSInterpreterPermission, AxLLMRequestTypeValues, AxMCPClient, AxMCPHTTPTransport, AxMCPStdioTransport, type AxMCPTransport, AxMemory, type AxMetricFn, type AxMetricFnArgs, AxMiPRO, type AxMiPROOptions, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, AxMultiServiceRouter, type AxOptimizationStats, type AxOptimizerArgs, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramStreamingForwardOptions, type AxProgramTrace, type AxProgramUsage, AxProgramWithSignature, type AxProgramWithSignatureOptions, AxPromptTemplate, AxRAG, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, type AxRerankerIn, type AxRerankerOut, type AxResponseHandlerArgs, type AxRewriteIn, type AxRewriteOut, AxSignature, AxSimpleClassifier, AxSimpleClassifierClass, type AxSimpleClassifierForwardOptions, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, AxStringUtil, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable, axAIAnthropicDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOllamaDefaultConfig, axAIOllamaDefaultCreativeConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAITogetherDefaultConfig, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoReka, axModelInfoTogether, axSpanAttributes, axSpanEvents };
|