ai 7.0.0-beta.34 → 7.0.0-beta.36
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 +12 -0
- package/dist/index.d.mts +193 -107
- package/dist/index.d.ts +193 -107
- package/dist/index.js +770 -609
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +772 -612
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +82 -82
- package/dist/internal/index.d.ts +82 -82
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +2 -0
- package/package.json +1 -1
- package/src/embed/embed-events.ts +72 -0
- package/src/embed/embed-many.ts +206 -262
- package/src/embed/embed.ts +81 -109
- package/src/generate-text/index.ts +12 -11
- package/src/generate-text/stream-model-call.ts +127 -0
- package/src/generate-text/stream-text.ts +74 -76
- package/src/telemetry/get-global-telemetry-integration.ts +8 -0
- package/src/telemetry/open-telemetry-integration.ts +185 -7
- package/src/telemetry/telemetry-integration.ts +28 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 118b953: feat(ai): decouple otel from embed functions
|
|
8
|
+
|
|
9
|
+
## 7.0.0-beta.35
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 99bf941: feat(ai): extract streamModelCall function for streaming text generation
|
|
14
|
+
|
|
3
15
|
## 7.0.0-beta.34
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
|
4
4
|
import { Tool, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, AssistantModelMessage, ToolModelMessage, ReasoningPart, ReasoningFilePart, ProviderOptions, UserModelMessage, IdGenerator, ToolCall, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
|
|
5
5
|
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
6
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
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,
|
|
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, LanguageModelV4ResponseMetadata, LanguageModelV4Prompt, 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
9
|
import { Tracer } from '@opentelemetry/api';
|
|
10
10
|
import { ServerResponse } from 'node:http';
|
|
@@ -1377,6 +1377,45 @@ declare function smoothStream<TOOLS extends ToolSet>({ delayInMs, chunking, _int
|
|
|
1377
1377
|
tools: TOOLS;
|
|
1378
1378
|
}) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
|
|
1379
1379
|
|
|
1380
|
+
type UglyTransformedStreamTextPart<TOOLS extends ToolSet> = Exclude<TextStreamPart<TOOLS>, {
|
|
1381
|
+
type: 'finish' | 'stream-start' | 'tool-output-denied' | 'start-step' | 'finish-step' | 'start' | 'abort';
|
|
1382
|
+
}> | TextStreamTextDeltaPart | TextStreamReasoningDeltaPart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | {
|
|
1383
|
+
type: 'finish';
|
|
1384
|
+
finishReason: FinishReason;
|
|
1385
|
+
rawFinishReason: string | undefined;
|
|
1386
|
+
usage: LanguageModelUsage;
|
|
1387
|
+
providerMetadata?: ProviderMetadata;
|
|
1388
|
+
} | {
|
|
1389
|
+
type: 'stream-start';
|
|
1390
|
+
warnings: Array<SharedV4Warning>;
|
|
1391
|
+
} | ({
|
|
1392
|
+
type: 'response-metadata';
|
|
1393
|
+
} & LanguageModelV4ResponseMetadata);
|
|
1394
|
+
|
|
1395
|
+
declare function streamModelCall<TOOLS extends ToolSet, OUTPUT extends Output = Output>({ model, tools, output, toolChoice, activeTools, prompt, system, messages, download, maxRetries, abortSignal, headers, includeRawChunks, providerOptions, repairToolCall, onStart, ...callSettings }: {
|
|
1396
|
+
model: LanguageModel;
|
|
1397
|
+
tools?: TOOLS;
|
|
1398
|
+
output?: OUTPUT;
|
|
1399
|
+
toolChoice?: ToolChoice<TOOLS>;
|
|
1400
|
+
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
|
1401
|
+
download?: DownloadFunction;
|
|
1402
|
+
headers?: Record<string, string | undefined>;
|
|
1403
|
+
includeRawChunks?: boolean;
|
|
1404
|
+
providerOptions?: ProviderOptions;
|
|
1405
|
+
repairToolCall?: ToolCallRepairFunction<TOOLS> | undefined;
|
|
1406
|
+
onStart?: (args: {
|
|
1407
|
+
promptMessages: LanguageModelV4Prompt;
|
|
1408
|
+
}) => Promise<void> | void;
|
|
1409
|
+
} & Prompt & CallSettings): Promise<{
|
|
1410
|
+
stream: AsyncIterableStream<UglyTransformedStreamTextPart<TOOLS>>;
|
|
1411
|
+
response: {
|
|
1412
|
+
headers?: _ai_sdk_provider.SharedV4Headers;
|
|
1413
|
+
} | undefined;
|
|
1414
|
+
request: {
|
|
1415
|
+
body?: unknown;
|
|
1416
|
+
} | undefined;
|
|
1417
|
+
}>;
|
|
1418
|
+
|
|
1380
1419
|
/**
|
|
1381
1420
|
* Tool output when the tool execution has been denied (for static tools).
|
|
1382
1421
|
*/
|
|
@@ -2811,6 +2850,138 @@ type OnFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS> & {
|
|
|
2811
2850
|
readonly metadata: Record<string, unknown> | undefined;
|
|
2812
2851
|
};
|
|
2813
2852
|
|
|
2853
|
+
/**
|
|
2854
|
+
* Event passed to the `onStart` callback for embed and embedMany operations.
|
|
2855
|
+
*
|
|
2856
|
+
* Called when the operation begins, before the embedding model is called.
|
|
2857
|
+
*/
|
|
2858
|
+
interface EmbedOnStartEvent {
|
|
2859
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
2860
|
+
readonly callId: string;
|
|
2861
|
+
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
2862
|
+
readonly operationId: string;
|
|
2863
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2864
|
+
readonly provider: string;
|
|
2865
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
2866
|
+
readonly modelId: string;
|
|
2867
|
+
/** The value(s) being embedded. A string for embed, an array for embedMany. */
|
|
2868
|
+
readonly value: string | Array<string>;
|
|
2869
|
+
/** Maximum number of retries for failed requests. */
|
|
2870
|
+
readonly maxRetries: number;
|
|
2871
|
+
/** Abort signal for cancelling the operation. */
|
|
2872
|
+
readonly abortSignal: AbortSignal | undefined;
|
|
2873
|
+
/** Additional HTTP headers sent with the request. */
|
|
2874
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
2875
|
+
/** Additional provider-specific options. */
|
|
2876
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
2877
|
+
/** Whether telemetry is enabled. */
|
|
2878
|
+
readonly isEnabled: boolean | undefined;
|
|
2879
|
+
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
2880
|
+
readonly recordInputs: boolean | undefined;
|
|
2881
|
+
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
2882
|
+
readonly recordOutputs: boolean | undefined;
|
|
2883
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
2884
|
+
readonly functionId: string | undefined;
|
|
2885
|
+
/** Additional metadata from telemetry settings. */
|
|
2886
|
+
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
2887
|
+
}
|
|
2888
|
+
/**
|
|
2889
|
+
* Event passed to the `onFinish` callback for embed and embedMany operations.
|
|
2890
|
+
*
|
|
2891
|
+
* Called when the operation completes, after the embedding model returns.
|
|
2892
|
+
*/
|
|
2893
|
+
interface EmbedOnFinishEvent {
|
|
2894
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
2895
|
+
readonly callId: string;
|
|
2896
|
+
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
2897
|
+
readonly operationId: string;
|
|
2898
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2899
|
+
readonly provider: string;
|
|
2900
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
2901
|
+
readonly modelId: string;
|
|
2902
|
+
/** The value(s) that were embedded. A string for embed, an array for embedMany. */
|
|
2903
|
+
readonly value: string | Array<string>;
|
|
2904
|
+
/** The resulting embedding(s). A single vector for embed, an array for embedMany. */
|
|
2905
|
+
readonly embedding: Embedding | Array<Embedding>;
|
|
2906
|
+
/** Token usage for the embedding operation. */
|
|
2907
|
+
readonly usage: EmbeddingModelUsage;
|
|
2908
|
+
/** Warnings from the embedding model, e.g. unsupported settings. */
|
|
2909
|
+
readonly warnings: Array<Warning>;
|
|
2910
|
+
/** Optional provider-specific metadata. */
|
|
2911
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
|
2912
|
+
/** Response data including headers and body. A single response for embed, an array for embedMany. */
|
|
2913
|
+
readonly response: {
|
|
2914
|
+
headers?: Record<string, string>;
|
|
2915
|
+
body?: unknown;
|
|
2916
|
+
} | Array<{
|
|
2917
|
+
headers?: Record<string, string>;
|
|
2918
|
+
body?: unknown;
|
|
2919
|
+
} | undefined> | undefined;
|
|
2920
|
+
/** Whether telemetry is enabled. */
|
|
2921
|
+
readonly isEnabled: boolean | undefined;
|
|
2922
|
+
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
2923
|
+
readonly recordInputs: boolean | undefined;
|
|
2924
|
+
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
2925
|
+
readonly recordOutputs: boolean | undefined;
|
|
2926
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
2927
|
+
readonly functionId: string | undefined;
|
|
2928
|
+
/** Additional metadata from telemetry settings. */
|
|
2929
|
+
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
2930
|
+
}
|
|
2931
|
+
/**
|
|
2932
|
+
* Event fired when an individual embedding model call (inner operation doEmbed) begins.
|
|
2933
|
+
*
|
|
2934
|
+
* For `embed`, there is one call. For `embedMany`, there may be multiple
|
|
2935
|
+
* calls when values are chunked.
|
|
2936
|
+
*/
|
|
2937
|
+
interface EmbedStartEvent {
|
|
2938
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
2939
|
+
readonly callId: string;
|
|
2940
|
+
/** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
|
|
2941
|
+
readonly embedCallId: string;
|
|
2942
|
+
/** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
|
|
2943
|
+
readonly operationId: string;
|
|
2944
|
+
/** The provider identifier. */
|
|
2945
|
+
readonly provider: string;
|
|
2946
|
+
/** The specific model identifier. */
|
|
2947
|
+
readonly modelId: string;
|
|
2948
|
+
/** The values being embedded in this particular model call. */
|
|
2949
|
+
readonly values: Array<string>;
|
|
2950
|
+
/** Whether telemetry is enabled. */
|
|
2951
|
+
readonly isEnabled: boolean | undefined;
|
|
2952
|
+
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
2953
|
+
readonly recordInputs: boolean | undefined;
|
|
2954
|
+
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
2955
|
+
readonly recordOutputs: boolean | undefined;
|
|
2956
|
+
/** Identifier from telemetry settings for grouping related operations. */
|
|
2957
|
+
readonly functionId: string | undefined;
|
|
2958
|
+
/** Additional metadata from telemetry settings. */
|
|
2959
|
+
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
2960
|
+
}
|
|
2961
|
+
/**
|
|
2962
|
+
* Event fired when an individual embedding model call (doEmbed) completes.
|
|
2963
|
+
*
|
|
2964
|
+
* Contains the embeddings, usage, and any warnings from the model response.
|
|
2965
|
+
*/
|
|
2966
|
+
interface EmbedFinishEvent {
|
|
2967
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
2968
|
+
readonly callId: string;
|
|
2969
|
+
/** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
|
|
2970
|
+
readonly embedCallId: string;
|
|
2971
|
+
/** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
|
|
2972
|
+
readonly operationId: string;
|
|
2973
|
+
/** The provider identifier. */
|
|
2974
|
+
readonly provider: string;
|
|
2975
|
+
/** The specific model identifier. */
|
|
2976
|
+
readonly modelId: string;
|
|
2977
|
+
/** The values that were embedded in this particular model call. */
|
|
2978
|
+
readonly values: Array<string>;
|
|
2979
|
+
/** The resulting embeddings from the model call. */
|
|
2980
|
+
readonly embeddings: Array<Embedding>;
|
|
2981
|
+
/** Token usage for this model call. */
|
|
2982
|
+
readonly usage: EmbeddingModelUsage;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2814
2985
|
/**
|
|
2815
2986
|
* A callback function that can be used to notify listeners.
|
|
2816
2987
|
*/
|
|
@@ -2822,14 +2993,12 @@ type Listener<EVENT> = (event: EVENT) => PromiseLike<void> | void;
|
|
|
2822
2993
|
*/
|
|
2823
2994
|
interface TelemetryIntegration {
|
|
2824
2995
|
/**
|
|
2825
|
-
* Called when
|
|
2826
|
-
*
|
|
2827
|
-
* tracking state for the entire generation lifecycle.
|
|
2996
|
+
* Called when an operation begins. Fired for both text generation
|
|
2997
|
+
* (generateText/streamText) and embedding (embed/embedMany) operations.
|
|
2828
2998
|
*
|
|
2829
|
-
*
|
|
2830
|
-
* parameters, and telemetry settings.
|
|
2999
|
+
* Use the `operationId` field to distinguish between operation types.
|
|
2831
3000
|
*/
|
|
2832
|
-
onStart?: Listener<OnStartEvent<ToolSet, Output
|
|
3001
|
+
onStart?: Listener<OnStartEvent<ToolSet, Output> | EmbedOnStartEvent>;
|
|
2833
3002
|
/**
|
|
2834
3003
|
* Called when an individual step (single LLM invocation) begins.
|
|
2835
3004
|
* A generation may consist of multiple steps (e.g. when tool calls trigger
|
|
@@ -2866,12 +3035,23 @@ interface TelemetryIntegration {
|
|
|
2866
3035
|
*/
|
|
2867
3036
|
onStepFinish?: Listener<OnStepFinishEvent<ToolSet>>;
|
|
2868
3037
|
/**
|
|
2869
|
-
* Called when
|
|
2870
|
-
*
|
|
2871
|
-
*
|
|
2872
|
-
* (`totalUsage`).
|
|
3038
|
+
* Called when an individual embedding model call (doEmbed) begins.
|
|
3039
|
+
* For `embed`, there is one call. For `embedMany`, there may be multiple
|
|
3040
|
+
* calls when values are chunked.
|
|
2873
3041
|
*/
|
|
2874
|
-
|
|
3042
|
+
onEmbedStart?: Listener<EmbedStartEvent>;
|
|
3043
|
+
/**
|
|
3044
|
+
* Called when an individual embedding model call (doEmbed) completes.
|
|
3045
|
+
* Contains the embeddings, usage, and any warnings from the model response.
|
|
3046
|
+
*/
|
|
3047
|
+
onEmbedFinish?: Listener<EmbedFinishEvent>;
|
|
3048
|
+
/**
|
|
3049
|
+
* Called when an operation completes. Fired for both text generation
|
|
3050
|
+
* (generateText/streamText) and embedding (embed/embedMany) operations.
|
|
3051
|
+
*
|
|
3052
|
+
* Use the event shape or `operationId` to distinguish between operation types.
|
|
3053
|
+
*/
|
|
3054
|
+
onFinish?: Listener<OnFinishEvent<ToolSet> | EmbedOnFinishEvent>;
|
|
2875
3055
|
/**
|
|
2876
3056
|
* Called when an unrecoverable error occurs during the generation lifecycle.
|
|
2877
3057
|
* The error value is untyped — it may be an `Error` instance, an `AISDKError`,
|
|
@@ -4623,85 +4803,6 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
4623
4803
|
onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>;
|
|
4624
4804
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
|
|
4625
4805
|
|
|
4626
|
-
/**
|
|
4627
|
-
* Event passed to the `onStart` callback for embed and embedMany operations.
|
|
4628
|
-
*
|
|
4629
|
-
* Called when the operation begins, before the embedding model is called.
|
|
4630
|
-
*/
|
|
4631
|
-
interface EmbedOnStartEvent {
|
|
4632
|
-
/** Unique identifier for this embed call, used to correlate events. */
|
|
4633
|
-
readonly callId: string;
|
|
4634
|
-
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
4635
|
-
readonly operationId: string;
|
|
4636
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
4637
|
-
readonly provider: string;
|
|
4638
|
-
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
4639
|
-
readonly modelId: string;
|
|
4640
|
-
/** The value(s) being embedded. A string for embed, an array for embedMany. */
|
|
4641
|
-
readonly value: string | Array<string>;
|
|
4642
|
-
/** Maximum number of retries for failed requests. */
|
|
4643
|
-
readonly maxRetries: number;
|
|
4644
|
-
/** Abort signal for cancelling the operation. */
|
|
4645
|
-
readonly abortSignal: AbortSignal | undefined;
|
|
4646
|
-
/** Additional HTTP headers sent with the request. */
|
|
4647
|
-
readonly headers: Record<string, string | undefined> | undefined;
|
|
4648
|
-
/** Additional provider-specific options. */
|
|
4649
|
-
readonly providerOptions: ProviderOptions | undefined;
|
|
4650
|
-
/** Whether telemetry is enabled. */
|
|
4651
|
-
readonly isEnabled: boolean | undefined;
|
|
4652
|
-
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
4653
|
-
readonly recordInputs: boolean | undefined;
|
|
4654
|
-
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
4655
|
-
readonly recordOutputs: boolean | undefined;
|
|
4656
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
4657
|
-
readonly functionId: string | undefined;
|
|
4658
|
-
/** Additional metadata from telemetry settings. */
|
|
4659
|
-
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
4660
|
-
}
|
|
4661
|
-
/**
|
|
4662
|
-
* Event passed to the `onFinish` callback for embed and embedMany operations.
|
|
4663
|
-
*
|
|
4664
|
-
* Called when the operation completes, after the embedding model returns.
|
|
4665
|
-
*/
|
|
4666
|
-
interface EmbedOnFinishEvent {
|
|
4667
|
-
/** Unique identifier for this embed call, used to correlate events. */
|
|
4668
|
-
readonly callId: string;
|
|
4669
|
-
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
4670
|
-
readonly operationId: string;
|
|
4671
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
4672
|
-
readonly provider: string;
|
|
4673
|
-
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
4674
|
-
readonly modelId: string;
|
|
4675
|
-
/** The value(s) that were embedded. A string for embed, an array for embedMany. */
|
|
4676
|
-
readonly value: string | Array<string>;
|
|
4677
|
-
/** The resulting embedding(s). A single vector for embed, an array for embedMany. */
|
|
4678
|
-
readonly embedding: Embedding | Array<Embedding>;
|
|
4679
|
-
/** Token usage for the embedding operation. */
|
|
4680
|
-
readonly usage: EmbeddingModelUsage;
|
|
4681
|
-
/** Warnings from the embedding model, e.g. unsupported settings. */
|
|
4682
|
-
readonly warnings: Array<Warning>;
|
|
4683
|
-
/** Optional provider-specific metadata. */
|
|
4684
|
-
readonly providerMetadata: ProviderMetadata | undefined;
|
|
4685
|
-
/** Response data including headers and body. A single response for embed, an array for embedMany. */
|
|
4686
|
-
readonly response: {
|
|
4687
|
-
headers?: Record<string, string>;
|
|
4688
|
-
body?: unknown;
|
|
4689
|
-
} | Array<{
|
|
4690
|
-
headers?: Record<string, string>;
|
|
4691
|
-
body?: unknown;
|
|
4692
|
-
} | undefined> | undefined;
|
|
4693
|
-
/** Whether telemetry is enabled. */
|
|
4694
|
-
readonly isEnabled: boolean | undefined;
|
|
4695
|
-
/** Whether to record inputs in telemetry. Enabled by default. */
|
|
4696
|
-
readonly recordInputs: boolean | undefined;
|
|
4697
|
-
/** Whether to record outputs in telemetry. Enabled by default. */
|
|
4698
|
-
readonly recordOutputs: boolean | undefined;
|
|
4699
|
-
/** Identifier from telemetry settings for grouping related operations. */
|
|
4700
|
-
readonly functionId: string | undefined;
|
|
4701
|
-
/** Additional metadata from telemetry settings. */
|
|
4702
|
-
readonly metadata: Record<string, JSONValue$1> | undefined;
|
|
4703
|
-
}
|
|
4704
|
-
|
|
4705
4806
|
/**
|
|
4706
4807
|
* The result of an `embed` call.
|
|
4707
4808
|
* It contains the embedding, the value, and additional information.
|
|
@@ -4947,21 +5048,6 @@ declare class InvalidArgumentError extends AISDKError {
|
|
|
4947
5048
|
static isInstance(error: unknown): error is InvalidArgumentError;
|
|
4948
5049
|
}
|
|
4949
5050
|
|
|
4950
|
-
type UglyTransformedStreamTextPart<TOOLS extends ToolSet> = Exclude<TextStreamPart<TOOLS>, {
|
|
4951
|
-
type: 'finish' | 'stream-start' | 'tool-output-denied' | 'start-step' | 'finish-step' | 'start' | 'abort';
|
|
4952
|
-
}> | TextStreamTextDeltaPart | TextStreamReasoningDeltaPart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | {
|
|
4953
|
-
type: 'finish';
|
|
4954
|
-
finishReason: FinishReason;
|
|
4955
|
-
rawFinishReason: string | undefined;
|
|
4956
|
-
usage: LanguageModelUsage;
|
|
4957
|
-
providerMetadata?: ProviderMetadata;
|
|
4958
|
-
} | {
|
|
4959
|
-
type: 'stream-start';
|
|
4960
|
-
warnings: Array<SharedV4Warning>;
|
|
4961
|
-
} | ({
|
|
4962
|
-
type: 'response-metadata';
|
|
4963
|
-
} & LanguageModelV4ResponseMetadata);
|
|
4964
|
-
|
|
4965
5051
|
declare const symbol$g: unique symbol;
|
|
4966
5052
|
declare class InvalidStreamPartError extends AISDKError {
|
|
4967
5053
|
private readonly [symbol$g];
|
|
@@ -6863,4 +6949,4 @@ declare global {
|
|
|
6863
6949
|
var AI_SDK_TELEMETRY_INTEGRATIONS: TelemetryIntegration[] | undefined;
|
|
6864
6950
|
}
|
|
6865
6951
|
|
|
6866
|
-
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, CustomContentUIPart, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedOnFinishEvent, EmbedOnStartEvent, 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, ReasoningFileOutput, ReasoningFileUIPart, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankOnFinishEvent, RerankOnStartEvent, 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, ToolLoopAgentOnStartCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentOnStepStartCallback, ToolLoopAgentOnToolCallFinishCallback, ToolLoopAgentOnToolCallStartCallback, 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, isCustomContentUIPart, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningFileUIPart, 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 };
|
|
6952
|
+
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, CustomContentUIPart, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedFinishEvent, EmbedManyResult, EmbedOnFinishEvent, EmbedOnStartEvent, EmbedResult, EmbedStartEvent, 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, ReasoningFileOutput, ReasoningFileUIPart, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankOnFinishEvent, RerankOnStartEvent, 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, ToolLoopAgentOnStartCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentOnStepStartCallback, ToolLoopAgentOnToolCallFinishCallback, ToolLoopAgentOnToolCallStartCallback, 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, streamModelCall as experimental_streamModelCall, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isCustomContentUIPart, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningFileUIPart, 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 };
|