@ax-llm/ax 10.0.47 → 10.0.49
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 +126 -70
- package/index.cjs.map +1 -1
- package/index.d.cts +18 -18
- package/index.d.ts +18 -18
- package/index.js +125 -70
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -176,6 +176,7 @@ type AxChatRequest = {
|
|
|
176
176
|
} | {
|
|
177
177
|
role: 'function';
|
|
178
178
|
result: string;
|
|
179
|
+
isError?: boolean;
|
|
179
180
|
functionId: string;
|
|
180
181
|
cache?: boolean;
|
|
181
182
|
}>[];
|
|
@@ -1455,24 +1456,16 @@ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxT
|
|
|
1455
1456
|
interface AxAssertion {
|
|
1456
1457
|
fn(values: Record<string, unknown>): boolean | undefined;
|
|
1457
1458
|
message?: string;
|
|
1458
|
-
optional?: boolean;
|
|
1459
1459
|
}
|
|
1460
1460
|
interface AxStreamingAssertion {
|
|
1461
1461
|
fieldName: string;
|
|
1462
1462
|
fn(content: string, done?: boolean): boolean | undefined;
|
|
1463
1463
|
message?: string;
|
|
1464
|
-
optional?: boolean;
|
|
1465
1464
|
}
|
|
1466
1465
|
declare class AxAssertionError extends Error {
|
|
1467
|
-
|
|
1468
|
-
private optional?;
|
|
1469
|
-
constructor({ message, values, optional, }: Readonly<{
|
|
1466
|
+
constructor({ message, }: Readonly<{
|
|
1470
1467
|
message: string;
|
|
1471
|
-
values: Record<string, unknown>;
|
|
1472
|
-
optional?: boolean;
|
|
1473
1468
|
}>);
|
|
1474
|
-
getValue: () => Record<string, unknown>;
|
|
1475
|
-
getOptional: () => boolean | undefined;
|
|
1476
1469
|
getFixingInstructions: () => {
|
|
1477
1470
|
name: string;
|
|
1478
1471
|
title: string;
|
|
@@ -1496,20 +1489,27 @@ declare class AxMemory implements AxAIMemory {
|
|
|
1496
1489
|
reset(sessionId?: string): void;
|
|
1497
1490
|
}
|
|
1498
1491
|
|
|
1492
|
+
declare class AxFunctionError extends Error {
|
|
1493
|
+
private fields;
|
|
1494
|
+
constructor(fields: {
|
|
1495
|
+
field: string;
|
|
1496
|
+
message: string;
|
|
1497
|
+
}[]);
|
|
1498
|
+
getFields: () => {
|
|
1499
|
+
field: string;
|
|
1500
|
+
message: string;
|
|
1501
|
+
}[];
|
|
1502
|
+
}
|
|
1499
1503
|
type AxChatResponseFunctionCall = {
|
|
1500
|
-
id
|
|
1504
|
+
id: string;
|
|
1501
1505
|
name: string;
|
|
1502
1506
|
args: string;
|
|
1503
1507
|
};
|
|
1504
|
-
type AxFunctionExec = {
|
|
1505
|
-
id?: string;
|
|
1506
|
-
result?: string;
|
|
1507
|
-
};
|
|
1508
1508
|
declare class AxFunctionProcessor {
|
|
1509
1509
|
private funcList;
|
|
1510
1510
|
constructor(funcList: Readonly<AxFunction[]>);
|
|
1511
1511
|
private executeFunction;
|
|
1512
|
-
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<
|
|
1512
|
+
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<string>;
|
|
1513
1513
|
}
|
|
1514
1514
|
type AxInputFunctionType = AxFunction[] | {
|
|
1515
1515
|
toFunction: () => AxFunction;
|
|
@@ -1607,8 +1607,8 @@ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenerateResult<A
|
|
|
1607
1607
|
private functions?;
|
|
1608
1608
|
private functionsExecuted;
|
|
1609
1609
|
constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxGenOptions>);
|
|
1610
|
-
addAssert: (fn: AxAssertion["fn"], message?: string
|
|
1611
|
-
addStreamingAssert: (fieldName: string, fn: AxStreamingAssertion["fn"], message?: string
|
|
1610
|
+
addAssert: (fn: AxAssertion["fn"], message?: string) => void;
|
|
1611
|
+
addStreamingAssert: (fieldName: string, fn: AxStreamingAssertion["fn"], message?: string) => void;
|
|
1612
1612
|
private forwardSendRequest;
|
|
1613
1613
|
private forwardCore;
|
|
1614
1614
|
private processStreamingResponse;
|
|
@@ -2246,4 +2246,4 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
2246
2246
|
}>;
|
|
2247
2247
|
}
|
|
2248
2248
|
|
|
2249
|
-
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, 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, 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 AxAIMemory, AxAIMistral, type AxAIMistralArgs, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelMap, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIArgs, 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 AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, type AxBaseAIFeatures, 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, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldTemplateFn, type AxFieldValue, type AxFunction,
|
|
2249
|
+
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, 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, 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 AxAIMemory, AxAIMistral, type AxAIMistralArgs, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelMap, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIArgs, 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 AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, type AxBaseAIFeatures, 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, type AxEvaluateArgs, type AxExample, type AxField, 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, AxMemory, type AxMetricFn, type AxMetricFnArgs, AxMockAIService, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, 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, AxRoute, AxRouter, type AxRouterForwardOptions, AxSignature, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable };
|
package/index.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ type AxChatRequest = {
|
|
|
176
176
|
} | {
|
|
177
177
|
role: 'function';
|
|
178
178
|
result: string;
|
|
179
|
+
isError?: boolean;
|
|
179
180
|
functionId: string;
|
|
180
181
|
cache?: boolean;
|
|
181
182
|
}>[];
|
|
@@ -1455,24 +1456,16 @@ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxT
|
|
|
1455
1456
|
interface AxAssertion {
|
|
1456
1457
|
fn(values: Record<string, unknown>): boolean | undefined;
|
|
1457
1458
|
message?: string;
|
|
1458
|
-
optional?: boolean;
|
|
1459
1459
|
}
|
|
1460
1460
|
interface AxStreamingAssertion {
|
|
1461
1461
|
fieldName: string;
|
|
1462
1462
|
fn(content: string, done?: boolean): boolean | undefined;
|
|
1463
1463
|
message?: string;
|
|
1464
|
-
optional?: boolean;
|
|
1465
1464
|
}
|
|
1466
1465
|
declare class AxAssertionError extends Error {
|
|
1467
|
-
|
|
1468
|
-
private optional?;
|
|
1469
|
-
constructor({ message, values, optional, }: Readonly<{
|
|
1466
|
+
constructor({ message, }: Readonly<{
|
|
1470
1467
|
message: string;
|
|
1471
|
-
values: Record<string, unknown>;
|
|
1472
|
-
optional?: boolean;
|
|
1473
1468
|
}>);
|
|
1474
|
-
getValue: () => Record<string, unknown>;
|
|
1475
|
-
getOptional: () => boolean | undefined;
|
|
1476
1469
|
getFixingInstructions: () => {
|
|
1477
1470
|
name: string;
|
|
1478
1471
|
title: string;
|
|
@@ -1496,20 +1489,27 @@ declare class AxMemory implements AxAIMemory {
|
|
|
1496
1489
|
reset(sessionId?: string): void;
|
|
1497
1490
|
}
|
|
1498
1491
|
|
|
1492
|
+
declare class AxFunctionError extends Error {
|
|
1493
|
+
private fields;
|
|
1494
|
+
constructor(fields: {
|
|
1495
|
+
field: string;
|
|
1496
|
+
message: string;
|
|
1497
|
+
}[]);
|
|
1498
|
+
getFields: () => {
|
|
1499
|
+
field: string;
|
|
1500
|
+
message: string;
|
|
1501
|
+
}[];
|
|
1502
|
+
}
|
|
1499
1503
|
type AxChatResponseFunctionCall = {
|
|
1500
|
-
id
|
|
1504
|
+
id: string;
|
|
1501
1505
|
name: string;
|
|
1502
1506
|
args: string;
|
|
1503
1507
|
};
|
|
1504
|
-
type AxFunctionExec = {
|
|
1505
|
-
id?: string;
|
|
1506
|
-
result?: string;
|
|
1507
|
-
};
|
|
1508
1508
|
declare class AxFunctionProcessor {
|
|
1509
1509
|
private funcList;
|
|
1510
1510
|
constructor(funcList: Readonly<AxFunction[]>);
|
|
1511
1511
|
private executeFunction;
|
|
1512
|
-
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<
|
|
1512
|
+
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<string>;
|
|
1513
1513
|
}
|
|
1514
1514
|
type AxInputFunctionType = AxFunction[] | {
|
|
1515
1515
|
toFunction: () => AxFunction;
|
|
@@ -1607,8 +1607,8 @@ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenerateResult<A
|
|
|
1607
1607
|
private functions?;
|
|
1608
1608
|
private functionsExecuted;
|
|
1609
1609
|
constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxGenOptions>);
|
|
1610
|
-
addAssert: (fn: AxAssertion["fn"], message?: string
|
|
1611
|
-
addStreamingAssert: (fieldName: string, fn: AxStreamingAssertion["fn"], message?: string
|
|
1610
|
+
addAssert: (fn: AxAssertion["fn"], message?: string) => void;
|
|
1611
|
+
addStreamingAssert: (fieldName: string, fn: AxStreamingAssertion["fn"], message?: string) => void;
|
|
1612
1612
|
private forwardSendRequest;
|
|
1613
1613
|
private forwardCore;
|
|
1614
1614
|
private processStreamingResponse;
|
|
@@ -2246,4 +2246,4 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
2246
2246
|
}>;
|
|
2247
2247
|
}
|
|
2248
2248
|
|
|
2249
|
-
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, 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, 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 AxAIMemory, AxAIMistral, type AxAIMistralArgs, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelMap, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIArgs, 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 AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, type AxBaseAIFeatures, 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, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldTemplateFn, type AxFieldValue, type AxFunction,
|
|
2249
|
+
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, 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, 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 AxAIMemory, AxAIMistral, type AxAIMistralArgs, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelMap, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIArgs, 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 AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, type AxBaseAIFeatures, 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, type AxEvaluateArgs, type AxExample, type AxField, 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, AxMemory, type AxMetricFn, type AxMetricFnArgs, AxMockAIService, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, 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, AxRoute, AxRouter, type AxRouterForwardOptions, AxSignature, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable };
|
package/index.js
CHANGED
|
@@ -217,7 +217,7 @@ var AxAIServiceError = class extends Error {
|
|
|
217
217
|
super(message);
|
|
218
218
|
this.url = url;
|
|
219
219
|
this.requestBody = requestBody;
|
|
220
|
-
this.name =
|
|
220
|
+
this.name = this.constructor.name;
|
|
221
221
|
this.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
222
222
|
this.errorId = crypto.randomUUID();
|
|
223
223
|
this.context = context;
|
|
@@ -254,7 +254,7 @@ var AxAIServiceStatusError = class extends AxAIServiceError {
|
|
|
254
254
|
});
|
|
255
255
|
this.status = status;
|
|
256
256
|
this.statusText = statusText;
|
|
257
|
-
this.name =
|
|
257
|
+
this.name = this.constructor.name;
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
var AxAIServiceNetworkError = class extends AxAIServiceError {
|
|
@@ -265,14 +265,14 @@ var AxAIServiceNetworkError = class extends AxAIServiceError {
|
|
|
265
265
|
...context
|
|
266
266
|
});
|
|
267
267
|
this.originalError = originalError;
|
|
268
|
-
this.name =
|
|
268
|
+
this.name = this.constructor.name;
|
|
269
269
|
this.stack = originalError.stack;
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
var AxAIServiceResponseError = class extends AxAIServiceError {
|
|
273
273
|
constructor(message, url, requestBody, context) {
|
|
274
274
|
super(message, url, requestBody, context);
|
|
275
|
-
this.name =
|
|
275
|
+
this.name = this.constructor.name;
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
278
|
var AxAIServiceStreamTerminatedError = class extends AxAIServiceError {
|
|
@@ -282,7 +282,7 @@ var AxAIServiceStreamTerminatedError = class extends AxAIServiceError {
|
|
|
282
282
|
...context
|
|
283
283
|
});
|
|
284
284
|
this.lastChunk = lastChunk;
|
|
285
|
-
this.name =
|
|
285
|
+
this.name = this.constructor.name;
|
|
286
286
|
}
|
|
287
287
|
};
|
|
288
288
|
var AxAIServiceTimeoutError = class extends AxAIServiceError {
|
|
@@ -291,13 +291,13 @@ var AxAIServiceTimeoutError = class extends AxAIServiceError {
|
|
|
291
291
|
timeoutMs,
|
|
292
292
|
...context
|
|
293
293
|
});
|
|
294
|
-
this.name =
|
|
294
|
+
this.name = this.constructor.name;
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
var AxAIServiceAuthenticationError = class extends AxAIServiceError {
|
|
298
298
|
constructor(url, requestBody, context) {
|
|
299
299
|
super("Authentication failed", url, requestBody, context);
|
|
300
|
-
this.name =
|
|
300
|
+
this.name = this.constructor.name;
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
303
|
function calculateRetryDelay(attempt, config) {
|
|
@@ -1486,16 +1486,18 @@ function createMessages(chatPrompt) {
|
|
|
1486
1486
|
const items = chatPrompt.map((msg) => {
|
|
1487
1487
|
switch (msg.role) {
|
|
1488
1488
|
case "function":
|
|
1489
|
+
const content = [
|
|
1490
|
+
{
|
|
1491
|
+
type: "tool_result",
|
|
1492
|
+
content: msg.result,
|
|
1493
|
+
tool_use_id: msg.functionId,
|
|
1494
|
+
...msg.isError ? { is_error: true } : {},
|
|
1495
|
+
...msg.cache ? { cache: { type: "ephemeral" } } : {}
|
|
1496
|
+
}
|
|
1497
|
+
];
|
|
1489
1498
|
return {
|
|
1490
1499
|
role: "user",
|
|
1491
|
-
content
|
|
1492
|
-
{
|
|
1493
|
-
type: "tool_result",
|
|
1494
|
-
content: msg.result,
|
|
1495
|
-
tool_use_id: msg.functionId,
|
|
1496
|
-
...msg.cache ? { cache: { type: "ephemeral" } } : {}
|
|
1497
|
-
}
|
|
1498
|
-
]
|
|
1500
|
+
content
|
|
1499
1501
|
};
|
|
1500
1502
|
case "user": {
|
|
1501
1503
|
if (typeof msg.content === "string") {
|
|
@@ -1504,7 +1506,7 @@ function createMessages(chatPrompt) {
|
|
|
1504
1506
|
content: msg.content
|
|
1505
1507
|
};
|
|
1506
1508
|
}
|
|
1507
|
-
const
|
|
1509
|
+
const content2 = msg.content.map((v) => {
|
|
1508
1510
|
switch (v.type) {
|
|
1509
1511
|
case "text":
|
|
1510
1512
|
return {
|
|
@@ -1528,16 +1530,16 @@ function createMessages(chatPrompt) {
|
|
|
1528
1530
|
});
|
|
1529
1531
|
return {
|
|
1530
1532
|
role: "user",
|
|
1531
|
-
content
|
|
1533
|
+
content: content2
|
|
1532
1534
|
};
|
|
1533
1535
|
}
|
|
1534
1536
|
case "assistant": {
|
|
1535
|
-
let
|
|
1537
|
+
let content2 = "";
|
|
1536
1538
|
if (typeof msg.content === "string") {
|
|
1537
|
-
|
|
1539
|
+
content2 = msg.content;
|
|
1538
1540
|
}
|
|
1539
1541
|
if (typeof msg.functionCalls !== "undefined") {
|
|
1540
|
-
|
|
1542
|
+
content2 = msg.functionCalls.map((v) => {
|
|
1541
1543
|
let input;
|
|
1542
1544
|
if (typeof v.function.params === "string") {
|
|
1543
1545
|
input = JSON.parse(v.function.params);
|
|
@@ -1555,7 +1557,7 @@ function createMessages(chatPrompt) {
|
|
|
1555
1557
|
}
|
|
1556
1558
|
return {
|
|
1557
1559
|
role: "assistant",
|
|
1558
|
-
content
|
|
1560
|
+
content: content2
|
|
1559
1561
|
};
|
|
1560
1562
|
}
|
|
1561
1563
|
default:
|
|
@@ -3717,21 +3719,12 @@ var AxMemory = class {
|
|
|
3717
3719
|
|
|
3718
3720
|
// dsp/asserts.ts
|
|
3719
3721
|
var AxAssertionError = class extends Error {
|
|
3720
|
-
values;
|
|
3721
|
-
optional;
|
|
3722
3722
|
constructor({
|
|
3723
|
-
message
|
|
3724
|
-
values,
|
|
3725
|
-
optional
|
|
3723
|
+
message
|
|
3726
3724
|
}) {
|
|
3727
3725
|
super(message);
|
|
3728
|
-
this.values = values;
|
|
3729
|
-
this.optional = optional;
|
|
3730
3726
|
this.name = this.constructor.name;
|
|
3731
|
-
this.stack = new Error().stack;
|
|
3732
3727
|
}
|
|
3733
|
-
getValue = () => this.values;
|
|
3734
|
-
getOptional = () => this.optional;
|
|
3735
3728
|
getFixingInstructions = () => {
|
|
3736
3729
|
const extraFields = [];
|
|
3737
3730
|
extraFields.push({
|
|
@@ -3744,13 +3737,16 @@ var AxAssertionError = class extends Error {
|
|
|
3744
3737
|
};
|
|
3745
3738
|
var assertAssertions = (asserts, values) => {
|
|
3746
3739
|
for (const assert of asserts) {
|
|
3747
|
-
const { fn, message
|
|
3740
|
+
const { fn, message } = assert;
|
|
3748
3741
|
const res = fn(values);
|
|
3749
3742
|
if (res === void 0) {
|
|
3750
3743
|
continue;
|
|
3751
3744
|
}
|
|
3752
|
-
if (!res
|
|
3753
|
-
|
|
3745
|
+
if (!res) {
|
|
3746
|
+
if (!message) {
|
|
3747
|
+
throw new Error(`Assertion Failed: No message provided for assertion`);
|
|
3748
|
+
}
|
|
3749
|
+
throw new AxAssertionError({ message });
|
|
3754
3750
|
}
|
|
3755
3751
|
}
|
|
3756
3752
|
};
|
|
@@ -3766,13 +3762,13 @@ var assertStreamingAssertions = (asserts, values, xstate, content, final) => {
|
|
|
3766
3762
|
}
|
|
3767
3763
|
const currValue = content.substring(xstate.s);
|
|
3768
3764
|
for (const assert of fieldAsserts) {
|
|
3769
|
-
const { message,
|
|
3765
|
+
const { message, fn } = assert;
|
|
3770
3766
|
const res = fn(currValue, final);
|
|
3771
3767
|
if (res === void 0) {
|
|
3772
3768
|
continue;
|
|
3773
3769
|
}
|
|
3774
3770
|
if (!res && message) {
|
|
3775
|
-
throw new AxAssertionError({ message
|
|
3771
|
+
throw new AxAssertionError({ message });
|
|
3776
3772
|
}
|
|
3777
3773
|
}
|
|
3778
3774
|
};
|
|
@@ -4643,9 +4639,9 @@ var functionCallInstructions = `
|
|
|
4643
4639
|
- Use the function results to generate the output fields.`;
|
|
4644
4640
|
var formattingRules = `
|
|
4645
4641
|
## Output Formatting Rules
|
|
4642
|
+
- Output must strictly follow the defined plaintext \`key: value\` field format.
|
|
4646
4643
|
- Each output key, value must strictly adhere to the specified output field formatting rules.
|
|
4647
4644
|
- No preamble, postscript, or supplementary information.
|
|
4648
|
-
- Output must be in plain text, with each \`key: value\` pair on a new line.
|
|
4649
4645
|
- Do not repeat output fields.`;
|
|
4650
4646
|
var AxPromptTemplate = class {
|
|
4651
4647
|
sig;
|
|
@@ -5026,13 +5022,11 @@ var ValidationError = class extends Error {
|
|
|
5026
5022
|
super(message);
|
|
5027
5023
|
this.fields = fields;
|
|
5028
5024
|
this.name = this.constructor.name;
|
|
5029
|
-
Error.captureStackTrace(this, this.constructor);
|
|
5030
5025
|
}
|
|
5031
|
-
getFields = () => this.fields;
|
|
5032
5026
|
getFixingInstructions = () => {
|
|
5033
5027
|
return this.fields.map((field) => ({
|
|
5034
5028
|
name: "outputError",
|
|
5035
|
-
title: "
|
|
5029
|
+
title: "Errors In Output Fields",
|
|
5036
5030
|
description: `Please fix and return the field \`${field.title}\` of type \`${toFieldType(field.type)}\`, ${this.message}.`
|
|
5037
5031
|
}));
|
|
5038
5032
|
};
|
|
@@ -5049,7 +5043,7 @@ function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId)
|
|
|
5049
5043
|
if (ai.getOptions().debug) {
|
|
5050
5044
|
const errors = errorFields.map((field) => `- ${field.title}: ${field.description}`).join("\n");
|
|
5051
5045
|
process.stdout.write(colorLog4.red(`
|
|
5052
|
-
Error Correction:
|
|
5046
|
+
\u274C Error Correction:
|
|
5053
5047
|
${errors}
|
|
5054
5048
|
`));
|
|
5055
5049
|
}
|
|
@@ -5390,6 +5384,43 @@ var validateJSONSchema = (schema) => {
|
|
|
5390
5384
|
};
|
|
5391
5385
|
|
|
5392
5386
|
// dsp/functions.ts
|
|
5387
|
+
var colorLog5 = new ColorLog();
|
|
5388
|
+
var AxFunctionError = class extends Error {
|
|
5389
|
+
constructor(fields) {
|
|
5390
|
+
super();
|
|
5391
|
+
this.fields = fields;
|
|
5392
|
+
this.name = this.constructor.name;
|
|
5393
|
+
}
|
|
5394
|
+
getFields = () => this.fields;
|
|
5395
|
+
};
|
|
5396
|
+
var FunctionError = class extends Error {
|
|
5397
|
+
constructor(fields, func, funcId) {
|
|
5398
|
+
super();
|
|
5399
|
+
this.fields = fields;
|
|
5400
|
+
this.func = func;
|
|
5401
|
+
this.funcId = funcId;
|
|
5402
|
+
}
|
|
5403
|
+
getFunctionId = () => this.funcId;
|
|
5404
|
+
getFieldDescription(fieldName) {
|
|
5405
|
+
if (!this.func.parameters?.properties?.[fieldName]) {
|
|
5406
|
+
return "";
|
|
5407
|
+
}
|
|
5408
|
+
const fieldSchema = this.func.parameters.properties[fieldName];
|
|
5409
|
+
let description = fieldSchema.description;
|
|
5410
|
+
if (fieldSchema.enum?.length) {
|
|
5411
|
+
description += ` Allowed values are: ${fieldSchema.enum.join(", ")}`;
|
|
5412
|
+
}
|
|
5413
|
+
return description;
|
|
5414
|
+
}
|
|
5415
|
+
getFixingInstructions = () => {
|
|
5416
|
+
const bulletPoints = this.fields.map((fieldError) => {
|
|
5417
|
+
const schemaDescription = this.getFieldDescription(fieldError.field) || "";
|
|
5418
|
+
return `- \`${fieldError.field}\` - ${fieldError.message} (${schemaDescription}).`;
|
|
5419
|
+
});
|
|
5420
|
+
return `Errors In Function Arguments: Fix the following invalid arguments to '${this.func.name}'
|
|
5421
|
+
${bulletPoints.join("\n")}`;
|
|
5422
|
+
};
|
|
5423
|
+
};
|
|
5393
5424
|
var AxFunctionProcessor = class {
|
|
5394
5425
|
funcList = [];
|
|
5395
5426
|
constructor(funcList) {
|
|
@@ -5409,16 +5440,10 @@ var AxFunctionProcessor = class {
|
|
|
5409
5440
|
} : void 0;
|
|
5410
5441
|
if (!fnSpec.parameters) {
|
|
5411
5442
|
const res2 = fnSpec.func.length === 1 ? await fnSpec.func(opt) : await fnSpec.func();
|
|
5412
|
-
return
|
|
5413
|
-
id: func.id,
|
|
5414
|
-
result: JSON.stringify(res2, null, 2)
|
|
5415
|
-
};
|
|
5443
|
+
return typeof res2 === "string" ? res2 : JSON.stringify(res2, null, 2);
|
|
5416
5444
|
}
|
|
5417
5445
|
const res = fnSpec.func.length === 2 ? await fnSpec.func(args, opt) : await fnSpec.func(args);
|
|
5418
|
-
return
|
|
5419
|
-
id: func.id,
|
|
5420
|
-
result: JSON.stringify(res, null, 2)
|
|
5421
|
-
};
|
|
5446
|
+
return typeof res === "string" ? res : JSON.stringify(res, null, 2);
|
|
5422
5447
|
};
|
|
5423
5448
|
execute = async (func, options) => {
|
|
5424
5449
|
const fnSpec = this.funcList.find(
|
|
@@ -5430,7 +5455,14 @@ var AxFunctionProcessor = class {
|
|
|
5430
5455
|
if (!fnSpec.func) {
|
|
5431
5456
|
throw new Error("No handler for function: " + func.name);
|
|
5432
5457
|
}
|
|
5433
|
-
|
|
5458
|
+
try {
|
|
5459
|
+
return await this.executeFunction(fnSpec, func, options);
|
|
5460
|
+
} catch (e) {
|
|
5461
|
+
if (e instanceof AxFunctionError) {
|
|
5462
|
+
throw new FunctionError(e.getFields(), fnSpec, func.id);
|
|
5463
|
+
}
|
|
5464
|
+
throw e;
|
|
5465
|
+
}
|
|
5434
5466
|
};
|
|
5435
5467
|
};
|
|
5436
5468
|
var parseFunctions = (newFuncs, existingFuncs) => {
|
|
@@ -5451,19 +5483,44 @@ var parseFunctions = (newFuncs, existingFuncs) => {
|
|
|
5451
5483
|
var processFunctions = async (ai, functionList, functionCalls, mem, sessionId, traceId) => {
|
|
5452
5484
|
const funcProc = new AxFunctionProcessor(functionList);
|
|
5453
5485
|
const functionsExecuted = /* @__PURE__ */ new Set();
|
|
5454
|
-
const promises = functionCalls.map(
|
|
5455
|
-
|
|
5486
|
+
const promises = functionCalls.map((func) => {
|
|
5487
|
+
if (!func.id) {
|
|
5488
|
+
throw new Error(`Function ${func.name} did not return an ID`);
|
|
5489
|
+
}
|
|
5490
|
+
const promise = funcProc.execute(func, { sessionId, traceId, ai }).then((functionResult) => {
|
|
5456
5491
|
functionsExecuted.add(func.name.toLowerCase());
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5492
|
+
return {
|
|
5493
|
+
role: "function",
|
|
5494
|
+
result: functionResult ?? "",
|
|
5495
|
+
functionId: func.id
|
|
5496
|
+
};
|
|
5497
|
+
}).catch((e) => {
|
|
5498
|
+
if (e instanceof FunctionError) {
|
|
5499
|
+
const result = e.getFixingInstructions();
|
|
5500
|
+
mem.add(
|
|
5501
|
+
{
|
|
5502
|
+
role: "function",
|
|
5503
|
+
functionId: func.id,
|
|
5504
|
+
isError: true,
|
|
5505
|
+
result
|
|
5506
|
+
},
|
|
5507
|
+
sessionId
|
|
5508
|
+
);
|
|
5509
|
+
mem.addTag("error");
|
|
5510
|
+
if (ai.getOptions().debug) {
|
|
5511
|
+
process.stdout.write(
|
|
5512
|
+
colorLog5.red(`
|
|
5513
|
+
\u274C Function Error Correction:
|
|
5514
|
+
${result}
|
|
5515
|
+
`)
|
|
5516
|
+
);
|
|
5517
|
+
}
|
|
5518
|
+
} else {
|
|
5519
|
+
throw e;
|
|
5463
5520
|
}
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
);
|
|
5521
|
+
});
|
|
5522
|
+
return promise;
|
|
5523
|
+
});
|
|
5467
5524
|
const results = await Promise.all(promises);
|
|
5468
5525
|
results.forEach((result) => {
|
|
5469
5526
|
if (result) {
|
|
@@ -5509,11 +5566,11 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5509
5566
|
this.functions = parseFunctions(options.functions);
|
|
5510
5567
|
}
|
|
5511
5568
|
}
|
|
5512
|
-
addAssert = (fn, message
|
|
5513
|
-
this.asserts.push({ fn, message
|
|
5569
|
+
addAssert = (fn, message) => {
|
|
5570
|
+
this.asserts.push({ fn, message });
|
|
5514
5571
|
};
|
|
5515
|
-
addStreamingAssert = (fieldName, fn, message
|
|
5516
|
-
this.streamingAsserts.push({ fieldName, fn, message
|
|
5572
|
+
addStreamingAssert = (fieldName, fn, message) => {
|
|
5573
|
+
this.streamingAsserts.push({ fieldName, fn, message });
|
|
5517
5574
|
};
|
|
5518
5575
|
async forwardSendRequest({
|
|
5519
5576
|
ai,
|
|
@@ -5778,9 +5835,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5778
5835
|
}
|
|
5779
5836
|
}
|
|
5780
5837
|
}
|
|
5781
|
-
if (err instanceof AxAssertionError && err.getOptional()) {
|
|
5782
|
-
return err.getValue();
|
|
5783
|
-
}
|
|
5784
5838
|
throw new Error(`Unable to fix validation error: ${err?.message}`);
|
|
5785
5839
|
}
|
|
5786
5840
|
throw new Error(`Max steps reached: ${maxSteps}`);
|
|
@@ -7367,7 +7421,7 @@ var AxJSInterpreter = class {
|
|
|
7367
7421
|
};
|
|
7368
7422
|
|
|
7369
7423
|
// dsp/router.ts
|
|
7370
|
-
var
|
|
7424
|
+
var colorLog6 = new ColorLog();
|
|
7371
7425
|
var AxRoute = class {
|
|
7372
7426
|
name;
|
|
7373
7427
|
context;
|
|
@@ -7419,7 +7473,7 @@ var AxRouter = class {
|
|
|
7419
7473
|
}
|
|
7420
7474
|
if (this.debug) {
|
|
7421
7475
|
console.log(
|
|
7422
|
-
|
|
7476
|
+
colorLog6.whiteBright(`query: ${text}`) + "\n" + colorLog6.greenBright(
|
|
7423
7477
|
JSON.stringify(m.map((m2) => `${m2.id}, ${m2.score}`))
|
|
7424
7478
|
)
|
|
7425
7479
|
);
|
|
@@ -7839,6 +7893,7 @@ export {
|
|
|
7839
7893
|
AxDefaultResultReranker,
|
|
7840
7894
|
AxDockerSession,
|
|
7841
7895
|
AxEmbeddingAdapter,
|
|
7896
|
+
AxFunctionError,
|
|
7842
7897
|
AxFunctionProcessor,
|
|
7843
7898
|
AxGen,
|
|
7844
7899
|
AxHFDataLoader,
|