ai 3.2.19 → 3.2.20
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/dist/index.d.mts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +448 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +448 -126
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
@@ -4,6 +4,7 @@ import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageM
|
|
4
4
|
export { APICallError, EmptyResponseBodyError, InvalidArgumentError, InvalidDataContentError, InvalidPromptError, InvalidResponseDataError, InvalidToolArgumentsError, JSONParseError, LoadAPIKeyError, NoObjectGeneratedError, NoSuchToolError, RetryError, ToolCallParseError, TypeValidationError, UnsupportedFunctionalityError, UnsupportedJSONSchemaError } from '@ai-sdk/provider';
|
5
5
|
import { z } from 'zod';
|
6
6
|
import { ServerResponse } from 'http';
|
7
|
+
import { AttributeValue, Span } from '@opentelemetry/api';
|
7
8
|
import { ServerResponse as ServerResponse$1 } from 'node:http';
|
8
9
|
import { AssistantStream } from 'openai/lib/AssistantStream';
|
9
10
|
import { Run } from 'openai/resources/beta/threads/runs/runs';
|
@@ -921,6 +922,24 @@ declare class InvalidMessageRoleError extends Error {
|
|
921
922
|
};
|
922
923
|
}
|
923
924
|
|
925
|
+
/**
|
926
|
+
* Telemetry configuration.
|
927
|
+
*/
|
928
|
+
type TelemetrySettings = {
|
929
|
+
/**
|
930
|
+
* Enable or disable telemetry. Disabled by default while experimental.
|
931
|
+
*/
|
932
|
+
isEnabled?: boolean;
|
933
|
+
/**
|
934
|
+
* Identifier for this function. Used to group telemetry data by function.
|
935
|
+
*/
|
936
|
+
functionId?: string;
|
937
|
+
/**
|
938
|
+
* Additional information to include in the telemetry data.
|
939
|
+
*/
|
940
|
+
metadata?: Record<string, AttributeValue>;
|
941
|
+
};
|
942
|
+
|
924
943
|
type ToToolCall<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
925
944
|
[NAME in keyof TOOLS]: {
|
926
945
|
type: 'tool-call';
|
@@ -970,7 +989,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
970
989
|
@returns
|
971
990
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
972
991
|
*/
|
973
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, ...settings }: CallSettings & Prompt & {
|
992
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, experimental_telemetry: telemetry, ...settings }: CallSettings & Prompt & {
|
974
993
|
/**
|
975
994
|
The language model to use.
|
976
995
|
*/
|
@@ -1000,6 +1019,10 @@ case of misconfigured tools.
|
|
1000
1019
|
By default, it's set to 0, which will disable the feature.
|
1001
1020
|
*/
|
1002
1021
|
maxToolRoundtrips?: number;
|
1022
|
+
/**
|
1023
|
+
* Optional telemetry configuration (experimental).
|
1024
|
+
*/
|
1025
|
+
experimental_telemetry?: TelemetrySettings;
|
1003
1026
|
}): Promise<GenerateTextResult<TOOLS>>;
|
1004
1027
|
/**
|
1005
1028
|
The result of a `generateText` call.
|
@@ -1109,7 +1132,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1109
1132
|
@return
|
1110
1133
|
A result object for accessing different stream types and additional information.
|
1111
1134
|
*/
|
1112
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: CallSettings & Prompt & {
|
1135
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, onFinish, ...settings }: CallSettings & Prompt & {
|
1113
1136
|
/**
|
1114
1137
|
The language model to use.
|
1115
1138
|
*/
|
@@ -1123,6 +1146,10 @@ The tool choice strategy. Default: 'auto'.
|
|
1123
1146
|
*/
|
1124
1147
|
toolChoice?: CoreToolChoice<TOOLS>;
|
1125
1148
|
/**
|
1149
|
+
* Optional telemetry configuration (experimental).
|
1150
|
+
*/
|
1151
|
+
experimental_telemetry?: TelemetrySettings;
|
1152
|
+
/**
|
1126
1153
|
Callback that is called when the LLM response and all request tool executions
|
1127
1154
|
(for tools that have an `execute` function) are finished.
|
1128
1155
|
*/
|
@@ -1221,13 +1248,15 @@ declare class StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1221
1248
|
*/
|
1222
1249
|
headers?: Record<string, string>;
|
1223
1250
|
};
|
1224
|
-
constructor({ stream, warnings, rawResponse, onFinish, }: {
|
1251
|
+
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, }: {
|
1225
1252
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
1226
1253
|
warnings: CallWarning[] | undefined;
|
1227
1254
|
rawResponse?: {
|
1228
1255
|
headers?: Record<string, string>;
|
1229
1256
|
};
|
1230
1257
|
onFinish?: Parameters<typeof streamText>[0]['onFinish'];
|
1258
|
+
rootSpan: Span;
|
1259
|
+
doStreamSpan: Span;
|
1231
1260
|
});
|
1232
1261
|
/**
|
1233
1262
|
Split out a new stream from the original stream.
|
package/dist/index.d.ts
CHANGED
@@ -4,6 +4,7 @@ import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageM
|
|
4
4
|
export { APICallError, EmptyResponseBodyError, InvalidArgumentError, InvalidDataContentError, InvalidPromptError, InvalidResponseDataError, InvalidToolArgumentsError, JSONParseError, LoadAPIKeyError, NoObjectGeneratedError, NoSuchToolError, RetryError, ToolCallParseError, TypeValidationError, UnsupportedFunctionalityError, UnsupportedJSONSchemaError } from '@ai-sdk/provider';
|
5
5
|
import { z } from 'zod';
|
6
6
|
import { ServerResponse } from 'http';
|
7
|
+
import { AttributeValue, Span } from '@opentelemetry/api';
|
7
8
|
import { ServerResponse as ServerResponse$1 } from 'node:http';
|
8
9
|
import { AssistantStream } from 'openai/lib/AssistantStream';
|
9
10
|
import { Run } from 'openai/resources/beta/threads/runs/runs';
|
@@ -921,6 +922,24 @@ declare class InvalidMessageRoleError extends Error {
|
|
921
922
|
};
|
922
923
|
}
|
923
924
|
|
925
|
+
/**
|
926
|
+
* Telemetry configuration.
|
927
|
+
*/
|
928
|
+
type TelemetrySettings = {
|
929
|
+
/**
|
930
|
+
* Enable or disable telemetry. Disabled by default while experimental.
|
931
|
+
*/
|
932
|
+
isEnabled?: boolean;
|
933
|
+
/**
|
934
|
+
* Identifier for this function. Used to group telemetry data by function.
|
935
|
+
*/
|
936
|
+
functionId?: string;
|
937
|
+
/**
|
938
|
+
* Additional information to include in the telemetry data.
|
939
|
+
*/
|
940
|
+
metadata?: Record<string, AttributeValue>;
|
941
|
+
};
|
942
|
+
|
924
943
|
type ToToolCall<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
925
944
|
[NAME in keyof TOOLS]: {
|
926
945
|
type: 'tool-call';
|
@@ -970,7 +989,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
970
989
|
@returns
|
971
990
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
972
991
|
*/
|
973
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, ...settings }: CallSettings & Prompt & {
|
992
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, experimental_telemetry: telemetry, ...settings }: CallSettings & Prompt & {
|
974
993
|
/**
|
975
994
|
The language model to use.
|
976
995
|
*/
|
@@ -1000,6 +1019,10 @@ case of misconfigured tools.
|
|
1000
1019
|
By default, it's set to 0, which will disable the feature.
|
1001
1020
|
*/
|
1002
1021
|
maxToolRoundtrips?: number;
|
1022
|
+
/**
|
1023
|
+
* Optional telemetry configuration (experimental).
|
1024
|
+
*/
|
1025
|
+
experimental_telemetry?: TelemetrySettings;
|
1003
1026
|
}): Promise<GenerateTextResult<TOOLS>>;
|
1004
1027
|
/**
|
1005
1028
|
The result of a `generateText` call.
|
@@ -1109,7 +1132,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1109
1132
|
@return
|
1110
1133
|
A result object for accessing different stream types and additional information.
|
1111
1134
|
*/
|
1112
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: CallSettings & Prompt & {
|
1135
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, onFinish, ...settings }: CallSettings & Prompt & {
|
1113
1136
|
/**
|
1114
1137
|
The language model to use.
|
1115
1138
|
*/
|
@@ -1123,6 +1146,10 @@ The tool choice strategy. Default: 'auto'.
|
|
1123
1146
|
*/
|
1124
1147
|
toolChoice?: CoreToolChoice<TOOLS>;
|
1125
1148
|
/**
|
1149
|
+
* Optional telemetry configuration (experimental).
|
1150
|
+
*/
|
1151
|
+
experimental_telemetry?: TelemetrySettings;
|
1152
|
+
/**
|
1126
1153
|
Callback that is called when the LLM response and all request tool executions
|
1127
1154
|
(for tools that have an `execute` function) are finished.
|
1128
1155
|
*/
|
@@ -1221,13 +1248,15 @@ declare class StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1221
1248
|
*/
|
1222
1249
|
headers?: Record<string, string>;
|
1223
1250
|
};
|
1224
|
-
constructor({ stream, warnings, rawResponse, onFinish, }: {
|
1251
|
+
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, }: {
|
1225
1252
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
1226
1253
|
warnings: CallWarning[] | undefined;
|
1227
1254
|
rawResponse?: {
|
1228
1255
|
headers?: Record<string, string>;
|
1229
1256
|
};
|
1230
1257
|
onFinish?: Parameters<typeof streamText>[0]['onFinish'];
|
1258
|
+
rootSpan: Span;
|
1259
|
+
doStreamSpan: Span;
|
1231
1260
|
});
|
1232
1261
|
/**
|
1233
1262
|
Split out a new stream from the original stream.
|