@fairyhunter13/ai-sdk 6.0.116-fork.29 → 6.0.116-fork.30
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 +18 -0
- package/dist/index.d.mts +206 -185
- package/dist/index.d.ts +206 -185
- package/dist/index.js +644 -845
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +644 -848
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +8 -8
- package/dist/internal/index.d.ts +8 -8
- package/dist/internal/index.js +18 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +16 -15
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/generate-object/generate-object.ts +141 -284
- package/src/generate-object/stream-object.ts +306 -456
- package/src/generate-object/structured-output-events.ts +11 -0
- package/src/generate-text/generate-text.ts +9 -6
- package/src/generate-text/stream-model-call.ts +9 -6
- package/src/generate-text/stream-text.ts +9 -6
- package/src/prompt/prepare-tool-choice.ts +15 -0
- package/src/prompt/{prepare-tools-and-tool-choice.ts → prepare-tools.ts} +7 -25
- package/src/telemetry/get-global-telemetry-integration.ts +8 -0
- package/src/telemetry/open-telemetry-integration.ts +229 -1
- package/src/telemetry/telemetry-integration.ts +36 -6
- package/src/telemetry/telemetry-settings.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.53
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9b47dea: fix(ai): remove otel Tracer api from telemetry settings
|
|
8
|
+
|
|
9
|
+
## 7.0.0-beta.52
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b56301c: feat(ai): decouple otel from generate/streamObject
|
|
14
|
+
|
|
15
|
+
## 7.0.0-beta.51
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 6abd098: split `prepareToolsAndToolChoice()` into `prepareTools()` and `prepareToolChoice()`
|
|
20
|
+
|
|
3
21
|
## 7.0.0-beta.50
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,6 @@ export { AssistantContent, AssistantModelMessage, DataContent, DownloadError, Fi
|
|
|
6
6
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
7
7
|
import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, LanguageModelV4CallOptions, AISDKError, LanguageModelV4ToolCall, JSONSchema7, LanguageModelV4Prompt, SharedV4Headers, LanguageModelV4ToolChoice, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
8
8
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
9
|
-
import { Tracer } from '@opentelemetry/api';
|
|
10
9
|
import { ServerResponse } from 'node:http';
|
|
11
10
|
import { ServerResponse as ServerResponse$1 } from 'http';
|
|
12
11
|
import { z } from 'zod/v4';
|
|
@@ -3014,6 +3013,190 @@ interface EmbedFinishEvent {
|
|
|
3014
3013
|
readonly usage: EmbeddingModelUsage;
|
|
3015
3014
|
}
|
|
3016
3015
|
|
|
3016
|
+
/**
|
|
3017
|
+
* Event passed to the `experimental_onStart` callback of
|
|
3018
|
+
* `generateObject` and `streamObject`.
|
|
3019
|
+
*
|
|
3020
|
+
* Called when the operation begins, before any LLM call.
|
|
3021
|
+
*
|
|
3022
|
+
* @deprecated
|
|
3023
|
+
*/
|
|
3024
|
+
interface ObjectOnStartEvent {
|
|
3025
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
3026
|
+
readonly callId: string;
|
|
3027
|
+
/** Identifies the operation type (e.g. `'ai.generateObject'` or `'ai.streamObject'`). */
|
|
3028
|
+
readonly operationId: string;
|
|
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
|
+
/** The system message(s) provided to the model. */
|
|
3034
|
+
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
3035
|
+
/** The prompt string or array of messages if using the prompt option. */
|
|
3036
|
+
readonly prompt: string | Array<ModelMessage> | undefined;
|
|
3037
|
+
/** The messages array if using the messages option. */
|
|
3038
|
+
readonly messages: Array<ModelMessage> | undefined;
|
|
3039
|
+
/** Maximum number of tokens to generate. */
|
|
3040
|
+
readonly maxOutputTokens: number | undefined;
|
|
3041
|
+
/** Sampling temperature for generation. */
|
|
3042
|
+
readonly temperature: number | undefined;
|
|
3043
|
+
/** Top-p (nucleus) sampling parameter. */
|
|
3044
|
+
readonly topP: number | undefined;
|
|
3045
|
+
/** Top-k sampling parameter. */
|
|
3046
|
+
readonly topK: number | undefined;
|
|
3047
|
+
/** Presence penalty for generation. */
|
|
3048
|
+
readonly presencePenalty: number | undefined;
|
|
3049
|
+
/** Frequency penalty for generation. */
|
|
3050
|
+
readonly frequencyPenalty: number | undefined;
|
|
3051
|
+
/** Random seed for reproducible generation. */
|
|
3052
|
+
readonly seed: number | undefined;
|
|
3053
|
+
/** Maximum number of retries for failed requests. */
|
|
3054
|
+
readonly maxRetries: number;
|
|
3055
|
+
/** Additional HTTP headers sent with the request. */
|
|
3056
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
3057
|
+
/** Additional provider-specific options. */
|
|
3058
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
3059
|
+
/** Abort signal for cancelling the operation. */
|
|
3060
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
3061
|
+
/** The output strategy type. */
|
|
3062
|
+
readonly output: 'object' | 'array' | 'enum' | 'no-schema';
|
|
3063
|
+
/** The JSON Schema used for object generation, if any. */
|
|
3064
|
+
readonly schema: Record<string, unknown> | undefined;
|
|
3065
|
+
/** Optional name of the schema. */
|
|
3066
|
+
readonly schemaName: string | undefined;
|
|
3067
|
+
/** Optional description of the schema. */
|
|
3068
|
+
readonly schemaDescription: string | undefined;
|
|
3069
|
+
/** Whether telemetry is enabled. */
|
|
3070
|
+
readonly isEnabled: boolean | undefined;
|
|
3071
|
+
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
3072
|
+
readonly recordInputs: boolean | undefined;
|
|
3073
|
+
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
3074
|
+
readonly recordOutputs: boolean | undefined;
|
|
3075
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3076
|
+
readonly functionId: string | undefined;
|
|
3077
|
+
/** Additional metadata from telemetry settings. */
|
|
3078
|
+
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* Event passed to the `experimental_onStepStart` callback of
|
|
3082
|
+
* `generateObject` and `streamObject`.
|
|
3083
|
+
*
|
|
3084
|
+
* Called when the model call (step) begins, before the provider is called.
|
|
3085
|
+
* For object generation, there is always exactly one step (step 0).
|
|
3086
|
+
*
|
|
3087
|
+
* @deprecated
|
|
3088
|
+
*/
|
|
3089
|
+
interface ObjectOnStepStartEvent {
|
|
3090
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
3091
|
+
readonly callId: string;
|
|
3092
|
+
/** Zero-based index of the current step. Always `0` for object generation. */
|
|
3093
|
+
readonly stepNumber: 0;
|
|
3094
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
3095
|
+
readonly provider: string;
|
|
3096
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
3097
|
+
readonly modelId: string;
|
|
3098
|
+
/** Additional provider-specific options. */
|
|
3099
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
3100
|
+
/** Additional HTTP headers sent with the request. */
|
|
3101
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
3102
|
+
/** Abort signal for cancelling the operation. */
|
|
3103
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
3104
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3105
|
+
readonly functionId: string | undefined;
|
|
3106
|
+
/** Additional metadata from telemetry settings. */
|
|
3107
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3108
|
+
/** The prompt messages in provider format (for telemetry). */
|
|
3109
|
+
readonly promptMessages?: LanguageModelV4Prompt;
|
|
3110
|
+
}
|
|
3111
|
+
/**
|
|
3112
|
+
* Event passed to the `onStepFinish` callback of
|
|
3113
|
+
* `generateObject` and `streamObject`.
|
|
3114
|
+
*
|
|
3115
|
+
* Called when the model call (step) completes, with the raw result
|
|
3116
|
+
* before JSON parsing and schema validation.
|
|
3117
|
+
*
|
|
3118
|
+
* @deprecated
|
|
3119
|
+
*/
|
|
3120
|
+
interface ObjectOnStepFinishEvent {
|
|
3121
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
3122
|
+
readonly callId: string;
|
|
3123
|
+
/** Zero-based index of the current step. Always `0` for object generation. */
|
|
3124
|
+
readonly stepNumber: 0;
|
|
3125
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
3126
|
+
readonly provider: string;
|
|
3127
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
3128
|
+
readonly modelId: string;
|
|
3129
|
+
/** The unified reason why the generation finished. */
|
|
3130
|
+
readonly finishReason: FinishReason;
|
|
3131
|
+
/** The token usage of the generated response. */
|
|
3132
|
+
readonly usage: LanguageModelUsage;
|
|
3133
|
+
/** The raw text output from the model (before JSON parsing). */
|
|
3134
|
+
readonly objectText: string;
|
|
3135
|
+
/** The reasoning generated by the model, if any. */
|
|
3136
|
+
readonly reasoning: string | undefined;
|
|
3137
|
+
/** Warnings from the model provider (e.g. unsupported settings). */
|
|
3138
|
+
readonly warnings: CallWarning[] | undefined;
|
|
3139
|
+
/** Additional request information. */
|
|
3140
|
+
readonly request: LanguageModelRequestMetadata;
|
|
3141
|
+
/** Additional response information. */
|
|
3142
|
+
readonly response: LanguageModelResponseMetadata & {
|
|
3143
|
+
body?: unknown;
|
|
3144
|
+
};
|
|
3145
|
+
/** Additional provider-specific metadata. */
|
|
3146
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
|
3147
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3148
|
+
readonly functionId: string | undefined;
|
|
3149
|
+
/** Additional metadata from telemetry settings. */
|
|
3150
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3151
|
+
/** Milliseconds from the start of the stream to the first chunk (streaming only). */
|
|
3152
|
+
readonly msToFirstChunk: number | undefined;
|
|
3153
|
+
}
|
|
3154
|
+
/**
|
|
3155
|
+
* Event passed to the `onFinish` callback of
|
|
3156
|
+
* `generateObject` and `streamObject`.
|
|
3157
|
+
*
|
|
3158
|
+
* Called when the entire operation completes, including JSON parsing
|
|
3159
|
+
* and schema validation. For `streamObject`, the object may be undefined
|
|
3160
|
+
* if validation failed (the error is provided in that case).
|
|
3161
|
+
*
|
|
3162
|
+
* @deprecated
|
|
3163
|
+
*/
|
|
3164
|
+
interface ObjectOnFinishEvent<RESULT> {
|
|
3165
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
3166
|
+
readonly callId: string;
|
|
3167
|
+
/**
|
|
3168
|
+
* The generated object (typed according to the schema).
|
|
3169
|
+
* Always defined for `generateObject`. May be `undefined` for `streamObject`
|
|
3170
|
+
* when parsing or validation fails.
|
|
3171
|
+
*/
|
|
3172
|
+
readonly object: RESULT | undefined;
|
|
3173
|
+
/**
|
|
3174
|
+
* Error from parsing or schema validation, if any.
|
|
3175
|
+
* Always `undefined` for `generateObject` (which throws instead).
|
|
3176
|
+
*/
|
|
3177
|
+
readonly error: unknown | undefined;
|
|
3178
|
+
/** The reasoning generated by the model, if any. */
|
|
3179
|
+
readonly reasoning: string | undefined;
|
|
3180
|
+
/** The unified reason why the generation finished. */
|
|
3181
|
+
readonly finishReason: FinishReason;
|
|
3182
|
+
/** The token usage of the generated response. */
|
|
3183
|
+
readonly usage: LanguageModelUsage;
|
|
3184
|
+
/** Warnings from the model provider (e.g. unsupported settings). */
|
|
3185
|
+
readonly warnings: CallWarning[] | undefined;
|
|
3186
|
+
/** Additional request information. */
|
|
3187
|
+
readonly request: LanguageModelRequestMetadata;
|
|
3188
|
+
/** Additional response information. */
|
|
3189
|
+
readonly response: LanguageModelResponseMetadata & {
|
|
3190
|
+
body?: unknown;
|
|
3191
|
+
};
|
|
3192
|
+
/** Additional provider-specific metadata. */
|
|
3193
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
|
3194
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
3195
|
+
readonly functionId: string | undefined;
|
|
3196
|
+
/** Additional metadata from telemetry settings. */
|
|
3197
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3017
3200
|
/**
|
|
3018
3201
|
* Event passed to the `onStart` callback for rerank operations.
|
|
3019
3202
|
*
|
|
@@ -3163,12 +3346,13 @@ type Listener<EVENT> = (event: EVENT) => PromiseLike<void> | void;
|
|
|
3163
3346
|
*/
|
|
3164
3347
|
interface TelemetryIntegration {
|
|
3165
3348
|
/**
|
|
3166
|
-
* Called when an operation begins. Fired for
|
|
3167
|
-
* (generateText/streamText)
|
|
3349
|
+
* Called when an operation begins. Fired for text generation
|
|
3350
|
+
* (generateText/streamText), object generation (generateObject/streamObject),
|
|
3351
|
+
* embedding (embed/embedMany), and reranking operations.
|
|
3168
3352
|
*
|
|
3169
3353
|
* Use the `operationId` field to distinguish between operation types.
|
|
3170
3354
|
*/
|
|
3171
|
-
onStart?: Listener<OnStartEvent<ToolSet, Output> | EmbedOnStartEvent | RerankOnStartEvent>;
|
|
3355
|
+
onStart?: Listener<OnStartEvent<ToolSet, Output> | ObjectOnStartEvent | EmbedOnStartEvent | RerankOnStartEvent>;
|
|
3172
3356
|
/**
|
|
3173
3357
|
* Called when an individual step (single LLM invocation) begins.
|
|
3174
3358
|
* A generation may consist of multiple steps (e.g. when tool calls trigger
|
|
@@ -3204,6 +3388,20 @@ interface TelemetryIntegration {
|
|
|
3204
3388
|
* bodies.
|
|
3205
3389
|
*/
|
|
3206
3390
|
onStepFinish?: Listener<OnStepFinishEvent<ToolSet>>;
|
|
3391
|
+
/**
|
|
3392
|
+
* Called when an object generation step (single LLM invocation) begins.
|
|
3393
|
+
* For generateObject/streamObject there is always exactly one step.
|
|
3394
|
+
*
|
|
3395
|
+
* @deprecated
|
|
3396
|
+
*/
|
|
3397
|
+
onObjectStepStart?: Listener<ObjectOnStepStartEvent>;
|
|
3398
|
+
/**
|
|
3399
|
+
* Called when an object generation step (single LLM invocation) completes,
|
|
3400
|
+
* with the raw result before JSON parsing and schema validation.
|
|
3401
|
+
*
|
|
3402
|
+
* @deprecated
|
|
3403
|
+
*/
|
|
3404
|
+
onObjectStepFinish?: Listener<ObjectOnStepFinishEvent>;
|
|
3207
3405
|
/**
|
|
3208
3406
|
* Called when an individual embedding model call (doEmbed) begins.
|
|
3209
3407
|
* For `embed`, there is one call. For `embedMany`, there may be multiple
|
|
@@ -3226,12 +3424,13 @@ interface TelemetryIntegration {
|
|
|
3226
3424
|
*/
|
|
3227
3425
|
onRerankFinish?: Listener<RerankFinishEvent>;
|
|
3228
3426
|
/**
|
|
3229
|
-
* Called when an operation completes. Fired for
|
|
3230
|
-
* (generateText/streamText)
|
|
3427
|
+
* Called when an operation completes. Fired for text generation
|
|
3428
|
+
* (generateText/streamText), object generation (generateObject/streamObject),
|
|
3429
|
+
* embedding (embed/embedMany), and reranking operations.
|
|
3231
3430
|
*
|
|
3232
3431
|
* Use the event shape or `operationId` to distinguish between operation types.
|
|
3233
3432
|
*/
|
|
3234
|
-
onFinish?: Listener<OnFinishEvent<ToolSet> | EmbedOnFinishEvent | RerankOnFinishEvent>;
|
|
3433
|
+
onFinish?: Listener<OnFinishEvent<ToolSet> | ObjectOnFinishEvent<unknown> | EmbedOnFinishEvent | RerankOnFinishEvent>;
|
|
3235
3434
|
/**
|
|
3236
3435
|
* Called when an unrecoverable error occurs during the generation lifecycle.
|
|
3237
3436
|
* The error value is untyped — it may be an `Error` instance, an `AISDKError`,
|
|
@@ -3286,10 +3485,6 @@ type TelemetrySettings = {
|
|
|
3286
3485
|
* Additional information to include in the telemetry data.
|
|
3287
3486
|
*/
|
|
3288
3487
|
metadata?: Record<string, JSONValue$1>;
|
|
3289
|
-
/**
|
|
3290
|
-
* A custom tracer to use for the telemetry data.
|
|
3291
|
-
*/
|
|
3292
|
-
tracer?: Tracer;
|
|
3293
3488
|
/**
|
|
3294
3489
|
* Per-call telemetry integrations that receive lifecycle events during generation.
|
|
3295
3490
|
*
|
|
@@ -5652,180 +5847,6 @@ declare const experimental_generateImage: typeof generateImage;
|
|
|
5652
5847
|
*/
|
|
5653
5848
|
type Experimental_GenerateImageResult = GenerateImageResult;
|
|
5654
5849
|
|
|
5655
|
-
/**
|
|
5656
|
-
* Event passed to the `experimental_onStart` callback of
|
|
5657
|
-
* `generateObject` and `streamObject`.
|
|
5658
|
-
*
|
|
5659
|
-
* Called when the operation begins, before any LLM call.
|
|
5660
|
-
*/
|
|
5661
|
-
interface ObjectOnStartEvent {
|
|
5662
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
5663
|
-
readonly callId: string;
|
|
5664
|
-
/** Identifies the operation type (e.g. `'ai.generateObject'` or `'ai.streamObject'`). */
|
|
5665
|
-
readonly operationId: string;
|
|
5666
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
5667
|
-
readonly provider: string;
|
|
5668
|
-
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
5669
|
-
readonly modelId: string;
|
|
5670
|
-
/** The system message(s) provided to the model. */
|
|
5671
|
-
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
5672
|
-
/** The prompt string or array of messages if using the prompt option. */
|
|
5673
|
-
readonly prompt: string | Array<ModelMessage> | undefined;
|
|
5674
|
-
/** The messages array if using the messages option. */
|
|
5675
|
-
readonly messages: Array<ModelMessage> | undefined;
|
|
5676
|
-
/** Maximum number of tokens to generate. */
|
|
5677
|
-
readonly maxOutputTokens: number | undefined;
|
|
5678
|
-
/** Sampling temperature for generation. */
|
|
5679
|
-
readonly temperature: number | undefined;
|
|
5680
|
-
/** Top-p (nucleus) sampling parameter. */
|
|
5681
|
-
readonly topP: number | undefined;
|
|
5682
|
-
/** Top-k sampling parameter. */
|
|
5683
|
-
readonly topK: number | undefined;
|
|
5684
|
-
/** Presence penalty for generation. */
|
|
5685
|
-
readonly presencePenalty: number | undefined;
|
|
5686
|
-
/** Frequency penalty for generation. */
|
|
5687
|
-
readonly frequencyPenalty: number | undefined;
|
|
5688
|
-
/** Random seed for reproducible generation. */
|
|
5689
|
-
readonly seed: number | undefined;
|
|
5690
|
-
/** Maximum number of retries for failed requests. */
|
|
5691
|
-
readonly maxRetries: number;
|
|
5692
|
-
/** Additional HTTP headers sent with the request. */
|
|
5693
|
-
readonly headers: Record<string, string | undefined> | undefined;
|
|
5694
|
-
/** Additional provider-specific options. */
|
|
5695
|
-
readonly providerOptions: ProviderOptions | undefined;
|
|
5696
|
-
/** Abort signal for cancelling the operation. */
|
|
5697
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
5698
|
-
/** The output strategy type. */
|
|
5699
|
-
readonly output: 'object' | 'array' | 'enum' | 'no-schema';
|
|
5700
|
-
/** The JSON Schema used for object generation, if any. */
|
|
5701
|
-
readonly schema: Record<string, unknown> | undefined;
|
|
5702
|
-
/** Optional name of the schema. */
|
|
5703
|
-
readonly schemaName: string | undefined;
|
|
5704
|
-
/** Optional description of the schema. */
|
|
5705
|
-
readonly schemaDescription: string | undefined;
|
|
5706
|
-
/** Whether telemetry is enabled. */
|
|
5707
|
-
readonly isEnabled: boolean | undefined;
|
|
5708
|
-
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
5709
|
-
readonly recordInputs: boolean | undefined;
|
|
5710
|
-
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
5711
|
-
readonly recordOutputs: boolean | undefined;
|
|
5712
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
5713
|
-
readonly functionId: string | undefined;
|
|
5714
|
-
/** Additional metadata from telemetry settings. */
|
|
5715
|
-
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
5716
|
-
}
|
|
5717
|
-
/**
|
|
5718
|
-
* Event passed to the `experimental_onStepStart` callback of
|
|
5719
|
-
* `generateObject` and `streamObject`.
|
|
5720
|
-
*
|
|
5721
|
-
* Called when the model call (step) begins, before the provider is called.
|
|
5722
|
-
* For object generation, there is always exactly one step (step 0).
|
|
5723
|
-
*/
|
|
5724
|
-
interface ObjectOnStepStartEvent {
|
|
5725
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
5726
|
-
readonly callId: string;
|
|
5727
|
-
/** Zero-based index of the current step. Always `0` for object generation. */
|
|
5728
|
-
readonly stepNumber: 0;
|
|
5729
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
5730
|
-
readonly provider: string;
|
|
5731
|
-
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
5732
|
-
readonly modelId: string;
|
|
5733
|
-
/** Additional provider-specific options. */
|
|
5734
|
-
readonly providerOptions: ProviderOptions | undefined;
|
|
5735
|
-
/** Additional HTTP headers sent with the request. */
|
|
5736
|
-
readonly headers: Record<string, string | undefined> | undefined;
|
|
5737
|
-
/** Abort signal for cancelling the operation. */
|
|
5738
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
5739
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
5740
|
-
readonly functionId: string | undefined;
|
|
5741
|
-
/** Additional metadata from telemetry settings. */
|
|
5742
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
5743
|
-
/** The prompt messages in provider format (for telemetry). */
|
|
5744
|
-
readonly promptMessages?: LanguageModelV4Prompt;
|
|
5745
|
-
}
|
|
5746
|
-
/**
|
|
5747
|
-
* Event passed to the `onStepFinish` callback of
|
|
5748
|
-
* `generateObject` and `streamObject`.
|
|
5749
|
-
*
|
|
5750
|
-
* Called when the model call (step) completes, with the raw result
|
|
5751
|
-
* before JSON parsing and schema validation.
|
|
5752
|
-
*/
|
|
5753
|
-
interface ObjectOnStepFinishEvent {
|
|
5754
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
5755
|
-
readonly callId: string;
|
|
5756
|
-
/** Zero-based index of the current step. Always `0` for object generation. */
|
|
5757
|
-
readonly stepNumber: 0;
|
|
5758
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
5759
|
-
readonly provider: string;
|
|
5760
|
-
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
5761
|
-
readonly modelId: string;
|
|
5762
|
-
/** The unified reason why the generation finished. */
|
|
5763
|
-
readonly finishReason: FinishReason;
|
|
5764
|
-
/** The token usage of the generated response. */
|
|
5765
|
-
readonly usage: LanguageModelUsage;
|
|
5766
|
-
/** The raw text output from the model (before JSON parsing). */
|
|
5767
|
-
readonly objectText: string;
|
|
5768
|
-
/** The reasoning generated by the model, if any. */
|
|
5769
|
-
readonly reasoning: string | undefined;
|
|
5770
|
-
/** Warnings from the model provider (e.g. unsupported settings). */
|
|
5771
|
-
readonly warnings: CallWarning[] | undefined;
|
|
5772
|
-
/** Additional request information. */
|
|
5773
|
-
readonly request: LanguageModelRequestMetadata;
|
|
5774
|
-
/** Additional response information. */
|
|
5775
|
-
readonly response: LanguageModelResponseMetadata & {
|
|
5776
|
-
body?: unknown;
|
|
5777
|
-
};
|
|
5778
|
-
/** Additional provider-specific metadata. */
|
|
5779
|
-
readonly providerMetadata: ProviderMetadata | undefined;
|
|
5780
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
5781
|
-
readonly functionId: string | undefined;
|
|
5782
|
-
/** Additional metadata from telemetry settings. */
|
|
5783
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
5784
|
-
}
|
|
5785
|
-
/**
|
|
5786
|
-
* Event passed to the `onFinish` callback of
|
|
5787
|
-
* `generateObject` and `streamObject`.
|
|
5788
|
-
*
|
|
5789
|
-
* Called when the entire operation completes, including JSON parsing
|
|
5790
|
-
* and schema validation. For `streamObject`, the object may be undefined
|
|
5791
|
-
* if validation failed (the error is provided in that case).
|
|
5792
|
-
*/
|
|
5793
|
-
interface ObjectOnFinishEvent<RESULT> {
|
|
5794
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
5795
|
-
readonly callId: string;
|
|
5796
|
-
/**
|
|
5797
|
-
* The generated object (typed according to the schema).
|
|
5798
|
-
* Always defined for `generateObject`. May be `undefined` for `streamObject`
|
|
5799
|
-
* when parsing or validation fails.
|
|
5800
|
-
*/
|
|
5801
|
-
readonly object: RESULT | undefined;
|
|
5802
|
-
/**
|
|
5803
|
-
* Error from parsing or schema validation, if any.
|
|
5804
|
-
* Always `undefined` for `generateObject` (which throws instead).
|
|
5805
|
-
*/
|
|
5806
|
-
readonly error: unknown | undefined;
|
|
5807
|
-
/** The reasoning generated by the model, if any. */
|
|
5808
|
-
readonly reasoning: string | undefined;
|
|
5809
|
-
/** The unified reason why the generation finished. */
|
|
5810
|
-
readonly finishReason: FinishReason;
|
|
5811
|
-
/** The token usage of the generated response. */
|
|
5812
|
-
readonly usage: LanguageModelUsage;
|
|
5813
|
-
/** Warnings from the model provider (e.g. unsupported settings). */
|
|
5814
|
-
readonly warnings: CallWarning[] | undefined;
|
|
5815
|
-
/** Additional request information. */
|
|
5816
|
-
readonly request: LanguageModelRequestMetadata;
|
|
5817
|
-
/** Additional response information. */
|
|
5818
|
-
readonly response: LanguageModelResponseMetadata & {
|
|
5819
|
-
body?: unknown;
|
|
5820
|
-
};
|
|
5821
|
-
/** Additional provider-specific metadata. */
|
|
5822
|
-
readonly providerMetadata: ProviderMetadata | undefined;
|
|
5823
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
5824
|
-
readonly functionId: string | undefined;
|
|
5825
|
-
/** Additional metadata from telemetry settings. */
|
|
5826
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
5827
|
-
}
|
|
5828
|
-
|
|
5829
5850
|
/**
|
|
5830
5851
|
* The result of a `generateObject` call.
|
|
5831
5852
|
*/
|