@ax-llm/ax 10.0.48 → 10.0.50
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 +107 -87
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -7
- package/index.d.ts +4 -7
- package/index.js +107 -87
- 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
|
}>[];
|
|
@@ -1500,19 +1501,15 @@ declare class AxFunctionError extends Error {
|
|
|
1500
1501
|
}[];
|
|
1501
1502
|
}
|
|
1502
1503
|
type AxChatResponseFunctionCall = {
|
|
1503
|
-
id
|
|
1504
|
+
id: string;
|
|
1504
1505
|
name: string;
|
|
1505
1506
|
args: string;
|
|
1506
1507
|
};
|
|
1507
|
-
type AxFunctionExec = {
|
|
1508
|
-
id?: string;
|
|
1509
|
-
result?: string;
|
|
1510
|
-
};
|
|
1511
1508
|
declare class AxFunctionProcessor {
|
|
1512
1509
|
private funcList;
|
|
1513
1510
|
constructor(funcList: Readonly<AxFunction[]>);
|
|
1514
1511
|
private executeFunction;
|
|
1515
|
-
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<
|
|
1512
|
+
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<string>;
|
|
1516
1513
|
}
|
|
1517
1514
|
type AxInputFunctionType = AxFunction[] | {
|
|
1518
1515
|
toFunction: () => AxFunction;
|
|
@@ -2249,4 +2246,4 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
2249
2246
|
}>;
|
|
2250
2247
|
}
|
|
2251
2248
|
|
|
2252
|
-
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
|
|
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
|
}>[];
|
|
@@ -1500,19 +1501,15 @@ declare class AxFunctionError extends Error {
|
|
|
1500
1501
|
}[];
|
|
1501
1502
|
}
|
|
1502
1503
|
type AxChatResponseFunctionCall = {
|
|
1503
|
-
id
|
|
1504
|
+
id: string;
|
|
1504
1505
|
name: string;
|
|
1505
1506
|
args: string;
|
|
1506
1507
|
};
|
|
1507
|
-
type AxFunctionExec = {
|
|
1508
|
-
id?: string;
|
|
1509
|
-
result?: string;
|
|
1510
|
-
};
|
|
1511
1508
|
declare class AxFunctionProcessor {
|
|
1512
1509
|
private funcList;
|
|
1513
1510
|
constructor(funcList: Readonly<AxFunction[]>);
|
|
1514
1511
|
private executeFunction;
|
|
1515
|
-
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<
|
|
1512
|
+
execute: (func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxAIServiceActionOptions>) => Promise<string>;
|
|
1516
1513
|
}
|
|
1517
1514
|
type AxInputFunctionType = AxFunction[] | {
|
|
1518
1515
|
toFunction: () => AxFunction;
|
|
@@ -2249,4 +2246,4 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
2249
2246
|
}>;
|
|
2250
2247
|
}
|
|
2251
2248
|
|
|
2252
|
-
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
|
|
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
|
@@ -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:
|
|
@@ -3722,7 +3724,6 @@ var AxAssertionError = class extends Error {
|
|
|
3722
3724
|
}) {
|
|
3723
3725
|
super(message);
|
|
3724
3726
|
this.name = this.constructor.name;
|
|
3725
|
-
this.stack = new Error().stack;
|
|
3726
3727
|
}
|
|
3727
3728
|
getFixingInstructions = () => {
|
|
3728
3729
|
const extraFields = [];
|
|
@@ -4638,9 +4639,9 @@ var functionCallInstructions = `
|
|
|
4638
4639
|
- Use the function results to generate the output fields.`;
|
|
4639
4640
|
var formattingRules = `
|
|
4640
4641
|
## Output Formatting Rules
|
|
4642
|
+
- Output must strictly follow the defined plaintext \`key: value\` field format.
|
|
4641
4643
|
- Each output key, value must strictly adhere to the specified output field formatting rules.
|
|
4642
4644
|
- No preamble, postscript, or supplementary information.
|
|
4643
|
-
- Output must be in plain text, with each \`key: value\` pair on a new line.
|
|
4644
4645
|
- Do not repeat output fields.`;
|
|
4645
4646
|
var AxPromptTemplate = class {
|
|
4646
4647
|
sig;
|
|
@@ -5042,7 +5043,7 @@ function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId)
|
|
|
5042
5043
|
if (ai.getOptions().debug) {
|
|
5043
5044
|
const errors = errorFields.map((field) => `- ${field.title}: ${field.description}`).join("\n");
|
|
5044
5045
|
process.stdout.write(colorLog4.red(`
|
|
5045
|
-
Error Correction:
|
|
5046
|
+
\u274C Error Correction:
|
|
5046
5047
|
${errors}
|
|
5047
5048
|
`));
|
|
5048
5049
|
}
|
|
@@ -5132,7 +5133,7 @@ var checkMissingRequiredFields = (xstate, values, currentIndex) => {
|
|
|
5132
5133
|
});
|
|
5133
5134
|
}
|
|
5134
5135
|
};
|
|
5135
|
-
var streamingExtractValues = (sig, values, xstate, content) => {
|
|
5136
|
+
var streamingExtractValues = (sig, values, xstate, content, streamingValidation = false) => {
|
|
5136
5137
|
const fields = sig.getOutputFields();
|
|
5137
5138
|
for (const [index, field] of fields.entries()) {
|
|
5138
5139
|
if (field.name in values) {
|
|
@@ -5142,6 +5143,12 @@ var streamingExtractValues = (sig, values, xstate, content) => {
|
|
|
5142
5143
|
let e = matchesContent(content, prefix, xstate.s + 1);
|
|
5143
5144
|
switch (e) {
|
|
5144
5145
|
case -1:
|
|
5146
|
+
if (streamingValidation && xstate.s == -1 && !field.isOptional) {
|
|
5147
|
+
throw new ValidationError({
|
|
5148
|
+
message: "Required field not found",
|
|
5149
|
+
fields: [field]
|
|
5150
|
+
});
|
|
5151
|
+
}
|
|
5145
5152
|
continue;
|
|
5146
5153
|
// Field is not found, continue to the next field
|
|
5147
5154
|
case -2:
|
|
@@ -5158,6 +5165,7 @@ var streamingExtractValues = (sig, values, xstate, content) => {
|
|
|
5158
5165
|
checkMissingRequiredFields(xstate, values, index);
|
|
5159
5166
|
xstate.s = e + prefixLen;
|
|
5160
5167
|
xstate.currField = field;
|
|
5168
|
+
xstate.currFieldIndex = index;
|
|
5161
5169
|
if (!xstate.extractedFields.includes(field)) {
|
|
5162
5170
|
xstate.extractedFields.push(field);
|
|
5163
5171
|
}
|
|
@@ -5171,8 +5179,8 @@ var streamingExtractFinalValue = (sig, values, xstate, content) => {
|
|
|
5171
5179
|
values[xstate.currField.name] = parsedValue;
|
|
5172
5180
|
}
|
|
5173
5181
|
}
|
|
5174
|
-
const
|
|
5175
|
-
checkMissingRequiredFields(xstate, values,
|
|
5182
|
+
const sigFields = sig.getOutputFields();
|
|
5183
|
+
checkMissingRequiredFields(xstate, values, sigFields.length);
|
|
5176
5184
|
};
|
|
5177
5185
|
var convertValueToType = (field, val) => {
|
|
5178
5186
|
switch (field.type?.name) {
|
|
@@ -5383,6 +5391,7 @@ var validateJSONSchema = (schema) => {
|
|
|
5383
5391
|
};
|
|
5384
5392
|
|
|
5385
5393
|
// dsp/functions.ts
|
|
5394
|
+
var colorLog5 = new ColorLog();
|
|
5386
5395
|
var AxFunctionError = class extends Error {
|
|
5387
5396
|
constructor(fields) {
|
|
5388
5397
|
super();
|
|
@@ -5392,17 +5401,13 @@ var AxFunctionError = class extends Error {
|
|
|
5392
5401
|
getFields = () => this.fields;
|
|
5393
5402
|
};
|
|
5394
5403
|
var FunctionError = class extends Error {
|
|
5395
|
-
fields
|
|
5396
|
-
func;
|
|
5397
|
-
constructor({
|
|
5398
|
-
fields,
|
|
5399
|
-
func
|
|
5400
|
-
}) {
|
|
5404
|
+
constructor(fields, func, funcId) {
|
|
5401
5405
|
super();
|
|
5402
5406
|
this.fields = fields;
|
|
5403
5407
|
this.func = func;
|
|
5404
|
-
this.
|
|
5408
|
+
this.funcId = funcId;
|
|
5405
5409
|
}
|
|
5410
|
+
getFunctionId = () => this.funcId;
|
|
5406
5411
|
getFieldDescription(fieldName) {
|
|
5407
5412
|
if (!this.func.parameters?.properties?.[fieldName]) {
|
|
5408
5413
|
return "";
|
|
@@ -5415,15 +5420,12 @@ var FunctionError = class extends Error {
|
|
|
5415
5420
|
return description;
|
|
5416
5421
|
}
|
|
5417
5422
|
getFixingInstructions = () => {
|
|
5418
|
-
|
|
5419
|
-
const schemaDescription = this.getFieldDescription(fieldError.field);
|
|
5420
|
-
|
|
5421
|
-
return {
|
|
5422
|
-
name: "functionArgumentError",
|
|
5423
|
-
title: `Errors in Function '${this.func.name}' Arguments`,
|
|
5424
|
-
description: `Please fix the argument '${fieldError.field}' in function '${this.func.name}': ${fullDescription}`
|
|
5425
|
-
};
|
|
5423
|
+
const bulletPoints = this.fields.map((fieldError) => {
|
|
5424
|
+
const schemaDescription = this.getFieldDescription(fieldError.field) || "";
|
|
5425
|
+
return `- \`${fieldError.field}\` - ${fieldError.message} (${schemaDescription}).`;
|
|
5426
5426
|
});
|
|
5427
|
+
return `Errors In Function Arguments: Fix the following invalid arguments to '${this.func.name}'
|
|
5428
|
+
${bulletPoints.join("\n")}`;
|
|
5427
5429
|
};
|
|
5428
5430
|
};
|
|
5429
5431
|
var AxFunctionProcessor = class {
|
|
@@ -5445,16 +5447,10 @@ var AxFunctionProcessor = class {
|
|
|
5445
5447
|
} : void 0;
|
|
5446
5448
|
if (!fnSpec.parameters) {
|
|
5447
5449
|
const res2 = fnSpec.func.length === 1 ? await fnSpec.func(opt) : await fnSpec.func();
|
|
5448
|
-
return
|
|
5449
|
-
id: func.id,
|
|
5450
|
-
result: JSON.stringify(res2, null, 2)
|
|
5451
|
-
};
|
|
5450
|
+
return typeof res2 === "string" ? res2 : JSON.stringify(res2, null, 2);
|
|
5452
5451
|
}
|
|
5453
5452
|
const res = fnSpec.func.length === 2 ? await fnSpec.func(args, opt) : await fnSpec.func(args);
|
|
5454
|
-
return
|
|
5455
|
-
id: func.id,
|
|
5456
|
-
result: JSON.stringify(res, null, 2)
|
|
5457
|
-
};
|
|
5453
|
+
return typeof res === "string" ? res : JSON.stringify(res, null, 2);
|
|
5458
5454
|
};
|
|
5459
5455
|
execute = async (func, options) => {
|
|
5460
5456
|
const fnSpec = this.funcList.find(
|
|
@@ -5470,10 +5466,7 @@ var AxFunctionProcessor = class {
|
|
|
5470
5466
|
return await this.executeFunction(fnSpec, func, options);
|
|
5471
5467
|
} catch (e) {
|
|
5472
5468
|
if (e instanceof AxFunctionError) {
|
|
5473
|
-
throw new FunctionError(
|
|
5474
|
-
fields: e.getFields(),
|
|
5475
|
-
func: fnSpec
|
|
5476
|
-
});
|
|
5469
|
+
throw new FunctionError(e.getFields(), fnSpec, func.id);
|
|
5477
5470
|
}
|
|
5478
5471
|
throw e;
|
|
5479
5472
|
}
|
|
@@ -5497,19 +5490,44 @@ var parseFunctions = (newFuncs, existingFuncs) => {
|
|
|
5497
5490
|
var processFunctions = async (ai, functionList, functionCalls, mem, sessionId, traceId) => {
|
|
5498
5491
|
const funcProc = new AxFunctionProcessor(functionList);
|
|
5499
5492
|
const functionsExecuted = /* @__PURE__ */ new Set();
|
|
5500
|
-
const promises = functionCalls.map(
|
|
5501
|
-
|
|
5493
|
+
const promises = functionCalls.map((func) => {
|
|
5494
|
+
if (!func.id) {
|
|
5495
|
+
throw new Error(`Function ${func.name} did not return an ID`);
|
|
5496
|
+
}
|
|
5497
|
+
const promise = funcProc.execute(func, { sessionId, traceId, ai }).then((functionResult) => {
|
|
5502
5498
|
functionsExecuted.add(func.name.toLowerCase());
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5499
|
+
return {
|
|
5500
|
+
role: "function",
|
|
5501
|
+
result: functionResult ?? "",
|
|
5502
|
+
functionId: func.id
|
|
5503
|
+
};
|
|
5504
|
+
}).catch((e) => {
|
|
5505
|
+
if (e instanceof FunctionError) {
|
|
5506
|
+
const result = e.getFixingInstructions();
|
|
5507
|
+
mem.add(
|
|
5508
|
+
{
|
|
5509
|
+
role: "function",
|
|
5510
|
+
functionId: func.id,
|
|
5511
|
+
isError: true,
|
|
5512
|
+
result
|
|
5513
|
+
},
|
|
5514
|
+
sessionId
|
|
5515
|
+
);
|
|
5516
|
+
mem.addTag("error");
|
|
5517
|
+
if (ai.getOptions().debug) {
|
|
5518
|
+
process.stdout.write(
|
|
5519
|
+
colorLog5.red(`
|
|
5520
|
+
\u274C Function Error Correction:
|
|
5521
|
+
${result}
|
|
5522
|
+
`)
|
|
5523
|
+
);
|
|
5524
|
+
}
|
|
5525
|
+
} else {
|
|
5526
|
+
throw e;
|
|
5509
5527
|
}
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
);
|
|
5528
|
+
});
|
|
5529
|
+
return promise;
|
|
5530
|
+
});
|
|
5513
5531
|
const results = await Promise.all(promises);
|
|
5514
5532
|
results.forEach((result) => {
|
|
5515
5533
|
if (result) {
|
|
@@ -5647,6 +5665,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5647
5665
|
traceId,
|
|
5648
5666
|
functions
|
|
5649
5667
|
}) {
|
|
5668
|
+
const streamingValidation = !functions || functions.length == 0;
|
|
5650
5669
|
const functionCalls = [];
|
|
5651
5670
|
const values = {};
|
|
5652
5671
|
const xstate = {
|
|
@@ -5662,14 +5681,21 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5662
5681
|
if (v.modelUsage) {
|
|
5663
5682
|
this.usage.push({ ...usageInfo, ...v.modelUsage });
|
|
5664
5683
|
}
|
|
5665
|
-
if (result.
|
|
5684
|
+
if (result.functionCalls) {
|
|
5685
|
+
mergeFunctionCalls(functionCalls, result.functionCalls);
|
|
5686
|
+
mem.updateResult(
|
|
5687
|
+
{ name: result.name, content, functionCalls },
|
|
5688
|
+
sessionId
|
|
5689
|
+
);
|
|
5690
|
+
} else if (result.content) {
|
|
5666
5691
|
content += result.content;
|
|
5667
5692
|
mem.updateResult({ name: result.name, content }, sessionId);
|
|
5668
5693
|
const skip = streamingExtractValues(
|
|
5669
5694
|
this.signature,
|
|
5670
5695
|
values,
|
|
5671
5696
|
xstate,
|
|
5672
|
-
content
|
|
5697
|
+
content,
|
|
5698
|
+
streamingValidation
|
|
5673
5699
|
);
|
|
5674
5700
|
if (skip) {
|
|
5675
5701
|
continue;
|
|
@@ -5684,13 +5710,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5684
5710
|
assertAssertions(this.asserts, values);
|
|
5685
5711
|
yield* streamValues(this.signature, values, xstate, content);
|
|
5686
5712
|
}
|
|
5687
|
-
if (result.functionCalls) {
|
|
5688
|
-
mergeFunctionCalls(functionCalls, result.functionCalls);
|
|
5689
|
-
mem.updateResult(
|
|
5690
|
-
{ name: result.name, content, functionCalls },
|
|
5691
|
-
sessionId
|
|
5692
|
-
);
|
|
5693
|
-
}
|
|
5694
5713
|
if (result.finishReason === "length") {
|
|
5695
5714
|
throw new Error("Max tokens reached before completion");
|
|
5696
5715
|
}
|
|
@@ -5709,17 +5728,18 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5709
5728
|
traceId
|
|
5710
5729
|
);
|
|
5711
5730
|
this.functionsExecuted = /* @__PURE__ */ new Set([...this.functionsExecuted, ...fx]);
|
|
5731
|
+
} else {
|
|
5732
|
+
streamingExtractFinalValue(this.signature, values, xstate, content);
|
|
5733
|
+
assertStreamingAssertions(
|
|
5734
|
+
this.streamingAsserts,
|
|
5735
|
+
values,
|
|
5736
|
+
xstate,
|
|
5737
|
+
content,
|
|
5738
|
+
true
|
|
5739
|
+
);
|
|
5740
|
+
assertAssertions(this.asserts, values);
|
|
5741
|
+
yield* streamValues(this.signature, values, xstate, content, true);
|
|
5712
5742
|
}
|
|
5713
|
-
streamingExtractFinalValue(this.signature, values, xstate, content);
|
|
5714
|
-
assertStreamingAssertions(
|
|
5715
|
-
this.streamingAsserts,
|
|
5716
|
-
values,
|
|
5717
|
-
xstate,
|
|
5718
|
-
content,
|
|
5719
|
-
true
|
|
5720
|
-
);
|
|
5721
|
-
assertAssertions(this.asserts, values);
|
|
5722
|
-
yield* streamValues(this.signature, values, xstate, content, true);
|
|
5723
5743
|
}
|
|
5724
5744
|
async processResponse({
|
|
5725
5745
|
ai,
|
|
@@ -5731,15 +5751,15 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5731
5751
|
functions
|
|
5732
5752
|
}) {
|
|
5733
5753
|
const values = {};
|
|
5734
|
-
|
|
5754
|
+
let results = res.results ?? [];
|
|
5755
|
+
if (res.results.length > 1) {
|
|
5756
|
+
results = res.results.filter((r) => r.functionCalls);
|
|
5757
|
+
}
|
|
5758
|
+
for (const result of results) {
|
|
5735
5759
|
if (res.modelUsage) {
|
|
5736
5760
|
this.usage.push({ ...usageInfo, ...res.modelUsage });
|
|
5737
5761
|
}
|
|
5738
5762
|
mem.addResult(result, sessionId);
|
|
5739
|
-
if (result.content) {
|
|
5740
|
-
extractValues(this.signature, values, result.content);
|
|
5741
|
-
assertAssertions(this.asserts, values);
|
|
5742
|
-
}
|
|
5743
5763
|
if (result.functionCalls) {
|
|
5744
5764
|
const funcs = parseFunctionCalls(ai, result.functionCalls, values);
|
|
5745
5765
|
if (funcs) {
|
|
@@ -5756,6 +5776,9 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5756
5776
|
);
|
|
5757
5777
|
this.functionsExecuted = /* @__PURE__ */ new Set([...this.functionsExecuted, ...fx]);
|
|
5758
5778
|
}
|
|
5779
|
+
} else if (result.content) {
|
|
5780
|
+
extractValues(this.signature, values, result.content);
|
|
5781
|
+
assertAssertions(this.asserts, values);
|
|
5759
5782
|
}
|
|
5760
5783
|
if (result.finishReason === "length") {
|
|
5761
5784
|
throw new Error("Max tokens reached before completion");
|
|
@@ -5809,9 +5832,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5809
5832
|
const e1 = e;
|
|
5810
5833
|
errorFields = e1.getFixingInstructions();
|
|
5811
5834
|
err = e;
|
|
5812
|
-
} else if (e instanceof FunctionError) {
|
|
5813
|
-
errorFields = e.getFixingInstructions();
|
|
5814
|
-
err = e;
|
|
5815
5835
|
} else if (e instanceof AxAIServiceStreamTerminatedError) {
|
|
5816
5836
|
} else {
|
|
5817
5837
|
throw e;
|
|
@@ -7413,7 +7433,7 @@ var AxJSInterpreter = class {
|
|
|
7413
7433
|
};
|
|
7414
7434
|
|
|
7415
7435
|
// dsp/router.ts
|
|
7416
|
-
var
|
|
7436
|
+
var colorLog6 = new ColorLog();
|
|
7417
7437
|
var AxRoute = class {
|
|
7418
7438
|
name;
|
|
7419
7439
|
context;
|
|
@@ -7465,7 +7485,7 @@ var AxRouter = class {
|
|
|
7465
7485
|
}
|
|
7466
7486
|
if (this.debug) {
|
|
7467
7487
|
console.log(
|
|
7468
|
-
|
|
7488
|
+
colorLog6.whiteBright(`query: ${text}`) + "\n" + colorLog6.greenBright(
|
|
7469
7489
|
JSON.stringify(m.map((m2) => `${m2.id}, ${m2.score}`))
|
|
7470
7490
|
)
|
|
7471
7491
|
);
|