ai 7.0.143 → 7.0.145
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/CHANGELOG.md +19 -0
- package/dist/index.d.ts +8 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -9
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/03-ai-sdk-core/32-decisions.mdx +27 -13
- package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +12 -12
- package/docs/07-reference/01-ai-sdk-core/02-stream-text-low-memory.mdx +9 -11
- package/docs/07-reference/01-ai-sdk-core/14-decide.mdx +23 -0
- package/package.json +13 -12
- package/src/agent/tool-loop-agent.ts +0 -1
- package/src/decide/validate-decision.ts +18 -3
- package/src/generate-text/index.ts +1 -0
- package/src/generate-text/stream-text.ts +13 -44
package/dist/index.js
CHANGED
|
@@ -1174,7 +1174,7 @@ function cloneValue(value) {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
//#endregion
|
|
1176
1176
|
//#region src/version.ts
|
|
1177
|
-
const VERSION = "7.0.
|
|
1177
|
+
const VERSION = "7.0.145";
|
|
1178
1178
|
//#endregion
|
|
1179
1179
|
//#region src/util/download/download.ts
|
|
1180
1180
|
/**
|
|
@@ -8774,8 +8774,82 @@ const originalGenerateCallId$7 = createIdGenerator$1({
|
|
|
8774
8774
|
prefix: "call",
|
|
8775
8775
|
size: 24
|
|
8776
8776
|
});
|
|
8777
|
-
|
|
8778
|
-
|
|
8777
|
+
/**
|
|
8778
|
+
* Generate a text and call tools for a given prompt using a language model.
|
|
8779
|
+
*
|
|
8780
|
+
* This function streams the output. If you do not want to stream the output, use `generateText` instead.
|
|
8781
|
+
*
|
|
8782
|
+
* @param model - The language model to use.
|
|
8783
|
+
* @param tools - Tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
|
8784
|
+
* @param toolOrder - Controls the order in which tools are sent to the provider. Tools not listed are appended alphabetically.
|
|
8785
|
+
* @param toolCallConcurrency - Maximum number of tool calls that may execute concurrently within a step. Set to 1 for sequential execution. Default: unlimited.
|
|
8786
|
+
*
|
|
8787
|
+
* @param system - A system message that will be part of the prompt.
|
|
8788
|
+
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
8789
|
+
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
8790
|
+
* @param allowSystemInMessages - Whether system messages are allowed in the `prompt` or `messages` fields. Default: false.
|
|
8791
|
+
*
|
|
8792
|
+
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
8793
|
+
* @param temperature - Temperature setting.
|
|
8794
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
8795
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
8796
|
+
* @param topP - Nucleus sampling.
|
|
8797
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
8798
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
8799
|
+
* @param topK - Only sample from the top K options for each subsequent token.
|
|
8800
|
+
* Used to remove "long tail" low probability responses.
|
|
8801
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
8802
|
+
* @param presencePenalty - Presence penalty setting.
|
|
8803
|
+
* It affects the likelihood of the model to repeat information that is already in the prompt.
|
|
8804
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
8805
|
+
* @param frequencyPenalty - Frequency penalty setting.
|
|
8806
|
+
* It affects the likelihood of the model to repeatedly use the same words or phrases.
|
|
8807
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
8808
|
+
* @param stopSequences - Stop sequences.
|
|
8809
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
8810
|
+
* @param seed - The seed (integer) to use for random sampling.
|
|
8811
|
+
* If set and supported by the model, calls will generate deterministic results.
|
|
8812
|
+
*
|
|
8813
|
+
* @param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
|
8814
|
+
* @param streamRetries - Maximum number of retries for provider errors received after streaming starts. Set to 0 to disable automatic stream retries while allowing `onError` to request retries. Omit to disable all stream retry behavior. Default: 0.
|
|
8815
|
+
* @param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
8816
|
+
* @param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
|
|
8817
|
+
* @param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
|
8818
|
+
*
|
|
8819
|
+
* @param experimental_sandbox - The sandbox environment that is passed through to tool execution.
|
|
8820
|
+
* @param runtimeContext - User-defined runtime context that flows through the entire generation lifecycle.
|
|
8821
|
+
* @param experimental_refineToolInput - Optional mapping of tool names to functions that refine parsed tool inputs before tools are executed and before outputs, callbacks, and telemetry are recorded.
|
|
8822
|
+
*
|
|
8823
|
+
* @param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
|
8824
|
+
* @param onError - Callback that is called when an error occurs during streaming. You can use it to log errors.
|
|
8825
|
+
* @param onStart - Callback invoked when generation begins, before any LLM calls.
|
|
8826
|
+
* @param experimental_onStart - Deprecated alias for `onStart`.
|
|
8827
|
+
* @param onStepStart - Callback invoked when each step begins, before the provider is called.
|
|
8828
|
+
* @param experimental_onStepStart - Deprecated alias for `onStepStart`.
|
|
8829
|
+
* @param onLanguageModelCallStart - Callback invoked immediately before each provider model call begins.
|
|
8830
|
+
* @param experimental_onLanguageModelCallStart - Deprecated alias for `onLanguageModelCallStart`.
|
|
8831
|
+
* @param onLanguageModelCallEnd - Callback invoked after each provider model call response is normalized and parsed.
|
|
8832
|
+
* @param experimental_onLanguageModelCallEnd - Deprecated alias for `onLanguageModelCallEnd`.
|
|
8833
|
+
* @param onToolExecutionStart - Callback invoked before each tool execution begins.
|
|
8834
|
+
* @param experimental_onToolCallStart - Deprecated alias for `onToolExecutionStart`.
|
|
8835
|
+
* @param onToolExecutionEnd - Callback invoked after each tool execution completes.
|
|
8836
|
+
* @param experimental_onToolCallFinish - Deprecated alias for `onToolExecutionEnd`.
|
|
8837
|
+
* @param onStepEnd - Callback that is called when each step (LLM call) ends, including intermediate steps.
|
|
8838
|
+
* @param onStepFinish - Deprecated alias for `onStepEnd`.
|
|
8839
|
+
* @param onEnd - Callback that is called when all steps are finished and the response is complete.
|
|
8840
|
+
* @param onFinish - Deprecated alias for `onEnd`.
|
|
8841
|
+
*
|
|
8842
|
+
* @returns
|
|
8843
|
+
* A result object for accessing different stream types and additional information.
|
|
8844
|
+
*/
|
|
8845
|
+
function streamText(options) {
|
|
8846
|
+
return streamTextInternal(options);
|
|
8847
|
+
}
|
|
8848
|
+
/**
|
|
8849
|
+
* Stream text with a single consumer, without replay or final-content getters.
|
|
8850
|
+
* Accepts the same options as streamText and uses the same execution engine.
|
|
8851
|
+
*/
|
|
8852
|
+
function streamTextLowMemory(options) {
|
|
8779
8853
|
const telemetry = options.telemetry ?? options.experimental_telemetry;
|
|
8780
8854
|
const integrations = telemetry?.integrations != null ? asArray(telemetry.integrations) : getGlobalTelemetryIntegrations();
|
|
8781
8855
|
const collectContent = options.tools != null && Object.keys(options.tools).length > 0 || options.toolChoice != null || options.output != null || options.prepareStep != null || options.stopWhen != null || options.onEnd != null || options.onFinish != null || options.onStepEnd != null || options.onStepFinish != null || options.onAbort != null || options.onLanguageModelCallEnd != null || options.experimental_onLanguageModelCallEnd != null || telemetry?.isEnabled !== false && integrations.length > 0;
|
|
@@ -10403,7 +10477,7 @@ var DefaultStreamTextResult = class {
|
|
|
10403
10477
|
return this.partialOutputStream;
|
|
10404
10478
|
}
|
|
10405
10479
|
get partialOutputStream() {
|
|
10406
|
-
if (!this.retention.replay && this.outputSpecification == null) throw new UnsupportedFunctionalityError$1({ functionality: "partialOutputStream without an explicit output specification with
|
|
10480
|
+
if (!this.retention.replay && this.outputSpecification == null) throw new UnsupportedFunctionalityError$1({ functionality: "partialOutputStream without an explicit output specification with experimental_streamTextLowMemory" });
|
|
10407
10481
|
return this.asIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ partialOutput }, controller) {
|
|
10408
10482
|
if (partialOutput !== void 0) controller.enqueue(partialOutput);
|
|
10409
10483
|
} })));
|
|
@@ -10640,8 +10714,7 @@ var ToolLoopAgent = class {
|
|
|
10640
10714
|
return await stream({
|
|
10641
10715
|
...preparedCall,
|
|
10642
10716
|
...callbackArgs,
|
|
10643
|
-
headers: this.agentHeaders(preparedCall)
|
|
10644
|
-
experimental_lowMemory: false
|
|
10717
|
+
headers: this.agentHeaders(preparedCall)
|
|
10645
10718
|
});
|
|
10646
10719
|
}
|
|
10647
10720
|
};
|
|
@@ -13003,7 +13076,7 @@ function validateDecisionInput({ state, questions }) {
|
|
|
13003
13076
|
if (!isRecord$1(questions) || Object.keys(questions).length === 0) invalidInput("questions", questions, "must be a nonempty question map");
|
|
13004
13077
|
for (const [id, question] of Object.entries(questions)) {
|
|
13005
13078
|
const parameter = `questions.${id}`;
|
|
13006
|
-
if (!isRecord$1(question) || !isInput(question.instructions)) invalidInput(parameter, question, "instructions must be a JSON-compatible string, object, or array");
|
|
13079
|
+
if (!isRecord$1(question) || (question.type === "box" || question.instructions != null) && !isInput(question.instructions)) invalidInput(parameter, question, "instructions must be a JSON-compatible string, object, or array");
|
|
13007
13080
|
if (question.type === "box") continue;
|
|
13008
13081
|
const criteria = question.criteria;
|
|
13009
13082
|
switch (question.type) {
|
|
@@ -13011,9 +13084,10 @@ function validateDecisionInput({ state, questions }) {
|
|
|
13011
13084
|
if (!isRecord$1(criteria) || Object.keys(criteria).length === 0) invalidInput(parameter, question, "choice criteria must be a nonempty option map");
|
|
13012
13085
|
break;
|
|
13013
13086
|
case "score":
|
|
13014
|
-
if (!Array.isArray(criteria) || criteria.length
|
|
13087
|
+
if (!Array.isArray(criteria) || criteria.length === 0) invalidInput(parameter, question, "score criteria must contain at least one ordered level");
|
|
13015
13088
|
break;
|
|
13016
13089
|
case "boolean":
|
|
13090
|
+
if (question.instructions == null && (!isRecord$1(criteria) || !Object.values(criteria).some((value) => value != null))) invalidInput(parameter, question, "boolean questions require instructions or at least one non-null criterion");
|
|
13017
13091
|
if (criteria === void 0) continue;
|
|
13018
13092
|
if (!isRecord$1(criteria) || Object.keys(criteria).some((key) => key !== "true" && key !== "false")) invalidInput(parameter, question, "boolean criteria may only describe true and false");
|
|
13019
13093
|
break;
|
|
@@ -21091,6 +21165,6 @@ async function uploadSkill({ api, files, displayTitle, providerOptions }) {
|
|
|
21091
21165
|
});
|
|
21092
21166
|
}
|
|
21093
21167
|
//#endregion
|
|
21094
|
-
export { AISDKError, AI_SDK_TELEMETRY_TRACING_CHANNEL, APICallError, AbstractChat, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DownloadError, EmptyResponseBodyError, AbstractRealtimeSession as Experimental_AbstractRealtimeSession, ToolLoopAgent as Experimental_Agent, ToolLoopAgent, Experimental_DecisionRefusalError, Experimental_DecisionUnsupportedQuestionTypeError, Experimental_EvaluationUnsupportedQuestionTypeError, HttpChatTransport, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidPromptError, InvalidResponseDataError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONParseError, JsonToSseTransformStream, LoadAPIKeyError, LoadSettingError, MessageConversionError, MissingToolResultsError, NoContentGeneratedError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchProviderReferenceError, NoSuchToolError, NoTranscriptGeneratedError, NoTranslationGeneratedError, NoVideoGeneratedError, output_exports as Output, RetryError, SerialJobExecutor, StreamProviderError, TextStreamChatTransport, TooManyEmbeddingValuesForCallError, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolChoiceViolationError, TypeValidationError, UIMessageStreamError, UI_MESSAGE_STREAM_HEADERS, UnsupportedFunctionalityError, UnsupportedModelVersionError, WebSocketChatTransport, addToolInputExamplesMiddleware, asSchema, assistantModelMessageSchema, callCompletionApi, consumeStream, convertDataContentToBase64String, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createGateway, createIdGenerator, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultInstructionsMiddleware, defaultSettingsMiddleware, detectToolDrift, dynamicTool, embed, embedMany, cancelBatch as experimental_cancelBatch, experimental_createProviderRegistry, decide as experimental_decide, decodeRealtimeAudio as experimental_decodeRealtimeAudio, encodeRealtimeAudio as experimental_encodeRealtimeAudio, experimental_evaluate, filterActiveTools as experimental_filterActiveTools, experimental_generateSpeech, experimental_generateVideo, getBatchResults as experimental_getBatchResults, getBatchStatus as experimental_getBatchStatus, getRealtimeToolDefinitions as experimental_getRealtimeToolDefinitions, experimental_getVideoStatus, listBatches as experimental_listBatches, resampleAudio as experimental_resampleAudio, startBatch as experimental_startBatch, experimental_startVideo, streamLanguageModelCall as experimental_streamLanguageModelCall, streamTranscribe as experimental_streamTranscribe, streamTranslate as experimental_streamTranslate, experimental_toolCaller, experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, fingerprintTools, gateway, generateId, generateImage, generateObject, generateSpeech, generateText, getChunkTimeoutMs, getFirstChunkTimeoutMs, getStaticToolName, getStepTimeoutMs, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, getToolTimeoutMs, getTotalTimeoutMs, hasToolCall, isCustomContentUIPart, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningFileUIPart, isReasoningUIPart, isStaticToolUIPart, isStepCount, isStepCount as stepCountIs, isTextUIPart, isToolOutputErrorUIPart, isToolUIPart, jsonSchema, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parseJsonEventStream, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetry, rerank, safeValidateUIMessages, safeValidateWebSocketChatTransportRequest, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, systemModelMessageSchema, toTextStream, toUIMessageChunk, toUIMessageStream, tool, toolModelMessageSchema, toolSearch, transcribe, uiMessageChunkSchema, uploadFile, uploadSkill, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider, zodSchema };
|
|
21168
|
+
export { AISDKError, AI_SDK_TELEMETRY_TRACING_CHANNEL, APICallError, AbstractChat, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DownloadError, EmptyResponseBodyError, AbstractRealtimeSession as Experimental_AbstractRealtimeSession, ToolLoopAgent as Experimental_Agent, ToolLoopAgent, Experimental_DecisionRefusalError, Experimental_DecisionUnsupportedQuestionTypeError, Experimental_EvaluationUnsupportedQuestionTypeError, HttpChatTransport, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidPromptError, InvalidResponseDataError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONParseError, JsonToSseTransformStream, LoadAPIKeyError, LoadSettingError, MessageConversionError, MissingToolResultsError, NoContentGeneratedError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchProviderReferenceError, NoSuchToolError, NoTranscriptGeneratedError, NoTranslationGeneratedError, NoVideoGeneratedError, output_exports as Output, RetryError, SerialJobExecutor, StreamProviderError, TextStreamChatTransport, TooManyEmbeddingValuesForCallError, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolChoiceViolationError, TypeValidationError, UIMessageStreamError, UI_MESSAGE_STREAM_HEADERS, UnsupportedFunctionalityError, UnsupportedModelVersionError, WebSocketChatTransport, addToolInputExamplesMiddleware, asSchema, assistantModelMessageSchema, callCompletionApi, consumeStream, convertDataContentToBase64String, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createGateway, createIdGenerator, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultInstructionsMiddleware, defaultSettingsMiddleware, detectToolDrift, dynamicTool, embed, embedMany, cancelBatch as experimental_cancelBatch, experimental_createProviderRegistry, decide as experimental_decide, decodeRealtimeAudio as experimental_decodeRealtimeAudio, encodeRealtimeAudio as experimental_encodeRealtimeAudio, experimental_evaluate, filterActiveTools as experimental_filterActiveTools, experimental_generateSpeech, experimental_generateVideo, getBatchResults as experimental_getBatchResults, getBatchStatus as experimental_getBatchStatus, getRealtimeToolDefinitions as experimental_getRealtimeToolDefinitions, experimental_getVideoStatus, listBatches as experimental_listBatches, resampleAudio as experimental_resampleAudio, startBatch as experimental_startBatch, experimental_startVideo, streamLanguageModelCall as experimental_streamLanguageModelCall, streamTextLowMemory as experimental_streamTextLowMemory, streamTranscribe as experimental_streamTranscribe, streamTranslate as experimental_streamTranslate, experimental_toolCaller, experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, fingerprintTools, gateway, generateId, generateImage, generateObject, generateSpeech, generateText, getChunkTimeoutMs, getFirstChunkTimeoutMs, getStaticToolName, getStepTimeoutMs, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, getToolTimeoutMs, getTotalTimeoutMs, hasToolCall, isCustomContentUIPart, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningFileUIPart, isReasoningUIPart, isStaticToolUIPart, isStepCount, isStepCount as stepCountIs, isTextUIPart, isToolOutputErrorUIPart, isToolUIPart, jsonSchema, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parseJsonEventStream, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetry, rerank, safeValidateUIMessages, safeValidateWebSocketChatTransportRequest, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, systemModelMessageSchema, toTextStream, toUIMessageChunk, toUIMessageStream, tool, toolModelMessageSchema, toolSearch, transcribe, uiMessageChunkSchema, uploadFile, uploadSkill, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider, zodSchema };
|
|
21095
21169
|
|
|
21096
21170
|
//# sourceMappingURL=index.js.map
|