ai 6.0.169 → 6.0.171
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 +23 -0
- package/dist/index.d.mts +822 -809
- package/dist/index.d.ts +822 -809
- package/dist/index.js +121 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -37
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +21 -1
- package/dist/internal/index.d.ts +21 -1
- package/dist/internal/index.js +44 -35
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +30 -22
- package/dist/internal/index.mjs.map +1 -1
- package/dist/test/index.d.mts +18 -18
- package/dist/test/index.d.ts +18 -18
- package/dist/test/index.js +24 -22
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +22 -22
- package/dist/test/index.mjs.map +1 -1
- package/docs/02-foundations/03-prompts.mdx +14 -10
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +5 -2
- package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +7 -0
- package/package.json +5 -5
- package/src/agent/agent.ts +7 -7
- package/src/agent/create-agent-ui-stream-response.ts +10 -7
- package/src/agent/create-agent-ui-stream.ts +11 -8
- package/src/agent/infer-agent-tools.ts +1 -1
- package/src/agent/infer-agent-ui-message.ts +2 -2
- package/src/agent/pipe-agent-ui-stream-to-response.ts +11 -8
- package/src/agent/tool-loop-agent-settings.ts +12 -12
- package/src/agent/tool-loop-agent.ts +27 -10
- package/src/embed/embed-many-result.ts +3 -4
- package/src/embed/embed-many.ts +8 -5
- package/src/embed/embed-result.ts +3 -4
- package/src/embed/embed.ts +7 -4
- package/src/error/invalid-stream-part-error.ts +1 -1
- package/src/error/no-image-generated-error.ts +1 -1
- package/src/error/no-object-generated-error.ts +3 -3
- package/src/error/no-speech-generated-error.ts +1 -1
- package/src/error/no-transcript-generated-error.ts +1 -1
- package/src/error/no-video-generated-error.ts +1 -1
- package/src/error/tool-call-repair-error.ts +2 -2
- package/src/error/verify-no-object-generated-error.ts +1 -1
- package/src/generate-image/generate-image-result.ts +5 -5
- package/src/generate-image/generate-image.ts +8 -8
- package/src/generate-image/index.ts +3 -2
- package/src/generate-object/generate-object-result.ts +2 -2
- package/src/generate-object/generate-object.ts +18 -15
- package/src/generate-object/inject-json-instruction.ts +1 -1
- package/src/generate-object/output-strategy.ts +10 -10
- package/src/generate-object/parse-and-validate-object-result.ts +1 -1
- package/src/generate-object/repair-text.ts +1 -1
- package/src/generate-object/stream-object-result.ts +4 -4
- package/src/generate-object/stream-object.ts +27 -18
- package/src/generate-object/validate-object-generation-input.ts +1 -1
- package/src/generate-speech/generate-speech-result.ts +4 -4
- package/src/generate-speech/generate-speech.ts +10 -7
- package/src/generate-speech/generated-audio-file.ts +1 -1
- package/src/generate-text/collect-tool-approvals.ts +4 -4
- package/src/generate-text/content-part.ts +9 -9
- package/src/generate-text/execute-tool-call.ts +9 -9
- package/src/generate-text/extract-reasoning-content.ts +1 -1
- package/src/generate-text/extract-text-content.ts +4 -1
- package/src/generate-text/generate-text-result.ts +19 -15
- package/src/generate-text/generate-text.ts +29 -26
- package/src/generate-text/is-approval-needed.ts +3 -3
- package/src/generate-text/output-utils.ts +1 -1
- package/src/generate-text/output.ts +8 -8
- package/src/generate-text/parse-tool-call.ts +6 -6
- package/src/generate-text/prepare-step.ts +3 -3
- package/src/generate-text/prune-messages.ts +1 -1
- package/src/generate-text/reasoning-output.ts +1 -1
- package/src/generate-text/reasoning.ts +1 -1
- package/src/generate-text/response-message.ts +1 -1
- package/src/generate-text/run-tools-transformation.ts +26 -16
- package/src/generate-text/smooth-stream.ts +6 -4
- package/src/generate-text/step-result.ts +14 -10
- package/src/generate-text/stop-condition.ts +2 -2
- package/src/generate-text/stream-text-result.ts +29 -25
- package/src/generate-text/stream-text.ts +44 -35
- package/src/generate-text/to-response-messages.ts +3 -3
- package/src/generate-text/tool-approval-request-output.ts +2 -2
- package/src/generate-text/tool-call-repair-function.ts +5 -5
- package/src/generate-text/tool-call.ts +4 -4
- package/src/generate-text/tool-error.ts +4 -4
- package/src/generate-text/tool-output-denied.ts +2 -2
- package/src/generate-text/tool-output.ts +3 -3
- package/src/generate-text/tool-result.ts +4 -4
- package/src/generate-text/tool-set.ts +1 -1
- package/src/generate-video/generate-video-result.ts +4 -4
- package/src/global.ts +2 -2
- package/src/index.ts +3 -3
- package/src/logger/log-warnings.ts +1 -1
- package/src/middleware/add-tool-input-examples-middleware.ts +2 -2
- package/src/middleware/default-embedding-settings-middleware.ts +2 -2
- package/src/middleware/default-settings-middleware.ts +2 -2
- package/src/middleware/extract-json-middleware.ts +1 -1
- package/src/middleware/extract-reasoning-middleware.ts +1 -1
- package/src/middleware/simulate-streaming-middleware.ts +1 -1
- package/src/middleware/wrap-embedding-model.ts +2 -2
- package/src/middleware/wrap-image-model.ts +2 -2
- package/src/middleware/wrap-language-model.ts +2 -2
- package/src/middleware/wrap-provider.ts +2 -2
- package/src/model/as-embedding-model-v3.ts +1 -1
- package/src/model/as-image-model-v3.ts +1 -1
- package/src/model/as-language-model-v3.ts +1 -1
- package/src/model/as-provider-v3.ts +1 -1
- package/src/model/as-speech-model-v3.ts +1 -1
- package/src/model/as-transcription-model-v3.ts +4 -1
- package/src/model/resolve-model.ts +8 -8
- package/src/prompt/content-part.ts +1 -1
- package/src/prompt/convert-to-language-model-prompt.ts +12 -12
- package/src/prompt/create-tool-model-output.ts +2 -2
- package/src/prompt/data-content.ts +2 -2
- package/src/prompt/message-conversion-error.ts +1 -1
- package/src/prompt/message.ts +1 -1
- package/src/prompt/prepare-call-settings.ts +1 -1
- package/src/prompt/prepare-tools-and-tool-choice.ts +3 -3
- package/src/prompt/prompt.ts +11 -1
- package/src/prompt/standardize-prompt.ts +50 -30
- package/src/registry/custom-provider.ts +9 -9
- package/src/registry/provider-registry.ts +8 -8
- package/src/rerank/rerank-result.ts +1 -1
- package/src/rerank/rerank.ts +5 -5
- package/src/telemetry/assemble-operation-name.ts +1 -1
- package/src/telemetry/get-base-telemetry-attributes.ts +3 -3
- package/src/telemetry/get-tracer.ts +1 -1
- package/src/telemetry/noop-tracer.ts +1 -1
- package/src/telemetry/record-span.ts +3 -3
- package/src/telemetry/stringify-for-telemetry.ts +1 -1
- package/src/telemetry/telemetry-integration.ts +1 -1
- package/src/telemetry/telemetry-settings.ts +1 -1
- package/src/test/mock-embedding-model-v2.ts +1 -1
- package/src/test/mock-embedding-model-v3.ts +1 -1
- package/src/test/mock-image-model-v2.ts +1 -1
- package/src/test/mock-image-model-v3.ts +1 -1
- package/src/test/mock-language-model-v2.ts +1 -1
- package/src/test/mock-language-model-v3.ts +1 -1
- package/src/test/mock-provider-v2.ts +6 -6
- package/src/test/mock-provider-v3.ts +7 -7
- package/src/test/mock-reranking-model-v3.ts +1 -1
- package/src/test/mock-server-response.ts +1 -1
- package/src/test/mock-speech-model-v2.ts +1 -1
- package/src/test/mock-speech-model-v3.ts +1 -1
- package/src/test/mock-tracer.ts +1 -1
- package/src/test/mock-transcription-model-v2.ts +1 -1
- package/src/test/mock-transcription-model-v3.ts +1 -1
- package/src/test/mock-video-model-v3.ts +1 -1
- package/src/text-stream/pipe-text-stream-to-response.ts +1 -1
- package/src/transcribe/transcribe-result.ts +3 -3
- package/src/transcribe/transcribe.ts +10 -7
- package/src/types/embedding-model-middleware.ts +1 -1
- package/src/types/embedding-model.ts +1 -1
- package/src/types/image-model-middleware.ts +1 -1
- package/src/types/image-model.ts +1 -1
- package/src/types/json-value.ts +1 -1
- package/src/types/language-model-middleware.ts +1 -1
- package/src/types/language-model.ts +2 -2
- package/src/types/provider-metadata.ts +1 -1
- package/src/types/provider.ts +4 -4
- package/src/types/reranking-model.ts +1 -1
- package/src/types/speech-model.ts +1 -1
- package/src/types/transcription-model.ts +4 -1
- package/src/types/usage.ts +1 -1
- package/src/types/video-model.ts +1 -1
- package/src/types/warning.ts +1 -1
- package/src/ui/call-completion-api.ts +2 -2
- package/src/ui/chat-transport.ts +3 -3
- package/src/ui/chat.ts +10 -10
- package/src/ui/convert-file-list-to-file-ui-parts.ts +1 -1
- package/src/ui/convert-to-model-messages.ts +16 -16
- package/src/ui/default-chat-transport.ts +4 -4
- package/src/ui/direct-chat-transport.ts +7 -7
- package/src/ui/http-chat-transport.ts +5 -5
- package/src/ui/process-ui-message-stream.ts +19 -19
- package/src/ui/text-stream-chat-transport.ts +3 -3
- package/src/ui/transform-text-to-ui-message-stream.ts +1 -1
- package/src/ui/ui-messages.ts +5 -5
- package/src/ui/use-completion.ts +1 -1
- package/src/ui/validate-ui-messages.ts +3 -3
- package/src/ui-message-stream/create-ui-message-stream-response.ts +2 -2
- package/src/ui-message-stream/create-ui-message-stream.ts +6 -6
- package/src/ui-message-stream/get-response-ui-message-id.ts +2 -2
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +6 -6
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +3 -3
- package/src/ui-message-stream/read-ui-message-stream.ts +4 -4
- package/src/ui-message-stream/ui-message-chunks.ts +4 -4
- package/src/ui-message-stream/ui-message-stream-on-finish-callback.ts +2 -2
- package/src/ui-message-stream/ui-message-stream-on-step-finish-callback.ts +1 -1
- package/src/ui-message-stream/ui-message-stream-writer.ts +3 -3
- package/src/util/create-resolvable-promise.ts +1 -1
- package/src/util/deep-partial.ts +1 -1
- package/src/util/download/download.ts +0 -2
- package/src/util/merge-objects.ts +5 -0
- package/src/util/parse-partial-json.ts +1 -1
- package/src/util/prepare-retries.ts +1 -1
- package/src/util/serial-job-executor.ts +1 -1
- package/src/util/write-to-server-response.ts +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
+
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, JSONParseError, TypeValidationError, Experimental_VideoModelV3, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
3
|
+
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
1
4
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
2
5
|
export { GatewayModelId, createGateway, gateway } from '@ai-sdk/gateway';
|
|
3
6
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
-
import {
|
|
7
|
+
import { FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ProviderOptions, UserModelMessage, IdGenerator, ToolCall, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
|
|
5
8
|
export { AssistantContent, AssistantModelMessage, DataContent, DownloadError, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolExecutionOptions, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
6
|
-
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
7
|
-
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, LanguageModelV3ToolChoice, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, JSONParseError, TypeValidationError, Experimental_VideoModelV3, EmbeddingModelV3CallOptions, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
8
|
-
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
9
9
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
10
10
|
import { ServerResponse } from 'node:http';
|
|
11
11
|
import { ServerResponse as ServerResponse$1 } from 'http';
|
|
@@ -344,241 +344,31 @@ type ImageModelUsage = ImageModelV3Usage;
|
|
|
344
344
|
type Warning = SharedV3Warning;
|
|
345
345
|
|
|
346
346
|
/**
|
|
347
|
-
* A
|
|
348
|
-
*/
|
|
349
|
-
interface GeneratedFile {
|
|
350
|
-
/**
|
|
351
|
-
* File as a base64 encoded string.
|
|
352
|
-
*/
|
|
353
|
-
readonly base64: string;
|
|
354
|
-
/**
|
|
355
|
-
* File as a Uint8Array.
|
|
356
|
-
*/
|
|
357
|
-
readonly uint8Array: Uint8Array;
|
|
358
|
-
/**
|
|
359
|
-
* The IANA media type of the file.
|
|
360
|
-
*
|
|
361
|
-
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
362
|
-
*/
|
|
363
|
-
readonly mediaType: string;
|
|
364
|
-
}
|
|
365
|
-
declare class DefaultGeneratedFile implements GeneratedFile {
|
|
366
|
-
private base64Data;
|
|
367
|
-
private uint8ArrayData;
|
|
368
|
-
readonly mediaType: string;
|
|
369
|
-
constructor({ data, mediaType, }: {
|
|
370
|
-
data: string | Uint8Array;
|
|
371
|
-
mediaType: string;
|
|
372
|
-
});
|
|
373
|
-
get base64(): string;
|
|
374
|
-
get uint8Array(): Uint8Array<ArrayBufferLike>;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
347
|
+
* A function for logging warnings.
|
|
379
348
|
*
|
|
380
|
-
*
|
|
349
|
+
* You can assign it to the `AI_SDK_LOG_WARNINGS` global variable to use it as the default warning logger.
|
|
381
350
|
*
|
|
382
351
|
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* globalThis.AI_SDK_LOG_WARNINGS = (options) => {
|
|
354
|
+
* console.log('WARNINGS:', options.warnings, options.provider, options.model);
|
|
355
|
+
* };
|
|
383
356
|
* ```
|
|
384
|
-
* // data.json
|
|
385
|
-
* {
|
|
386
|
-
* 'foo': 1,
|
|
387
|
-
* 'bar': 2,
|
|
388
|
-
* 'biz': 3
|
|
389
|
-
* }
|
|
390
|
-
*
|
|
391
|
-
* // main.ts
|
|
392
|
-
* import type {ValueOf} from 'type-fest';
|
|
393
|
-
* import data = require('./data.json');
|
|
394
|
-
*
|
|
395
|
-
* export function getData(name: string): ValueOf<typeof data> {
|
|
396
|
-
* return data[name];
|
|
397
|
-
* }
|
|
398
|
-
*
|
|
399
|
-
* export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
|
|
400
|
-
* return data[name];
|
|
401
|
-
* }
|
|
402
|
-
*
|
|
403
|
-
* // file.ts
|
|
404
|
-
* import {getData, onlyBar} from './main';
|
|
405
|
-
*
|
|
406
|
-
* getData('foo');
|
|
407
|
-
* //=> 1
|
|
408
|
-
*
|
|
409
|
-
* onlyBar('foo');
|
|
410
|
-
* //=> TypeError ...
|
|
411
|
-
*
|
|
412
|
-
* onlyBar('bar');
|
|
413
|
-
* //=> 2
|
|
414
|
-
* ```
|
|
415
|
-
* @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
|
|
416
|
-
*/
|
|
417
|
-
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
418
|
-
|
|
419
|
-
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta' | 'needsApproval'>>;
|
|
420
|
-
|
|
421
|
-
type BaseToolCall = {
|
|
422
|
-
type: 'tool-call';
|
|
423
|
-
toolCallId: string;
|
|
424
|
-
providerExecuted?: boolean;
|
|
425
|
-
providerMetadata?: ProviderMetadata;
|
|
426
|
-
};
|
|
427
|
-
type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
|
|
428
|
-
[NAME in keyof TOOLS]: BaseToolCall & {
|
|
429
|
-
toolName: NAME & string;
|
|
430
|
-
input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
|
|
431
|
-
dynamic?: false | undefined;
|
|
432
|
-
invalid?: false | undefined;
|
|
433
|
-
error?: never;
|
|
434
|
-
title?: string;
|
|
435
|
-
};
|
|
436
|
-
}>;
|
|
437
|
-
type DynamicToolCall = BaseToolCall & {
|
|
438
|
-
toolName: string;
|
|
439
|
-
input: unknown;
|
|
440
|
-
dynamic: true;
|
|
441
|
-
title?: string;
|
|
442
|
-
/**
|
|
443
|
-
* True if this is caused by an unparsable tool call or
|
|
444
|
-
* a tool that does not exist.
|
|
445
|
-
*/
|
|
446
|
-
invalid?: boolean;
|
|
447
|
-
/**
|
|
448
|
-
* The error that caused the tool call to be invalid.
|
|
449
|
-
*/
|
|
450
|
-
error?: unknown;
|
|
451
|
-
};
|
|
452
|
-
type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Output part that indicates that a tool approval request has been made.
|
|
456
|
-
*
|
|
457
|
-
* The tool approval request can be approved or denied in the next tool message.
|
|
458
357
|
*/
|
|
459
|
-
type
|
|
460
|
-
type: 'tool-approval-request';
|
|
461
|
-
/**
|
|
462
|
-
* ID of the tool approval request.
|
|
463
|
-
*/
|
|
464
|
-
approvalId: string;
|
|
358
|
+
type LogWarningsFunction = (options: {
|
|
465
359
|
/**
|
|
466
|
-
*
|
|
360
|
+
* The warnings returned by the model provider.
|
|
467
361
|
*/
|
|
468
|
-
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Reasoning output of a text generation. It contains a reasoning.
|
|
473
|
-
*/
|
|
474
|
-
interface ReasoningOutput {
|
|
475
|
-
type: 'reasoning';
|
|
362
|
+
warnings: Warning[];
|
|
476
363
|
/**
|
|
477
|
-
* The
|
|
364
|
+
* The provider id used for the call.
|
|
478
365
|
*/
|
|
479
|
-
|
|
366
|
+
provider: string;
|
|
480
367
|
/**
|
|
481
|
-
*
|
|
482
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
483
|
-
* functionality that can be fully encapsulated in the provider.
|
|
368
|
+
* The model id used for the call.
|
|
484
369
|
*/
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
489
|
-
[NAME in keyof TOOLS]: {
|
|
490
|
-
type: 'tool-error';
|
|
491
|
-
toolCallId: string;
|
|
492
|
-
toolName: NAME & string;
|
|
493
|
-
input: InferToolInput<TOOLS[NAME]>;
|
|
494
|
-
error: unknown;
|
|
495
|
-
providerExecuted?: boolean;
|
|
496
|
-
providerMetadata?: ProviderMetadata;
|
|
497
|
-
dynamic?: false | undefined;
|
|
498
|
-
title?: string;
|
|
499
|
-
};
|
|
500
|
-
}>;
|
|
501
|
-
type DynamicToolError = {
|
|
502
|
-
type: 'tool-error';
|
|
503
|
-
toolCallId: string;
|
|
504
|
-
toolName: string;
|
|
505
|
-
input: unknown;
|
|
506
|
-
error: unknown;
|
|
507
|
-
providerExecuted?: boolean;
|
|
508
|
-
providerMetadata?: ProviderMetadata;
|
|
509
|
-
dynamic: true;
|
|
510
|
-
title?: string;
|
|
511
|
-
};
|
|
512
|
-
type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
|
|
513
|
-
|
|
514
|
-
type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
|
|
515
|
-
[NAME in keyof TOOLS]: {
|
|
516
|
-
type: 'tool-result';
|
|
517
|
-
toolCallId: string;
|
|
518
|
-
toolName: NAME & string;
|
|
519
|
-
input: InferToolInput<TOOLS[NAME]>;
|
|
520
|
-
output: InferToolOutput<TOOLS[NAME]>;
|
|
521
|
-
providerExecuted?: boolean;
|
|
522
|
-
providerMetadata?: ProviderMetadata;
|
|
523
|
-
dynamic?: false | undefined;
|
|
524
|
-
preliminary?: boolean;
|
|
525
|
-
title?: string;
|
|
526
|
-
};
|
|
527
|
-
}>;
|
|
528
|
-
type DynamicToolResult = {
|
|
529
|
-
type: 'tool-result';
|
|
530
|
-
toolCallId: string;
|
|
531
|
-
toolName: string;
|
|
532
|
-
input: unknown;
|
|
533
|
-
output: unknown;
|
|
534
|
-
providerExecuted?: boolean;
|
|
535
|
-
providerMetadata?: ProviderMetadata;
|
|
536
|
-
dynamic: true;
|
|
537
|
-
preliminary?: boolean;
|
|
538
|
-
title?: string;
|
|
539
|
-
};
|
|
540
|
-
type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
|
|
541
|
-
|
|
542
|
-
type ContentPart<TOOLS extends ToolSet> = {
|
|
543
|
-
type: 'text';
|
|
544
|
-
text: string;
|
|
545
|
-
providerMetadata?: ProviderMetadata;
|
|
546
|
-
} | ReasoningOutput | ({
|
|
547
|
-
type: 'source';
|
|
548
|
-
} & Source) | {
|
|
549
|
-
type: 'file';
|
|
550
|
-
file: GeneratedFile;
|
|
551
|
-
providerMetadata?: ProviderMetadata;
|
|
552
|
-
} | ({
|
|
553
|
-
type: 'tool-call';
|
|
554
|
-
} & TypedToolCall<TOOLS> & {
|
|
555
|
-
providerMetadata?: ProviderMetadata;
|
|
556
|
-
}) | ({
|
|
557
|
-
type: 'tool-result';
|
|
558
|
-
} & TypedToolResult<TOOLS> & {
|
|
559
|
-
providerMetadata?: ProviderMetadata;
|
|
560
|
-
}) | ({
|
|
561
|
-
type: 'tool-error';
|
|
562
|
-
} & TypedToolError<TOOLS> & {
|
|
563
|
-
providerMetadata?: ProviderMetadata;
|
|
564
|
-
}) | ToolApprovalRequestOutput<TOOLS>;
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Create a type from an object with all keys and nested keys set to optional.
|
|
568
|
-
* The helper supports normal objects and schemas (which are resolved automatically).
|
|
569
|
-
* It always recurses into arrays.
|
|
570
|
-
*
|
|
571
|
-
* Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
|
572
|
-
*/
|
|
573
|
-
type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
|
|
574
|
-
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
|
575
|
-
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
576
|
-
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
|
577
|
-
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
578
|
-
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
|
579
|
-
type PartialObject<ObjectType extends object> = {
|
|
580
|
-
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
|
581
|
-
};
|
|
370
|
+
model: string;
|
|
371
|
+
}) => void;
|
|
582
372
|
|
|
583
373
|
/**
|
|
584
374
|
* Timeout configuration for API calls. Can be specified as:
|
|
@@ -671,16 +461,42 @@ type CallSettings = {
|
|
|
671
461
|
};
|
|
672
462
|
|
|
673
463
|
/**
|
|
674
|
-
*
|
|
675
|
-
*
|
|
464
|
+
* Create a type from an object with all keys and nested keys set to optional.
|
|
465
|
+
* The helper supports normal objects and schemas (which are resolved automatically).
|
|
466
|
+
* It always recurses into arrays.
|
|
467
|
+
*
|
|
468
|
+
* Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
|
676
469
|
*/
|
|
677
|
-
type
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
} &
|
|
683
|
-
|
|
470
|
+
type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
|
|
471
|
+
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
|
472
|
+
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
473
|
+
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
|
474
|
+
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
475
|
+
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
|
476
|
+
type PartialObject<ObjectType extends object> = {
|
|
477
|
+
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Prompt part of the AI function options.
|
|
482
|
+
* It contains a system message, a simple text prompt, or a list of messages.
|
|
483
|
+
*/
|
|
484
|
+
type Prompt = {
|
|
485
|
+
/**
|
|
486
|
+
* System message to include in the prompt. Can be used with `prompt` or `messages`.
|
|
487
|
+
*/
|
|
488
|
+
system?: string | SystemModelMessage | Array<SystemModelMessage>;
|
|
489
|
+
/**
|
|
490
|
+
* Whether system messages are allowed in the `prompt` or `messages` fields.
|
|
491
|
+
*
|
|
492
|
+
* When disabled, system messages must be provided through the `system`
|
|
493
|
+
* option. When unset, system messages are allowed with a warning.
|
|
494
|
+
*
|
|
495
|
+
* @default undefined
|
|
496
|
+
*/
|
|
497
|
+
allowSystemInMessages?: boolean;
|
|
498
|
+
} & ({
|
|
499
|
+
/**
|
|
684
500
|
* A prompt. It can be either a text prompt or a list of messages.
|
|
685
501
|
*
|
|
686
502
|
* You can either use `prompt` or `messages` but not both.
|
|
@@ -708,98 +524,386 @@ type Prompt = {
|
|
|
708
524
|
});
|
|
709
525
|
|
|
710
526
|
/**
|
|
711
|
-
*
|
|
712
|
-
* It can be either an assistant message or a tool message.
|
|
713
|
-
*/
|
|
714
|
-
type ResponseMessage = AssistantModelMessage | ToolModelMessage;
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* The result of a single step in the generation process.
|
|
527
|
+
* Telemetry configuration.
|
|
718
528
|
*/
|
|
719
|
-
type
|
|
720
|
-
/**
|
|
721
|
-
* Zero-based index of this step.
|
|
722
|
-
*/
|
|
723
|
-
readonly stepNumber: number;
|
|
724
|
-
/**
|
|
725
|
-
* Information about the model that produced this step.
|
|
726
|
-
*/
|
|
727
|
-
readonly model: {
|
|
728
|
-
/** The provider of the model. */
|
|
729
|
-
readonly provider: string;
|
|
730
|
-
/** The ID of the model. */
|
|
731
|
-
readonly modelId: string;
|
|
732
|
-
};
|
|
733
|
-
/**
|
|
734
|
-
* Identifier from telemetry settings for grouping related operations.
|
|
735
|
-
*/
|
|
736
|
-
readonly functionId: string | undefined;
|
|
529
|
+
type TelemetrySettings = {
|
|
737
530
|
/**
|
|
738
|
-
*
|
|
531
|
+
* Enable or disable telemetry. Disabled by default while experimental.
|
|
739
532
|
*/
|
|
740
|
-
|
|
533
|
+
isEnabled?: boolean;
|
|
741
534
|
/**
|
|
742
|
-
*
|
|
535
|
+
* Enable or disable input recording. Enabled by default.
|
|
743
536
|
*
|
|
744
|
-
*
|
|
537
|
+
* You might want to disable input recording to avoid recording sensitive
|
|
538
|
+
* information, to reduce data transfers, or to increase performance.
|
|
745
539
|
*/
|
|
746
|
-
|
|
540
|
+
recordInputs?: boolean;
|
|
747
541
|
/**
|
|
748
|
-
*
|
|
542
|
+
* Enable or disable output recording. Enabled by default.
|
|
543
|
+
*
|
|
544
|
+
* You might want to disable output recording to avoid recording sensitive
|
|
545
|
+
* information, to reduce data transfers, or to increase performance.
|
|
749
546
|
*/
|
|
750
|
-
|
|
547
|
+
recordOutputs?: boolean;
|
|
751
548
|
/**
|
|
752
|
-
*
|
|
549
|
+
* Identifier for this function. Used to group telemetry data by function.
|
|
753
550
|
*/
|
|
754
|
-
|
|
551
|
+
functionId?: string;
|
|
755
552
|
/**
|
|
756
|
-
*
|
|
553
|
+
* Additional information to include in the telemetry data.
|
|
757
554
|
*/
|
|
758
|
-
|
|
555
|
+
metadata?: Record<string, AttributeValue>;
|
|
759
556
|
/**
|
|
760
|
-
*
|
|
557
|
+
* A custom tracer to use for the telemetry data.
|
|
761
558
|
*/
|
|
762
|
-
|
|
559
|
+
tracer?: Tracer;
|
|
763
560
|
/**
|
|
764
|
-
*
|
|
561
|
+
* Per-call telemetry integrations that receive lifecycle events during generation.
|
|
562
|
+
*
|
|
563
|
+
* These integrations run after any globally registered integrations
|
|
564
|
+
* (see `registerTelemetryIntegration`).
|
|
765
565
|
*/
|
|
766
|
-
|
|
566
|
+
integrations?: TelemetryIntegration | TelemetryIntegration[];
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Experimental. Can change in patch versions without warning.
|
|
571
|
+
*
|
|
572
|
+
* Download function. Called with the array of URLs and a boolean indicating
|
|
573
|
+
* whether the URL is supported by the model.
|
|
574
|
+
*
|
|
575
|
+
* The download function can decide for each URL:
|
|
576
|
+
* - to return null (which means that the URL should be passed to the model)
|
|
577
|
+
* - to download the asset and return the data (incl. retries, authentication, etc.)
|
|
578
|
+
*
|
|
579
|
+
* Should throw DownloadError if the download fails.
|
|
580
|
+
*
|
|
581
|
+
* Should return an array of objects sorted by the order of the requested downloads.
|
|
582
|
+
* For each object, the data should be a Uint8Array if the URL was downloaded.
|
|
583
|
+
* For each object, the mediaType should be the media type of the downloaded asset.
|
|
584
|
+
* For each object, the data should be null if the URL should be passed through as is.
|
|
585
|
+
*/
|
|
586
|
+
type DownloadFunction = (options: Array<{
|
|
587
|
+
url: URL;
|
|
588
|
+
isUrlSupportedByModel: boolean;
|
|
589
|
+
}>) => PromiseLike<Array<{
|
|
590
|
+
data: Uint8Array;
|
|
591
|
+
mediaType: string | undefined;
|
|
592
|
+
} | null>>;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Reasoning output of a text generation. It contains a reasoning.
|
|
596
|
+
*/
|
|
597
|
+
interface ReasoningOutput {
|
|
598
|
+
type: 'reasoning';
|
|
767
599
|
/**
|
|
768
|
-
* The
|
|
600
|
+
* The reasoning text.
|
|
769
601
|
*/
|
|
770
|
-
|
|
602
|
+
text: string;
|
|
771
603
|
/**
|
|
772
|
-
*
|
|
604
|
+
* Additional provider-specific metadata. They are passed through
|
|
605
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
606
|
+
* functionality that can be fully encapsulated in the provider.
|
|
773
607
|
*/
|
|
774
|
-
|
|
608
|
+
providerMetadata?: ProviderMetadata;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* A generated file.
|
|
613
|
+
*/
|
|
614
|
+
interface GeneratedFile {
|
|
775
615
|
/**
|
|
776
|
-
*
|
|
616
|
+
* File as a base64 encoded string.
|
|
777
617
|
*/
|
|
778
|
-
readonly
|
|
618
|
+
readonly base64: string;
|
|
779
619
|
/**
|
|
780
|
-
*
|
|
620
|
+
* File as a Uint8Array.
|
|
781
621
|
*/
|
|
782
|
-
readonly
|
|
622
|
+
readonly uint8Array: Uint8Array;
|
|
783
623
|
/**
|
|
784
|
-
* The
|
|
624
|
+
* The IANA media type of the file.
|
|
625
|
+
*
|
|
626
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
785
627
|
*/
|
|
786
|
-
readonly
|
|
628
|
+
readonly mediaType: string;
|
|
629
|
+
}
|
|
630
|
+
declare class DefaultGeneratedFile implements GeneratedFile {
|
|
631
|
+
private base64Data;
|
|
632
|
+
private uint8ArrayData;
|
|
633
|
+
readonly mediaType: string;
|
|
634
|
+
constructor({ data, mediaType, }: {
|
|
635
|
+
data: string | Uint8Array;
|
|
636
|
+
mediaType: string;
|
|
637
|
+
});
|
|
638
|
+
get base64(): string;
|
|
639
|
+
get uint8Array(): Uint8Array<ArrayBufferLike>;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
644
|
+
*
|
|
645
|
+
* Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```
|
|
649
|
+
* // data.json
|
|
650
|
+
* {
|
|
651
|
+
* 'foo': 1,
|
|
652
|
+
* 'bar': 2,
|
|
653
|
+
* 'biz': 3
|
|
654
|
+
* }
|
|
655
|
+
*
|
|
656
|
+
* // main.ts
|
|
657
|
+
* import type {ValueOf} from 'type-fest';
|
|
658
|
+
* import data = require('./data.json');
|
|
659
|
+
*
|
|
660
|
+
* export function getData(name: string): ValueOf<typeof data> {
|
|
661
|
+
* return data[name];
|
|
662
|
+
* }
|
|
663
|
+
*
|
|
664
|
+
* export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
|
|
665
|
+
* return data[name];
|
|
666
|
+
* }
|
|
667
|
+
*
|
|
668
|
+
* // file.ts
|
|
669
|
+
* import {getData, onlyBar} from './main';
|
|
670
|
+
*
|
|
671
|
+
* getData('foo');
|
|
672
|
+
* //=> 1
|
|
673
|
+
*
|
|
674
|
+
* onlyBar('foo');
|
|
675
|
+
* //=> TypeError ...
|
|
676
|
+
*
|
|
677
|
+
* onlyBar('bar');
|
|
678
|
+
* //=> 2
|
|
679
|
+
* ```
|
|
680
|
+
* @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
|
|
681
|
+
*/
|
|
682
|
+
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
683
|
+
|
|
684
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta' | 'needsApproval'>>;
|
|
685
|
+
|
|
686
|
+
type BaseToolCall = {
|
|
687
|
+
type: 'tool-call';
|
|
688
|
+
toolCallId: string;
|
|
689
|
+
providerExecuted?: boolean;
|
|
690
|
+
providerMetadata?: ProviderMetadata;
|
|
691
|
+
};
|
|
692
|
+
type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
|
|
693
|
+
[NAME in keyof TOOLS]: BaseToolCall & {
|
|
694
|
+
toolName: NAME & string;
|
|
695
|
+
input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
|
|
696
|
+
dynamic?: false | undefined;
|
|
697
|
+
invalid?: false | undefined;
|
|
698
|
+
error?: never;
|
|
699
|
+
title?: string;
|
|
700
|
+
};
|
|
701
|
+
}>;
|
|
702
|
+
type DynamicToolCall = BaseToolCall & {
|
|
703
|
+
toolName: string;
|
|
704
|
+
input: unknown;
|
|
705
|
+
dynamic: true;
|
|
706
|
+
title?: string;
|
|
787
707
|
/**
|
|
788
|
-
*
|
|
708
|
+
* True if this is caused by an unparsable tool call or
|
|
709
|
+
* a tool that does not exist.
|
|
789
710
|
*/
|
|
790
|
-
|
|
711
|
+
invalid?: boolean;
|
|
791
712
|
/**
|
|
792
|
-
* The
|
|
713
|
+
* The error that caused the tool call to be invalid.
|
|
793
714
|
*/
|
|
794
|
-
|
|
715
|
+
error?: unknown;
|
|
716
|
+
};
|
|
717
|
+
type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Output part that indicates that a tool approval request has been made.
|
|
721
|
+
*
|
|
722
|
+
* The tool approval request can be approved or denied in the next tool message.
|
|
723
|
+
*/
|
|
724
|
+
type ToolApprovalRequestOutput<TOOLS extends ToolSet> = {
|
|
725
|
+
type: 'tool-approval-request';
|
|
795
726
|
/**
|
|
796
|
-
*
|
|
727
|
+
* ID of the tool approval request.
|
|
797
728
|
*/
|
|
798
|
-
|
|
729
|
+
approvalId: string;
|
|
799
730
|
/**
|
|
800
|
-
*
|
|
731
|
+
* Tool call that the approval request is for.
|
|
801
732
|
*/
|
|
802
|
-
|
|
733
|
+
toolCall: TypedToolCall<TOOLS>;
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
737
|
+
[NAME in keyof TOOLS]: {
|
|
738
|
+
type: 'tool-error';
|
|
739
|
+
toolCallId: string;
|
|
740
|
+
toolName: NAME & string;
|
|
741
|
+
input: InferToolInput<TOOLS[NAME]>;
|
|
742
|
+
error: unknown;
|
|
743
|
+
providerExecuted?: boolean;
|
|
744
|
+
providerMetadata?: ProviderMetadata;
|
|
745
|
+
dynamic?: false | undefined;
|
|
746
|
+
title?: string;
|
|
747
|
+
};
|
|
748
|
+
}>;
|
|
749
|
+
type DynamicToolError = {
|
|
750
|
+
type: 'tool-error';
|
|
751
|
+
toolCallId: string;
|
|
752
|
+
toolName: string;
|
|
753
|
+
input: unknown;
|
|
754
|
+
error: unknown;
|
|
755
|
+
providerExecuted?: boolean;
|
|
756
|
+
providerMetadata?: ProviderMetadata;
|
|
757
|
+
dynamic: true;
|
|
758
|
+
title?: string;
|
|
759
|
+
};
|
|
760
|
+
type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
|
|
761
|
+
|
|
762
|
+
type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
|
|
763
|
+
[NAME in keyof TOOLS]: {
|
|
764
|
+
type: 'tool-result';
|
|
765
|
+
toolCallId: string;
|
|
766
|
+
toolName: NAME & string;
|
|
767
|
+
input: InferToolInput<TOOLS[NAME]>;
|
|
768
|
+
output: InferToolOutput<TOOLS[NAME]>;
|
|
769
|
+
providerExecuted?: boolean;
|
|
770
|
+
providerMetadata?: ProviderMetadata;
|
|
771
|
+
dynamic?: false | undefined;
|
|
772
|
+
preliminary?: boolean;
|
|
773
|
+
title?: string;
|
|
774
|
+
};
|
|
775
|
+
}>;
|
|
776
|
+
type DynamicToolResult = {
|
|
777
|
+
type: 'tool-result';
|
|
778
|
+
toolCallId: string;
|
|
779
|
+
toolName: string;
|
|
780
|
+
input: unknown;
|
|
781
|
+
output: unknown;
|
|
782
|
+
providerExecuted?: boolean;
|
|
783
|
+
providerMetadata?: ProviderMetadata;
|
|
784
|
+
dynamic: true;
|
|
785
|
+
preliminary?: boolean;
|
|
786
|
+
title?: string;
|
|
787
|
+
};
|
|
788
|
+
type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
|
|
789
|
+
|
|
790
|
+
type ContentPart<TOOLS extends ToolSet> = {
|
|
791
|
+
type: 'text';
|
|
792
|
+
text: string;
|
|
793
|
+
providerMetadata?: ProviderMetadata;
|
|
794
|
+
} | ReasoningOutput | ({
|
|
795
|
+
type: 'source';
|
|
796
|
+
} & Source) | {
|
|
797
|
+
type: 'file';
|
|
798
|
+
file: GeneratedFile;
|
|
799
|
+
providerMetadata?: ProviderMetadata;
|
|
800
|
+
} | ({
|
|
801
|
+
type: 'tool-call';
|
|
802
|
+
} & TypedToolCall<TOOLS> & {
|
|
803
|
+
providerMetadata?: ProviderMetadata;
|
|
804
|
+
}) | ({
|
|
805
|
+
type: 'tool-result';
|
|
806
|
+
} & TypedToolResult<TOOLS> & {
|
|
807
|
+
providerMetadata?: ProviderMetadata;
|
|
808
|
+
}) | ({
|
|
809
|
+
type: 'tool-error';
|
|
810
|
+
} & TypedToolError<TOOLS> & {
|
|
811
|
+
providerMetadata?: ProviderMetadata;
|
|
812
|
+
}) | ToolApprovalRequestOutput<TOOLS>;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* A message that was generated during the generation process.
|
|
816
|
+
* It can be either an assistant message or a tool message.
|
|
817
|
+
*/
|
|
818
|
+
type ResponseMessage = AssistantModelMessage | ToolModelMessage;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* The result of a single step in the generation process.
|
|
822
|
+
*/
|
|
823
|
+
type StepResult<TOOLS extends ToolSet> = {
|
|
824
|
+
/**
|
|
825
|
+
* Zero-based index of this step.
|
|
826
|
+
*/
|
|
827
|
+
readonly stepNumber: number;
|
|
828
|
+
/**
|
|
829
|
+
* Information about the model that produced this step.
|
|
830
|
+
*/
|
|
831
|
+
readonly model: {
|
|
832
|
+
/** The provider of the model. */
|
|
833
|
+
readonly provider: string;
|
|
834
|
+
/** The ID of the model. */
|
|
835
|
+
readonly modelId: string;
|
|
836
|
+
};
|
|
837
|
+
/**
|
|
838
|
+
* Identifier from telemetry settings for grouping related operations.
|
|
839
|
+
*/
|
|
840
|
+
readonly functionId: string | undefined;
|
|
841
|
+
/**
|
|
842
|
+
* Additional metadata from telemetry settings.
|
|
843
|
+
*/
|
|
844
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
845
|
+
/**
|
|
846
|
+
* User-defined context object flowing through the generation.
|
|
847
|
+
*
|
|
848
|
+
* Experimental (can break in patch releases).
|
|
849
|
+
*/
|
|
850
|
+
readonly experimental_context: unknown;
|
|
851
|
+
/**
|
|
852
|
+
* The content that was generated in the last step.
|
|
853
|
+
*/
|
|
854
|
+
readonly content: Array<ContentPart<TOOLS>>;
|
|
855
|
+
/**
|
|
856
|
+
* The generated text.
|
|
857
|
+
*/
|
|
858
|
+
readonly text: string;
|
|
859
|
+
/**
|
|
860
|
+
* The reasoning that was generated during the generation.
|
|
861
|
+
*/
|
|
862
|
+
readonly reasoning: Array<ReasoningPart>;
|
|
863
|
+
/**
|
|
864
|
+
* The reasoning text that was generated during the generation.
|
|
865
|
+
*/
|
|
866
|
+
readonly reasoningText: string | undefined;
|
|
867
|
+
/**
|
|
868
|
+
* The files that were generated during the generation.
|
|
869
|
+
*/
|
|
870
|
+
readonly files: Array<GeneratedFile>;
|
|
871
|
+
/**
|
|
872
|
+
* The sources that were used to generate the text.
|
|
873
|
+
*/
|
|
874
|
+
readonly sources: Array<Source>;
|
|
875
|
+
/**
|
|
876
|
+
* The tool calls that were made during the generation.
|
|
877
|
+
*/
|
|
878
|
+
readonly toolCalls: Array<TypedToolCall<TOOLS>>;
|
|
879
|
+
/**
|
|
880
|
+
* The static tool calls that were made in the last step.
|
|
881
|
+
*/
|
|
882
|
+
readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
|
|
883
|
+
/**
|
|
884
|
+
* The dynamic tool calls that were made in the last step.
|
|
885
|
+
*/
|
|
886
|
+
readonly dynamicToolCalls: Array<DynamicToolCall>;
|
|
887
|
+
/**
|
|
888
|
+
* The results of the tool calls.
|
|
889
|
+
*/
|
|
890
|
+
readonly toolResults: Array<TypedToolResult<TOOLS>>;
|
|
891
|
+
/**
|
|
892
|
+
* The static tool results that were made in the last step.
|
|
893
|
+
*/
|
|
894
|
+
readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
|
|
895
|
+
/**
|
|
896
|
+
* The dynamic tool results that were made in the last step.
|
|
897
|
+
*/
|
|
898
|
+
readonly dynamicToolResults: Array<DynamicToolResult>;
|
|
899
|
+
/**
|
|
900
|
+
* The unified reason why the generation finished.
|
|
901
|
+
*/
|
|
902
|
+
readonly finishReason: FinishReason;
|
|
903
|
+
/**
|
|
904
|
+
* The raw reason why the generation finished (from the provider).
|
|
905
|
+
*/
|
|
906
|
+
readonly rawFinishReason: string | undefined;
|
|
803
907
|
/**
|
|
804
908
|
* The token usage of the generated text.
|
|
805
909
|
*/
|
|
@@ -835,6 +939,84 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
|
835
939
|
readonly providerMetadata: ProviderMetadata | undefined;
|
|
836
940
|
};
|
|
837
941
|
|
|
942
|
+
/**
|
|
943
|
+
* Function that you can use to provide different settings for a step.
|
|
944
|
+
*
|
|
945
|
+
* @param options - The options for the step.
|
|
946
|
+
* @param options.steps - The steps that have been executed so far.
|
|
947
|
+
* @param options.stepNumber - The number of the step that is being executed.
|
|
948
|
+
* @param options.model - The model that is being used.
|
|
949
|
+
* @param options.messages - The messages that will be sent to the model for the current step.
|
|
950
|
+
* @param options.experimental_context - The context passed via the experimental_context setting (experimental).
|
|
951
|
+
*
|
|
952
|
+
* @returns An object that contains the settings for the step.
|
|
953
|
+
* If you return undefined (or for undefined settings), the settings from the outer level will be used.
|
|
954
|
+
*/
|
|
955
|
+
type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Tool>> = (options: {
|
|
956
|
+
/**
|
|
957
|
+
* The steps that have been executed so far.
|
|
958
|
+
*/
|
|
959
|
+
steps: Array<StepResult<NoInfer<TOOLS>>>;
|
|
960
|
+
/**
|
|
961
|
+
* The number of the step that is being executed.
|
|
962
|
+
*/
|
|
963
|
+
stepNumber: number;
|
|
964
|
+
/**
|
|
965
|
+
* The model instance that is being used for this step.
|
|
966
|
+
*/
|
|
967
|
+
model: LanguageModel;
|
|
968
|
+
/**
|
|
969
|
+
* The messages that will be sent to the model for the current step.
|
|
970
|
+
*/
|
|
971
|
+
messages: Array<ModelMessage>;
|
|
972
|
+
/**
|
|
973
|
+
* The context passed via the experimental_context setting (experimental).
|
|
974
|
+
*/
|
|
975
|
+
experimental_context: unknown;
|
|
976
|
+
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
|
|
977
|
+
/**
|
|
978
|
+
* The result type returned by a {@link PrepareStepFunction},
|
|
979
|
+
* allowing per-step overrides of model, tools, or messages.
|
|
980
|
+
*/
|
|
981
|
+
type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
|
|
982
|
+
/**
|
|
983
|
+
* Optionally override which LanguageModel instance is used for this step.
|
|
984
|
+
*/
|
|
985
|
+
model?: LanguageModel;
|
|
986
|
+
/**
|
|
987
|
+
* Optionally set which tool the model must call, or provide tool call configuration
|
|
988
|
+
* for this step.
|
|
989
|
+
*/
|
|
990
|
+
toolChoice?: ToolChoice<NoInfer<TOOLS>>;
|
|
991
|
+
/**
|
|
992
|
+
* If provided, only these tools are enabled/available for this step.
|
|
993
|
+
*/
|
|
994
|
+
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
|
995
|
+
/**
|
|
996
|
+
* Optionally override the system message(s) sent to the model for this step.
|
|
997
|
+
*/
|
|
998
|
+
system?: string | SystemModelMessage | Array<SystemModelMessage>;
|
|
999
|
+
/**
|
|
1000
|
+
* Optionally override the full set of messages sent to the model
|
|
1001
|
+
* for this step.
|
|
1002
|
+
*/
|
|
1003
|
+
messages?: Array<ModelMessage>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Context that is passed into tool execution. Experimental.
|
|
1006
|
+
*
|
|
1007
|
+
* Changing the context will affect the context in this step
|
|
1008
|
+
* and all subsequent steps.
|
|
1009
|
+
*/
|
|
1010
|
+
experimental_context?: unknown;
|
|
1011
|
+
/**
|
|
1012
|
+
* Additional provider-specific options for this step.
|
|
1013
|
+
*
|
|
1014
|
+
* Can be used to pass provider-specific configuration such as
|
|
1015
|
+
* container IDs for Anthropic's code execution.
|
|
1016
|
+
*/
|
|
1017
|
+
providerOptions?: ProviderOptions;
|
|
1018
|
+
} | undefined;
|
|
1019
|
+
|
|
838
1020
|
type StopCondition<TOOLS extends ToolSet> = (options: {
|
|
839
1021
|
steps: Array<StepResult<TOOLS>>;
|
|
840
1022
|
}) => PromiseLike<boolean> | boolean;
|
|
@@ -843,406 +1025,140 @@ declare function isLoopFinished(): StopCondition<any>;
|
|
|
843
1025
|
declare function hasToolCall(toolName: string): StopCondition<any>;
|
|
844
1026
|
|
|
845
1027
|
/**
|
|
846
|
-
*
|
|
1028
|
+
* Infers the complete output type from the output specification.
|
|
847
1029
|
*/
|
|
848
|
-
|
|
849
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
850
|
-
readonly provider: string;
|
|
851
|
-
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
852
|
-
readonly modelId: string;
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Event passed to the `onStart` callback.
|
|
856
|
-
*
|
|
857
|
-
* Called when the generation operation begins, before any LLM calls.
|
|
858
|
-
*/
|
|
859
|
-
interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output, INCLUDE = {
|
|
860
|
-
requestBody?: boolean;
|
|
861
|
-
responseBody?: boolean;
|
|
862
|
-
}> {
|
|
863
|
-
/** The model being used for generation. */
|
|
864
|
-
readonly model: CallbackModelInfo;
|
|
865
|
-
/** The system message(s) provided to the model. */
|
|
866
|
-
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
867
|
-
/** The prompt string or array of messages if using the prompt option. */
|
|
868
|
-
readonly prompt: string | Array<ModelMessage> | undefined;
|
|
869
|
-
/** The messages array if using the messages option. */
|
|
870
|
-
readonly messages: Array<ModelMessage> | undefined;
|
|
871
|
-
/** The tools available for this generation. */
|
|
872
|
-
readonly tools: TOOLS | undefined;
|
|
873
|
-
/** The tool choice strategy for this generation. */
|
|
874
|
-
readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
|
|
875
|
-
/** Limits which tools are available for the model to call. */
|
|
876
|
-
readonly activeTools: Array<keyof TOOLS> | undefined;
|
|
877
|
-
/** Maximum number of tokens to generate. */
|
|
878
|
-
readonly maxOutputTokens: number | undefined;
|
|
879
|
-
/** Sampling temperature for generation. */
|
|
880
|
-
readonly temperature: number | undefined;
|
|
881
|
-
/** Top-p (nucleus) sampling parameter. */
|
|
882
|
-
readonly topP: number | undefined;
|
|
883
|
-
/** Top-k sampling parameter. */
|
|
884
|
-
readonly topK: number | undefined;
|
|
885
|
-
/** Presence penalty for generation. */
|
|
886
|
-
readonly presencePenalty: number | undefined;
|
|
887
|
-
/** Frequency penalty for generation. */
|
|
888
|
-
readonly frequencyPenalty: number | undefined;
|
|
889
|
-
/** Sequences that will stop generation. */
|
|
890
|
-
readonly stopSequences: string[] | undefined;
|
|
891
|
-
/** Random seed for reproducible generation. */
|
|
892
|
-
readonly seed: number | undefined;
|
|
893
|
-
/** Maximum number of retries for failed requests. */
|
|
894
|
-
readonly maxRetries: number;
|
|
895
|
-
/**
|
|
896
|
-
* Timeout configuration for the generation.
|
|
897
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
898
|
-
*/
|
|
899
|
-
readonly timeout: TimeoutConfiguration | undefined;
|
|
900
|
-
/** Additional HTTP headers sent with the request. */
|
|
901
|
-
readonly headers: Record<string, string | undefined> | undefined;
|
|
902
|
-
/** Additional provider-specific options. */
|
|
903
|
-
readonly providerOptions: ProviderOptions | undefined;
|
|
904
|
-
/**
|
|
905
|
-
* Condition(s) for stopping the generation.
|
|
906
|
-
* When the condition is an array, any of the conditions can be met to stop.
|
|
907
|
-
*/
|
|
908
|
-
readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
|
|
909
|
-
/** The output specification for structured outputs, if configured. */
|
|
910
|
-
readonly output: OUTPUT | undefined;
|
|
911
|
-
/** Abort signal for cancelling the operation. */
|
|
912
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
913
|
-
/**
|
|
914
|
-
* Settings for controlling what data is included in step results.
|
|
915
|
-
*/
|
|
916
|
-
readonly include: INCLUDE | undefined;
|
|
917
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
918
|
-
readonly functionId: string | undefined;
|
|
919
|
-
/** Additional metadata passed to the generation. */
|
|
920
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
921
|
-
/**
|
|
922
|
-
* User-defined context object that flows through the entire generation lifecycle.
|
|
923
|
-
* Can be accessed and modified in `prepareStep` and tool `execute` functions.
|
|
924
|
-
*/
|
|
925
|
-
readonly experimental_context: unknown;
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* Event passed to the `onStepStart` callback.
|
|
929
|
-
*
|
|
930
|
-
* Called when a step (LLM call) begins, before the provider is called.
|
|
931
|
-
* Each step represents a single LLM invocation.
|
|
932
|
-
*/
|
|
933
|
-
interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output, INCLUDE = {
|
|
934
|
-
requestBody?: boolean;
|
|
935
|
-
responseBody?: boolean;
|
|
936
|
-
}> {
|
|
937
|
-
/** Zero-based index of the current step. */
|
|
938
|
-
readonly stepNumber: number;
|
|
939
|
-
/** The model being used for this step. */
|
|
940
|
-
readonly model: CallbackModelInfo;
|
|
941
|
-
/**
|
|
942
|
-
* The system message for this step.
|
|
943
|
-
*/
|
|
944
|
-
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
945
|
-
/**
|
|
946
|
-
* The messages that will be sent to the model for this step.
|
|
947
|
-
* Uses the user-facing `ModelMessage` format.
|
|
948
|
-
* May be overridden by prepareStep.
|
|
949
|
-
*/
|
|
950
|
-
readonly messages: Array<ModelMessage>;
|
|
951
|
-
/** The tools available for this generation. */
|
|
952
|
-
readonly tools: TOOLS | undefined;
|
|
953
|
-
/** The tool choice configuration for this step. */
|
|
954
|
-
readonly toolChoice: LanguageModelV3ToolChoice | undefined;
|
|
955
|
-
/** Limits which tools are available for this step. */
|
|
956
|
-
readonly activeTools: Array<keyof TOOLS> | undefined;
|
|
957
|
-
/** Array of results from previous steps (empty for first step). */
|
|
958
|
-
readonly steps: ReadonlyArray<StepResult<TOOLS>>;
|
|
959
|
-
/** Additional provider-specific options for this step. */
|
|
960
|
-
readonly providerOptions: ProviderOptions | undefined;
|
|
961
|
-
/**
|
|
962
|
-
* Timeout configuration for the generation.
|
|
963
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
964
|
-
*/
|
|
965
|
-
readonly timeout: TimeoutConfiguration | undefined;
|
|
966
|
-
/** Additional HTTP headers sent with the request. */
|
|
967
|
-
readonly headers: Record<string, string | undefined> | undefined;
|
|
968
|
-
/**
|
|
969
|
-
* Condition(s) for stopping the generation.
|
|
970
|
-
* When the condition is an array, any of the conditions can be met to stop.
|
|
971
|
-
*/
|
|
972
|
-
readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
|
|
973
|
-
/** The output specification for structured outputs, if configured. */
|
|
974
|
-
readonly output: OUTPUT | undefined;
|
|
975
|
-
/** Abort signal for cancelling the operation. */
|
|
976
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
977
|
-
/**
|
|
978
|
-
* Settings for controlling what data is included in step results.
|
|
979
|
-
*/
|
|
980
|
-
readonly include: INCLUDE | undefined;
|
|
981
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
982
|
-
readonly functionId: string | undefined;
|
|
983
|
-
/** Additional metadata from telemetry settings. */
|
|
984
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
985
|
-
/**
|
|
986
|
-
* User-defined context object. May be updated from `prepareStep` between steps.
|
|
987
|
-
*/
|
|
988
|
-
readonly experimental_context: unknown;
|
|
989
|
-
}
|
|
990
|
-
/**
|
|
991
|
-
* Event passed to the `onToolCallStart` callback.
|
|
992
|
-
*
|
|
993
|
-
* Called when a tool execution begins, before the tool's `execute` function is invoked.
|
|
994
|
-
*/
|
|
995
|
-
interface OnToolCallStartEvent<TOOLS extends ToolSet = ToolSet> {
|
|
996
|
-
/** Zero-based index of the current step where this tool call occurs. */
|
|
997
|
-
readonly stepNumber: number | undefined;
|
|
998
|
-
/** The model being used for this step. */
|
|
999
|
-
readonly model: CallbackModelInfo | undefined;
|
|
1000
|
-
/** The full tool call object. */
|
|
1001
|
-
readonly toolCall: TypedToolCall<TOOLS>;
|
|
1002
|
-
/** The conversation messages available at tool execution time. */
|
|
1003
|
-
readonly messages: Array<ModelMessage>;
|
|
1004
|
-
/** Signal for cancelling the operation. */
|
|
1005
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
1006
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
1007
|
-
readonly functionId: string | undefined;
|
|
1008
|
-
/** Additional metadata from telemetry settings. */
|
|
1009
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
1010
|
-
/** User-defined context object flowing through the generation. */
|
|
1011
|
-
readonly experimental_context: unknown;
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Event passed to the `onToolCallFinish` callback.
|
|
1015
|
-
*
|
|
1016
|
-
* Called when a tool execution completes, either successfully or with an error.
|
|
1017
|
-
* Uses a discriminated union on the `success` field.
|
|
1018
|
-
*/
|
|
1019
|
-
type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = {
|
|
1020
|
-
/** Zero-based index of the current step where this tool call occurred. */
|
|
1021
|
-
readonly stepNumber: number | undefined;
|
|
1022
|
-
/** The model being used for this step. */
|
|
1023
|
-
readonly model: CallbackModelInfo | undefined;
|
|
1024
|
-
/** The full tool call object. */
|
|
1025
|
-
readonly toolCall: TypedToolCall<TOOLS>;
|
|
1026
|
-
/** The conversation messages available at tool execution time. */
|
|
1027
|
-
readonly messages: Array<ModelMessage>;
|
|
1028
|
-
/** Signal for cancelling the operation. */
|
|
1029
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
1030
|
-
/** Execution time of the tool call in milliseconds. */
|
|
1031
|
-
readonly durationMs: number;
|
|
1032
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
1033
|
-
readonly functionId: string | undefined;
|
|
1034
|
-
/** Additional metadata from telemetry settings. */
|
|
1035
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
1036
|
-
/** User-defined context object flowing through the generation. */
|
|
1037
|
-
readonly experimental_context: unknown;
|
|
1038
|
-
} & ({
|
|
1039
|
-
/** Indicates the tool call succeeded. */
|
|
1040
|
-
readonly success: true;
|
|
1041
|
-
/** The tool's return value. */
|
|
1042
|
-
readonly output: unknown;
|
|
1043
|
-
readonly error?: never;
|
|
1044
|
-
} | {
|
|
1045
|
-
/** Indicates the tool call failed. */
|
|
1046
|
-
readonly success: false;
|
|
1047
|
-
readonly output?: never;
|
|
1048
|
-
/** The error that occurred during tool execution. */
|
|
1049
|
-
readonly error: unknown;
|
|
1050
|
-
});
|
|
1051
|
-
/**
|
|
1052
|
-
* Event passed to the `onStepFinish` callback.
|
|
1053
|
-
*
|
|
1054
|
-
* Called when a step (LLM call) completes.
|
|
1055
|
-
* This is simply the StepResult for that step.
|
|
1056
|
-
*/
|
|
1057
|
-
type OnStepFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS>;
|
|
1058
|
-
/**
|
|
1059
|
-
* Event passed to the `onFinish` callback.
|
|
1060
|
-
*
|
|
1061
|
-
* Called when the entire generation completes (all steps finished).
|
|
1062
|
-
* Includes the final step's result along with aggregated data from all steps.
|
|
1063
|
-
*/
|
|
1064
|
-
type OnFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS> & {
|
|
1065
|
-
/** Array containing results from all steps in the generation. */
|
|
1066
|
-
readonly steps: StepResult<TOOLS>[];
|
|
1067
|
-
/** Aggregated token usage across all steps. */
|
|
1068
|
-
readonly totalUsage: LanguageModelUsage;
|
|
1069
|
-
/**
|
|
1070
|
-
* The final state of the user-defined context object.
|
|
1071
|
-
*
|
|
1072
|
-
* Experimental (can break in patch releases).
|
|
1073
|
-
*
|
|
1074
|
-
* @default undefined
|
|
1075
|
-
*/
|
|
1076
|
-
experimental_context: unknown;
|
|
1077
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
1078
|
-
readonly functionId: string | undefined;
|
|
1079
|
-
/** Additional metadata from telemetry settings. */
|
|
1080
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1030
|
+
type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
|
|
1083
1031
|
/**
|
|
1084
|
-
*
|
|
1032
|
+
* Infers the partial output type from the output specification.
|
|
1085
1033
|
*/
|
|
1086
|
-
type
|
|
1087
|
-
|
|
1034
|
+
type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT, any> ? PARTIAL_OUTPUT : never;
|
|
1088
1035
|
/**
|
|
1089
|
-
*
|
|
1090
|
-
* Methods can be sync or return a PromiseLike.
|
|
1036
|
+
* Infers the element type from an array output specification.
|
|
1091
1037
|
*/
|
|
1092
|
-
|
|
1093
|
-
onStart?: Listener<OnStartEvent<ToolSet, Output>>;
|
|
1094
|
-
onStepStart?: Listener<OnStepStartEvent<ToolSet, Output>>;
|
|
1095
|
-
onToolCallStart?: Listener<OnToolCallStartEvent<ToolSet>>;
|
|
1096
|
-
onToolCallFinish?: Listener<OnToolCallFinishEvent<ToolSet>>;
|
|
1097
|
-
onStepFinish?: Listener<OnStepFinishEvent<ToolSet>>;
|
|
1098
|
-
onFinish?: Listener<OnFinishEvent<ToolSet>>;
|
|
1099
|
-
}
|
|
1038
|
+
type InferElementOutput<OUTPUT extends Output> = OUTPUT extends Output<any, any, infer ELEMENT> ? ELEMENT : never;
|
|
1100
1039
|
|
|
1101
1040
|
/**
|
|
1102
|
-
*
|
|
1041
|
+
* The result of a `generateText` call.
|
|
1042
|
+
* It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
|
1103
1043
|
*/
|
|
1104
|
-
|
|
1044
|
+
interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
1105
1045
|
/**
|
|
1106
|
-
*
|
|
1046
|
+
* The content that was generated in the last step.
|
|
1107
1047
|
*/
|
|
1108
|
-
|
|
1048
|
+
readonly content: Array<ContentPart<TOOLS>>;
|
|
1109
1049
|
/**
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
* You might want to disable input recording to avoid recording sensitive
|
|
1113
|
-
* information, to reduce data transfers, or to increase performance.
|
|
1050
|
+
* The text that was generated in the last step.
|
|
1114
1051
|
*/
|
|
1115
|
-
|
|
1052
|
+
readonly text: string;
|
|
1116
1053
|
/**
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
* You might want to disable output recording to avoid recording sensitive
|
|
1120
|
-
* information, to reduce data transfers, or to increase performance.
|
|
1054
|
+
* The full reasoning that the model has generated in the last step.
|
|
1121
1055
|
*/
|
|
1122
|
-
|
|
1056
|
+
readonly reasoning: Array<ReasoningOutput>;
|
|
1123
1057
|
/**
|
|
1124
|
-
*
|
|
1058
|
+
* The reasoning text that the model has generated in the last step. Can be undefined if the model
|
|
1059
|
+
* has only generated text.
|
|
1125
1060
|
*/
|
|
1126
|
-
|
|
1061
|
+
readonly reasoningText: string | undefined;
|
|
1127
1062
|
/**
|
|
1128
|
-
*
|
|
1063
|
+
* The files that were generated in the last step.
|
|
1064
|
+
* Empty array if no files were generated.
|
|
1129
1065
|
*/
|
|
1130
|
-
|
|
1066
|
+
readonly files: Array<GeneratedFile>;
|
|
1131
1067
|
/**
|
|
1132
|
-
*
|
|
1068
|
+
* Sources that have been used as references in the last step.
|
|
1133
1069
|
*/
|
|
1134
|
-
|
|
1070
|
+
readonly sources: Array<Source>;
|
|
1135
1071
|
/**
|
|
1136
|
-
*
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
* (see `registerTelemetryIntegration`).
|
|
1140
|
-
*/
|
|
1141
|
-
integrations?: TelemetryIntegration | TelemetryIntegration[];
|
|
1142
|
-
};
|
|
1143
|
-
|
|
1144
|
-
/**
|
|
1145
|
-
* Experimental. Can change in patch versions without warning.
|
|
1146
|
-
*
|
|
1147
|
-
* Download function. Called with the array of URLs and a boolean indicating
|
|
1148
|
-
* whether the URL is supported by the model.
|
|
1149
|
-
*
|
|
1150
|
-
* The download function can decide for each URL:
|
|
1151
|
-
* - to return null (which means that the URL should be passed to the model)
|
|
1152
|
-
* - to download the asset and return the data (incl. retries, authentication, etc.)
|
|
1153
|
-
*
|
|
1154
|
-
* Should throw DownloadError if the download fails.
|
|
1155
|
-
*
|
|
1156
|
-
* Should return an array of objects sorted by the order of the requested downloads.
|
|
1157
|
-
* For each object, the data should be a Uint8Array if the URL was downloaded.
|
|
1158
|
-
* For each object, the mediaType should be the media type of the downloaded asset.
|
|
1159
|
-
* For each object, the data should be null if the URL should be passed through as is.
|
|
1160
|
-
*/
|
|
1161
|
-
type DownloadFunction = (options: Array<{
|
|
1162
|
-
url: URL;
|
|
1163
|
-
isUrlSupportedByModel: boolean;
|
|
1164
|
-
}>) => PromiseLike<Array<{
|
|
1165
|
-
data: Uint8Array;
|
|
1166
|
-
mediaType: string | undefined;
|
|
1167
|
-
} | null>>;
|
|
1168
|
-
|
|
1169
|
-
/**
|
|
1170
|
-
* Function that you can use to provide different settings for a step.
|
|
1171
|
-
*
|
|
1172
|
-
* @param options - The options for the step.
|
|
1173
|
-
* @param options.steps - The steps that have been executed so far.
|
|
1174
|
-
* @param options.stepNumber - The number of the step that is being executed.
|
|
1175
|
-
* @param options.model - The model that is being used.
|
|
1176
|
-
* @param options.messages - The messages that will be sent to the model for the current step.
|
|
1177
|
-
* @param options.experimental_context - The context passed via the experimental_context setting (experimental).
|
|
1178
|
-
*
|
|
1179
|
-
* @returns An object that contains the settings for the step.
|
|
1180
|
-
* If you return undefined (or for undefined settings), the settings from the outer level will be used.
|
|
1181
|
-
*/
|
|
1182
|
-
type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Tool>> = (options: {
|
|
1072
|
+
* The tool calls that were made in the last step.
|
|
1073
|
+
*/
|
|
1074
|
+
readonly toolCalls: Array<TypedToolCall<TOOLS>>;
|
|
1183
1075
|
/**
|
|
1184
|
-
* The
|
|
1076
|
+
* The static tool calls that were made in the last step.
|
|
1185
1077
|
*/
|
|
1186
|
-
|
|
1078
|
+
readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
|
|
1187
1079
|
/**
|
|
1188
|
-
* The
|
|
1080
|
+
* The dynamic tool calls that were made in the last step.
|
|
1189
1081
|
*/
|
|
1190
|
-
|
|
1082
|
+
readonly dynamicToolCalls: Array<DynamicToolCall>;
|
|
1191
1083
|
/**
|
|
1192
|
-
* The
|
|
1084
|
+
* The results of the tool calls from the last step.
|
|
1193
1085
|
*/
|
|
1194
|
-
|
|
1086
|
+
readonly toolResults: Array<TypedToolResult<TOOLS>>;
|
|
1195
1087
|
/**
|
|
1196
|
-
* The
|
|
1088
|
+
* The static tool results that were made in the last step.
|
|
1197
1089
|
*/
|
|
1198
|
-
|
|
1090
|
+
readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
|
|
1199
1091
|
/**
|
|
1200
|
-
* The
|
|
1092
|
+
* The dynamic tool results that were made in the last step.
|
|
1201
1093
|
*/
|
|
1202
|
-
|
|
1203
|
-
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
|
|
1204
|
-
/**
|
|
1205
|
-
* The result type returned by a {@link PrepareStepFunction},
|
|
1206
|
-
* allowing per-step overrides of model, tools, or messages.
|
|
1207
|
-
*/
|
|
1208
|
-
type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
|
|
1094
|
+
readonly dynamicToolResults: Array<DynamicToolResult>;
|
|
1209
1095
|
/**
|
|
1210
|
-
*
|
|
1096
|
+
* The unified reason why the generation finished.
|
|
1211
1097
|
*/
|
|
1212
|
-
|
|
1098
|
+
readonly finishReason: FinishReason;
|
|
1213
1099
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
* for this step.
|
|
1100
|
+
* The raw reason why the generation finished (from the provider).
|
|
1216
1101
|
*/
|
|
1217
|
-
|
|
1102
|
+
readonly rawFinishReason: string | undefined;
|
|
1218
1103
|
/**
|
|
1219
|
-
*
|
|
1104
|
+
* The token usage of the last step.
|
|
1220
1105
|
*/
|
|
1221
|
-
|
|
1106
|
+
readonly usage: LanguageModelUsage;
|
|
1222
1107
|
/**
|
|
1223
|
-
*
|
|
1108
|
+
* The total token usage of all steps.
|
|
1109
|
+
* When there are multiple steps, the usage is the sum of all step usages.
|
|
1224
1110
|
*/
|
|
1225
|
-
|
|
1111
|
+
readonly totalUsage: LanguageModelUsage;
|
|
1226
1112
|
/**
|
|
1227
|
-
*
|
|
1228
|
-
* for this step.
|
|
1113
|
+
* Warnings from the model provider (e.g. unsupported settings)
|
|
1229
1114
|
*/
|
|
1230
|
-
|
|
1115
|
+
readonly warnings: CallWarning[] | undefined;
|
|
1231
1116
|
/**
|
|
1232
|
-
*
|
|
1117
|
+
* Additional request information.
|
|
1118
|
+
*/
|
|
1119
|
+
readonly request: LanguageModelRequestMetadata;
|
|
1120
|
+
/**
|
|
1121
|
+
* Additional response information.
|
|
1122
|
+
*/
|
|
1123
|
+
readonly response: LanguageModelResponseMetadata & {
|
|
1124
|
+
/**
|
|
1125
|
+
* The response messages that were generated during the call. It consists of an assistant message,
|
|
1126
|
+
* potentially containing tool calls.
|
|
1127
|
+
*
|
|
1128
|
+
* When there are tool results, there is an additional tool message with the tool results that are available.
|
|
1129
|
+
* If there are tools that do not have execute functions, they are not included in the tool results and
|
|
1130
|
+
* need to be added separately.
|
|
1131
|
+
*/
|
|
1132
|
+
messages: Array<ResponseMessage>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Response body (available only for providers that use HTTP requests).
|
|
1135
|
+
*/
|
|
1136
|
+
body?: unknown;
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* Additional provider-specific metadata. They are passed through
|
|
1140
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
1141
|
+
* results that can be fully encapsulated in the provider.
|
|
1142
|
+
*/
|
|
1143
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
|
1144
|
+
/**
|
|
1145
|
+
* Details for all steps.
|
|
1146
|
+
* You can use this to get information about intermediate steps,
|
|
1147
|
+
* such as the tool calls or the response headers.
|
|
1148
|
+
*/
|
|
1149
|
+
readonly steps: Array<StepResult<TOOLS>>;
|
|
1150
|
+
/**
|
|
1151
|
+
* The generated structured output. It uses the `output` specification.
|
|
1233
1152
|
*
|
|
1234
|
-
*
|
|
1235
|
-
* and all subsequent steps.
|
|
1153
|
+
* @deprecated Use `output` instead.
|
|
1236
1154
|
*/
|
|
1237
|
-
|
|
1155
|
+
readonly experimental_output: InferCompleteOutput<OUTPUT>;
|
|
1238
1156
|
/**
|
|
1239
|
-
*
|
|
1157
|
+
* The generated structured output. It uses the `output` specification.
|
|
1240
1158
|
*
|
|
1241
|
-
* Can be used to pass provider-specific configuration such as
|
|
1242
|
-
* container IDs for Anthropic's code execution.
|
|
1243
1159
|
*/
|
|
1244
|
-
|
|
1245
|
-
}
|
|
1160
|
+
readonly output: InferCompleteOutput<OUTPUT>;
|
|
1161
|
+
}
|
|
1246
1162
|
|
|
1247
1163
|
declare const symbol$j: unique symbol;
|
|
1248
1164
|
declare class InvalidToolInputError extends AISDKError {
|
|
@@ -1382,6 +1298,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent
|
|
|
1382
1298
|
* @param system - A system message that will be part of the prompt.
|
|
1383
1299
|
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
1384
1300
|
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
1301
|
+
* @param allowSystemInMessages - Whether system messages are allowed in the `prompt` or `messages` fields. When unset, system messages are allowed with a warning.
|
|
1385
1302
|
*
|
|
1386
1303
|
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
1387
1304
|
* @param temperature - Temperature setting.
|
|
@@ -1423,7 +1340,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent
|
|
|
1423
1340
|
* @returns
|
|
1424
1341
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1425
1342
|
*/
|
|
1426
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1343
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1427
1344
|
/**
|
|
1428
1345
|
* The language model to use.
|
|
1429
1346
|
*/
|
|
@@ -1552,19 +1469,6 @@ declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Out
|
|
|
1552
1469
|
};
|
|
1553
1470
|
}): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
1554
1471
|
|
|
1555
|
-
/**
|
|
1556
|
-
* Infers the complete output type from the output specification.
|
|
1557
|
-
*/
|
|
1558
|
-
type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
|
|
1559
|
-
/**
|
|
1560
|
-
* Infers the partial output type from the output specification.
|
|
1561
|
-
*/
|
|
1562
|
-
type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT, any> ? PARTIAL_OUTPUT : never;
|
|
1563
|
-
/**
|
|
1564
|
-
* Infers the element type from an array output specification.
|
|
1565
|
-
*/
|
|
1566
|
-
type InferElementOutput<OUTPUT extends Output> = OUTPUT extends Output<any, any, infer ELEMENT> ? ELEMENT : never;
|
|
1567
|
-
|
|
1568
1472
|
/**
|
|
1569
1473
|
* Prunes model messages from a list of model messages.
|
|
1570
1474
|
*
|
|
@@ -2774,6 +2678,7 @@ type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (even
|
|
|
2774
2678
|
* @param system - A system message that will be part of the prompt.
|
|
2775
2679
|
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
2776
2680
|
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
2681
|
+
* @param allowSystemInMessages - Whether system messages are allowed in the `prompt` or `messages` fields. When unset, system messages are allowed with a warning.
|
|
2777
2682
|
*
|
|
2778
2683
|
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
2779
2684
|
* @param temperature - Temperature setting.
|
|
@@ -2809,7 +2714,7 @@ type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (even
|
|
|
2809
2714
|
* @returns
|
|
2810
2715
|
* A result object for accessing different stream types and additional information.
|
|
2811
2716
|
*/
|
|
2812
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2717
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2813
2718
|
/**
|
|
2814
2719
|
* The language model to use.
|
|
2815
2720
|
*/
|
|
@@ -3118,126 +3023,289 @@ declare namespace output {
|
|
|
3118
3023
|
}
|
|
3119
3024
|
|
|
3120
3025
|
/**
|
|
3121
|
-
*
|
|
3122
|
-
* It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
|
3026
|
+
* Common model information used across callback events.
|
|
3123
3027
|
*/
|
|
3124
|
-
interface
|
|
3125
|
-
/**
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
readonly
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
readonly
|
|
3147
|
-
/**
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
readonly
|
|
3151
|
-
/**
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
readonly
|
|
3155
|
-
/**
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
readonly
|
|
3159
|
-
/**
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
readonly
|
|
3028
|
+
interface CallbackModelInfo {
|
|
3029
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
3030
|
+
readonly provider: string;
|
|
3031
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
3032
|
+
readonly modelId: string;
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* Event passed to the `onStart` callback.
|
|
3036
|
+
*
|
|
3037
|
+
* Called when the generation operation begins, before any LLM calls.
|
|
3038
|
+
*/
|
|
3039
|
+
interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output, INCLUDE = {
|
|
3040
|
+
requestBody?: boolean;
|
|
3041
|
+
responseBody?: boolean;
|
|
3042
|
+
}> {
|
|
3043
|
+
/** The model being used for generation. */
|
|
3044
|
+
readonly model: CallbackModelInfo;
|
|
3045
|
+
/** The system message(s) provided to the model. */
|
|
3046
|
+
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
3047
|
+
/** The prompt string or array of messages if using the prompt option. */
|
|
3048
|
+
readonly prompt: string | Array<ModelMessage> | undefined;
|
|
3049
|
+
/** The messages array if using the messages option. */
|
|
3050
|
+
readonly messages: Array<ModelMessage> | undefined;
|
|
3051
|
+
/** The tools available for this generation. */
|
|
3052
|
+
readonly tools: TOOLS | undefined;
|
|
3053
|
+
/** The tool choice strategy for this generation. */
|
|
3054
|
+
readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
|
|
3055
|
+
/** Limits which tools are available for the model to call. */
|
|
3056
|
+
readonly activeTools: Array<keyof TOOLS> | undefined;
|
|
3057
|
+
/** Maximum number of tokens to generate. */
|
|
3058
|
+
readonly maxOutputTokens: number | undefined;
|
|
3059
|
+
/** Sampling temperature for generation. */
|
|
3060
|
+
readonly temperature: number | undefined;
|
|
3061
|
+
/** Top-p (nucleus) sampling parameter. */
|
|
3062
|
+
readonly topP: number | undefined;
|
|
3063
|
+
/** Top-k sampling parameter. */
|
|
3064
|
+
readonly topK: number | undefined;
|
|
3065
|
+
/** Presence penalty for generation. */
|
|
3066
|
+
readonly presencePenalty: number | undefined;
|
|
3067
|
+
/** Frequency penalty for generation. */
|
|
3068
|
+
readonly frequencyPenalty: number | undefined;
|
|
3069
|
+
/** Sequences that will stop generation. */
|
|
3070
|
+
readonly stopSequences: string[] | undefined;
|
|
3071
|
+
/** Random seed for reproducible generation. */
|
|
3072
|
+
readonly seed: number | undefined;
|
|
3073
|
+
/** Maximum number of retries for failed requests. */
|
|
3074
|
+
readonly maxRetries: number;
|
|
3163
3075
|
/**
|
|
3164
|
-
*
|
|
3076
|
+
* Timeout configuration for the generation.
|
|
3077
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
3165
3078
|
*/
|
|
3166
|
-
readonly
|
|
3079
|
+
readonly timeout: TimeoutConfiguration | undefined;
|
|
3080
|
+
/** Additional HTTP headers sent with the request. */
|
|
3081
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
3082
|
+
/** Additional provider-specific options. */
|
|
3083
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
3167
3084
|
/**
|
|
3168
|
-
*
|
|
3085
|
+
* Condition(s) for stopping the generation.
|
|
3086
|
+
* When the condition is an array, any of the conditions can be met to stop.
|
|
3169
3087
|
*/
|
|
3170
|
-
readonly
|
|
3088
|
+
readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
|
|
3089
|
+
/** The output specification for structured outputs, if configured. */
|
|
3090
|
+
readonly output: OUTPUT | undefined;
|
|
3091
|
+
/** Abort signal for cancelling the operation. */
|
|
3092
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
3171
3093
|
/**
|
|
3172
|
-
*
|
|
3094
|
+
* Settings for controlling what data is included in step results.
|
|
3173
3095
|
*/
|
|
3174
|
-
readonly
|
|
3096
|
+
readonly include: INCLUDE | undefined;
|
|
3097
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3098
|
+
readonly functionId: string | undefined;
|
|
3099
|
+
/** Additional metadata passed to the generation. */
|
|
3100
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3175
3101
|
/**
|
|
3176
|
-
*
|
|
3102
|
+
* User-defined context object that flows through the entire generation lifecycle.
|
|
3103
|
+
* Can be accessed and modified in `prepareStep` and tool `execute` functions.
|
|
3177
3104
|
*/
|
|
3178
|
-
readonly
|
|
3105
|
+
readonly experimental_context: unknown;
|
|
3106
|
+
}
|
|
3107
|
+
/**
|
|
3108
|
+
* Event passed to the `onStepStart` callback.
|
|
3109
|
+
*
|
|
3110
|
+
* Called when a step (LLM call) begins, before the provider is called.
|
|
3111
|
+
* Each step represents a single LLM invocation.
|
|
3112
|
+
*/
|
|
3113
|
+
interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output, INCLUDE = {
|
|
3114
|
+
requestBody?: boolean;
|
|
3115
|
+
responseBody?: boolean;
|
|
3116
|
+
}> {
|
|
3117
|
+
/** Zero-based index of the current step. */
|
|
3118
|
+
readonly stepNumber: number;
|
|
3119
|
+
/** The model being used for this step. */
|
|
3120
|
+
readonly model: CallbackModelInfo;
|
|
3179
3121
|
/**
|
|
3180
|
-
* The
|
|
3122
|
+
* The system message for this step.
|
|
3181
3123
|
*/
|
|
3182
|
-
readonly
|
|
3124
|
+
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
3183
3125
|
/**
|
|
3184
|
-
* The
|
|
3126
|
+
* The messages that will be sent to the model for this step.
|
|
3127
|
+
* Uses the user-facing `ModelMessage` format.
|
|
3128
|
+
* May be overridden by prepareStep.
|
|
3185
3129
|
*/
|
|
3186
|
-
readonly
|
|
3130
|
+
readonly messages: Array<ModelMessage>;
|
|
3131
|
+
/** The tools available for this generation. */
|
|
3132
|
+
readonly tools: TOOLS | undefined;
|
|
3133
|
+
/** The tool choice configuration for this step. */
|
|
3134
|
+
readonly toolChoice: LanguageModelV3ToolChoice | undefined;
|
|
3135
|
+
/** Limits which tools are available for this step. */
|
|
3136
|
+
readonly activeTools: Array<keyof TOOLS> | undefined;
|
|
3137
|
+
/** Array of results from previous steps (empty for first step). */
|
|
3138
|
+
readonly steps: ReadonlyArray<StepResult<TOOLS>>;
|
|
3139
|
+
/** Additional provider-specific options for this step. */
|
|
3140
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
3187
3141
|
/**
|
|
3188
|
-
*
|
|
3189
|
-
*
|
|
3142
|
+
* Timeout configuration for the generation.
|
|
3143
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
3190
3144
|
*/
|
|
3191
|
-
readonly
|
|
3145
|
+
readonly timeout: TimeoutConfiguration | undefined;
|
|
3146
|
+
/** Additional HTTP headers sent with the request. */
|
|
3147
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
3192
3148
|
/**
|
|
3193
|
-
*
|
|
3149
|
+
* Condition(s) for stopping the generation.
|
|
3150
|
+
* When the condition is an array, any of the conditions can be met to stop.
|
|
3194
3151
|
*/
|
|
3195
|
-
readonly
|
|
3152
|
+
readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
|
|
3153
|
+
/** The output specification for structured outputs, if configured. */
|
|
3154
|
+
readonly output: OUTPUT | undefined;
|
|
3155
|
+
/** Abort signal for cancelling the operation. */
|
|
3156
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
3196
3157
|
/**
|
|
3197
|
-
*
|
|
3158
|
+
* Settings for controlling what data is included in step results.
|
|
3198
3159
|
*/
|
|
3199
|
-
readonly
|
|
3160
|
+
readonly include: INCLUDE | undefined;
|
|
3161
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3162
|
+
readonly functionId: string | undefined;
|
|
3163
|
+
/** Additional metadata from telemetry settings. */
|
|
3164
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3200
3165
|
/**
|
|
3201
|
-
*
|
|
3166
|
+
* User-defined context object. May be updated from `prepareStep` between steps.
|
|
3202
3167
|
*/
|
|
3203
|
-
readonly
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3168
|
+
readonly experimental_context: unknown;
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Event passed to the `onToolCallStart` callback.
|
|
3172
|
+
*
|
|
3173
|
+
* Called when a tool execution begins, before the tool's `execute` function is invoked.
|
|
3174
|
+
*/
|
|
3175
|
+
interface OnToolCallStartEvent<TOOLS extends ToolSet = ToolSet> {
|
|
3176
|
+
/** Zero-based index of the current step where this tool call occurs. */
|
|
3177
|
+
readonly stepNumber: number | undefined;
|
|
3178
|
+
/** The model being used for this step. */
|
|
3179
|
+
readonly model: CallbackModelInfo | undefined;
|
|
3180
|
+
/** The full tool call object. */
|
|
3181
|
+
readonly toolCall: TypedToolCall<TOOLS>;
|
|
3182
|
+
/** The conversation messages available at tool execution time. */
|
|
3183
|
+
readonly messages: Array<ModelMessage>;
|
|
3184
|
+
/** Signal for cancelling the operation. */
|
|
3185
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
3186
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3187
|
+
readonly functionId: string | undefined;
|
|
3188
|
+
/** Additional metadata from telemetry settings. */
|
|
3189
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3190
|
+
/** User-defined context object flowing through the generation. */
|
|
3191
|
+
readonly experimental_context: unknown;
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* Event passed to the `onToolCallFinish` callback.
|
|
3195
|
+
*
|
|
3196
|
+
* Called when a tool execution completes, either successfully or with an error.
|
|
3197
|
+
* Uses a discriminated union on the `success` field.
|
|
3198
|
+
*/
|
|
3199
|
+
type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = {
|
|
3200
|
+
/** Zero-based index of the current step where this tool call occurred. */
|
|
3201
|
+
readonly stepNumber: number | undefined;
|
|
3202
|
+
/** The model being used for this step. */
|
|
3203
|
+
readonly model: CallbackModelInfo | undefined;
|
|
3204
|
+
/** The full tool call object. */
|
|
3205
|
+
readonly toolCall: TypedToolCall<TOOLS>;
|
|
3206
|
+
/** The conversation messages available at tool execution time. */
|
|
3207
|
+
readonly messages: Array<ModelMessage>;
|
|
3208
|
+
/** Signal for cancelling the operation. */
|
|
3209
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
3210
|
+
/** Execution time of the tool call in milliseconds. */
|
|
3211
|
+
readonly durationMs: number;
|
|
3212
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3213
|
+
readonly functionId: string | undefined;
|
|
3214
|
+
/** Additional metadata from telemetry settings. */
|
|
3215
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3216
|
+
/** User-defined context object flowing through the generation. */
|
|
3217
|
+
readonly experimental_context: unknown;
|
|
3218
|
+
} & ({
|
|
3219
|
+
/** Indicates the tool call succeeded. */
|
|
3220
|
+
readonly success: true;
|
|
3221
|
+
/** The tool's return value. */
|
|
3222
|
+
readonly output: unknown;
|
|
3223
|
+
readonly error?: never;
|
|
3224
|
+
} | {
|
|
3225
|
+
/** Indicates the tool call failed. */
|
|
3226
|
+
readonly success: false;
|
|
3227
|
+
readonly output?: never;
|
|
3228
|
+
/** The error that occurred during tool execution. */
|
|
3229
|
+
readonly error: unknown;
|
|
3230
|
+
});
|
|
3231
|
+
/**
|
|
3232
|
+
* Event passed to the `onStepFinish` callback.
|
|
3233
|
+
*
|
|
3234
|
+
* Called when a step (LLM call) completes.
|
|
3235
|
+
* This is simply the StepResult for that step.
|
|
3236
|
+
*/
|
|
3237
|
+
type OnStepFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS>;
|
|
3238
|
+
/**
|
|
3239
|
+
* Event passed to the `onFinish` callback.
|
|
3240
|
+
*
|
|
3241
|
+
* Called when the entire generation completes (all steps finished).
|
|
3242
|
+
* Includes the final step's result along with aggregated data from all steps.
|
|
3243
|
+
*/
|
|
3244
|
+
type OnFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS> & {
|
|
3245
|
+
/** Array containing results from all steps in the generation. */
|
|
3246
|
+
readonly steps: StepResult<TOOLS>[];
|
|
3247
|
+
/** Aggregated token usage across all steps. */
|
|
3248
|
+
readonly totalUsage: LanguageModelUsage;
|
|
3218
3249
|
/**
|
|
3219
|
-
*
|
|
3220
|
-
*
|
|
3221
|
-
*
|
|
3250
|
+
* The final state of the user-defined context object.
|
|
3251
|
+
*
|
|
3252
|
+
* Experimental (can break in patch releases).
|
|
3253
|
+
*
|
|
3254
|
+
* @default undefined
|
|
3222
3255
|
*/
|
|
3223
|
-
|
|
3256
|
+
experimental_context: unknown;
|
|
3257
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3258
|
+
readonly functionId: string | undefined;
|
|
3259
|
+
/** Additional metadata from telemetry settings. */
|
|
3260
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3261
|
+
};
|
|
3262
|
+
|
|
3263
|
+
/**
|
|
3264
|
+
* A callback function that can be used to notify listeners.
|
|
3265
|
+
*/
|
|
3266
|
+
type Listener<EVENT> = (event: EVENT) => PromiseLike<void> | void;
|
|
3267
|
+
|
|
3268
|
+
/**
|
|
3269
|
+
* Implement this interface to create custom telemetry integrations.
|
|
3270
|
+
* Methods can be sync or return a PromiseLike.
|
|
3271
|
+
*/
|
|
3272
|
+
interface TelemetryIntegration {
|
|
3273
|
+
onStart?: Listener<OnStartEvent<ToolSet, Output>>;
|
|
3274
|
+
onStepStart?: Listener<OnStepStartEvent<ToolSet, Output>>;
|
|
3275
|
+
onToolCallStart?: Listener<OnToolCallStartEvent<ToolSet>>;
|
|
3276
|
+
onToolCallFinish?: Listener<OnToolCallFinishEvent<ToolSet>>;
|
|
3277
|
+
onStepFinish?: Listener<OnStepFinishEvent<ToolSet>>;
|
|
3278
|
+
onFinish?: Listener<OnFinishEvent<ToolSet>>;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
declare global {
|
|
3224
3282
|
/**
|
|
3225
|
-
*
|
|
3226
|
-
*
|
|
3227
|
-
*
|
|
3283
|
+
* The default provider to use for the AI SDK.
|
|
3284
|
+
* String model ids are resolved to the default provider and model id.
|
|
3285
|
+
*
|
|
3286
|
+
* If not set, the default provider is the Vercel AI gateway provider.
|
|
3287
|
+
*
|
|
3288
|
+
* @see https://ai-sdk.dev/docs/ai-sdk-core/provider-management#global-provider-configuration
|
|
3228
3289
|
*/
|
|
3229
|
-
|
|
3290
|
+
var AI_SDK_DEFAULT_PROVIDER: ProviderV3 | undefined;
|
|
3230
3291
|
/**
|
|
3231
|
-
* The
|
|
3292
|
+
* The warning logger to use for the AI SDK.
|
|
3232
3293
|
*
|
|
3233
|
-
*
|
|
3294
|
+
* If not set, the default logger is the console.warn function.
|
|
3295
|
+
*
|
|
3296
|
+
* If set to false, no warnings are logged.
|
|
3234
3297
|
*/
|
|
3235
|
-
|
|
3298
|
+
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
3236
3299
|
/**
|
|
3237
|
-
*
|
|
3300
|
+
* Globally registered telemetry integrations for the AI SDK.
|
|
3238
3301
|
*
|
|
3302
|
+
* Integrations registered here receive lifecycle events (onStart, onStepStart,
|
|
3303
|
+
* etc.) from every `generateText`, `streamText`, and similar call.
|
|
3304
|
+
*
|
|
3305
|
+
* Prefer using `registerTelemetryIntegration()` from `'ai'` instead of
|
|
3306
|
+
* assigning this directly.
|
|
3239
3307
|
*/
|
|
3240
|
-
|
|
3308
|
+
var AI_SDK_TELEMETRY_INTEGRATIONS: TelemetryIntegration[] | undefined;
|
|
3241
3309
|
}
|
|
3242
3310
|
|
|
3243
3311
|
type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: OnStepFinishEvent<TOOLS>) => Promise<void> | void;
|
|
@@ -5098,6 +5166,7 @@ type RepairTextFunction = (options: {
|
|
|
5098
5166
|
* @param system - A system message that will be part of the prompt.
|
|
5099
5167
|
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
5100
5168
|
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
5169
|
+
* @param allowSystemInMessages - Whether system messages are allowed in the `prompt` or `messages` fields. When unset, system messages are allowed with a warning.
|
|
5101
5170
|
*
|
|
5102
5171
|
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
5103
5172
|
* @param temperature - Temperature setting.
|
|
@@ -5449,6 +5518,7 @@ type StreamObjectOnFinishCallback<RESULT> = (event: {
|
|
|
5449
5518
|
* @param system - A system message that will be part of the prompt.
|
|
5450
5519
|
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
5451
5520
|
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
5521
|
+
* @param allowSystemInMessages - Whether system messages are allowed in the `prompt` or `messages` fields. When unset, system messages are allowed with a warning.
|
|
5452
5522
|
*
|
|
5453
5523
|
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
5454
5524
|
* @param temperature - Temperature setting.
|
|
@@ -5792,33 +5862,6 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5792
5862
|
}>;
|
|
5793
5863
|
}): Promise<GenerateVideoResult>;
|
|
5794
5864
|
|
|
5795
|
-
/**
|
|
5796
|
-
* A function for logging warnings.
|
|
5797
|
-
*
|
|
5798
|
-
* You can assign it to the `AI_SDK_LOG_WARNINGS` global variable to use it as the default warning logger.
|
|
5799
|
-
*
|
|
5800
|
-
* @example
|
|
5801
|
-
* ```ts
|
|
5802
|
-
* globalThis.AI_SDK_LOG_WARNINGS = (options) => {
|
|
5803
|
-
* console.log('WARNINGS:', options.warnings, options.provider, options.model);
|
|
5804
|
-
* };
|
|
5805
|
-
* ```
|
|
5806
|
-
*/
|
|
5807
|
-
type LogWarningsFunction = (options: {
|
|
5808
|
-
/**
|
|
5809
|
-
* The warnings returned by the model provider.
|
|
5810
|
-
*/
|
|
5811
|
-
warnings: Warning[];
|
|
5812
|
-
/**
|
|
5813
|
-
* The provider id used for the call.
|
|
5814
|
-
*/
|
|
5815
|
-
provider: string;
|
|
5816
|
-
/**
|
|
5817
|
-
* The model id used for the call.
|
|
5818
|
-
*/
|
|
5819
|
-
model: string;
|
|
5820
|
-
}) => void;
|
|
5821
|
-
|
|
5822
5865
|
/**
|
|
5823
5866
|
* Applies default settings for an embedding model.
|
|
5824
5867
|
*/
|
|
@@ -6370,34 +6413,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
|
|
|
6370
6413
|
*/
|
|
6371
6414
|
declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
|
|
6372
6415
|
|
|
6373
|
-
declare global {
|
|
6374
|
-
/**
|
|
6375
|
-
* The default provider to use for the AI SDK.
|
|
6376
|
-
* String model ids are resolved to the default provider and model id.
|
|
6377
|
-
*
|
|
6378
|
-
* If not set, the default provider is the Vercel AI gateway provider.
|
|
6379
|
-
*
|
|
6380
|
-
* @see https://ai-sdk.dev/docs/ai-sdk-core/provider-management#global-provider-configuration
|
|
6381
|
-
*/
|
|
6382
|
-
var AI_SDK_DEFAULT_PROVIDER: ProviderV3 | undefined;
|
|
6383
|
-
/**
|
|
6384
|
-
* The warning logger to use for the AI SDK.
|
|
6385
|
-
*
|
|
6386
|
-
* If not set, the default logger is the console.warn function.
|
|
6387
|
-
*
|
|
6388
|
-
* If set to false, no warnings are logged.
|
|
6389
|
-
*/
|
|
6390
|
-
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
6391
|
-
/**
|
|
6392
|
-
* Globally registered telemetry integrations for the AI SDK.
|
|
6393
|
-
*
|
|
6394
|
-
* Integrations registered here receive lifecycle events (onStart, onStepStart,
|
|
6395
|
-
* etc.) from every `generateText`, `streamText`, and similar call.
|
|
6396
|
-
*
|
|
6397
|
-
* Prefer using `registerTelemetryIntegration()` from `'ai'` instead of
|
|
6398
|
-
* assigning this directly.
|
|
6399
|
-
*/
|
|
6400
|
-
var AI_SDK_TELEMETRY_INTEGRATIONS: TelemetryIntegration[] | undefined;
|
|
6401
|
-
}
|
|
6402
|
-
|
|
6403
6416
|
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|