ai 3.3.33 → 3.3.35
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 +22 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +22 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -8
- package/rsc/dist/rsc-server.mjs +10 -3
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/test/dist/index.d.mts +42 -0
- package/test/dist/index.d.ts +42 -0
- package/test/dist/index.js +98 -0
- package/test/dist/index.js.map +1 -0
- package/test/dist/index.mjs +69 -0
- package/test/dist/index.mjs.map +1 -0
package/dist/index.mjs
CHANGED
@@ -4112,8 +4112,9 @@ var DefaultStreamTextResult = class {
|
|
4112
4112
|
}
|
4113
4113
|
toDataStreamInternal({
|
4114
4114
|
callbacks = {},
|
4115
|
-
getErrorMessage: getErrorMessage4 = () => ""
|
4115
|
+
getErrorMessage: getErrorMessage4 = () => "",
|
4116
4116
|
// mask error messages for safety by default
|
4117
|
+
sendUsage = true
|
4117
4118
|
} = {}) {
|
4118
4119
|
let aggregatedResponse = "";
|
4119
4120
|
const callbackTransformer = new TransformStream({
|
@@ -4188,10 +4189,10 @@ var DefaultStreamTextResult = class {
|
|
4188
4189
|
controller.enqueue(
|
4189
4190
|
formatStreamPart("finish_roundtrip", {
|
4190
4191
|
finishReason: chunk.finishReason,
|
4191
|
-
usage: {
|
4192
|
+
usage: sendUsage ? {
|
4192
4193
|
promptTokens: chunk.usage.promptTokens,
|
4193
4194
|
completionTokens: chunk.usage.completionTokens
|
4194
|
-
}
|
4195
|
+
} : void 0
|
4195
4196
|
})
|
4196
4197
|
);
|
4197
4198
|
break;
|
@@ -4199,10 +4200,10 @@ var DefaultStreamTextResult = class {
|
|
4199
4200
|
controller.enqueue(
|
4200
4201
|
formatStreamPart("finish_message", {
|
4201
4202
|
finishReason: chunk.finishReason,
|
4202
|
-
usage: {
|
4203
|
+
usage: sendUsage ? {
|
4203
4204
|
promptTokens: chunk.usage.promptTokens,
|
4204
4205
|
completionTokens: chunk.usage.completionTokens
|
4205
|
-
}
|
4206
|
+
} : void 0
|
4206
4207
|
})
|
4207
4208
|
);
|
4208
4209
|
break;
|
@@ -4226,6 +4227,7 @@ var DefaultStreamTextResult = class {
|
|
4226
4227
|
};
|
4227
4228
|
const data = options == null ? void 0 : "data" in options ? options.data : void 0;
|
4228
4229
|
const getErrorMessage4 = options == null ? void 0 : "getErrorMessage" in options ? options.getErrorMessage : void 0;
|
4230
|
+
const sendUsage = options == null ? void 0 : "sendUsage" in options ? options.sendUsage : void 0;
|
4229
4231
|
writeToServerResponse({
|
4230
4232
|
response,
|
4231
4233
|
status: init == null ? void 0 : init.status,
|
@@ -4234,7 +4236,7 @@ var DefaultStreamTextResult = class {
|
|
4234
4236
|
contentType: "text/plain; charset=utf-8",
|
4235
4237
|
dataStreamVersion: "v1"
|
4236
4238
|
}),
|
4237
|
-
stream: this.toDataStream({ data, getErrorMessage: getErrorMessage4 })
|
4239
|
+
stream: this.toDataStream({ data, getErrorMessage: getErrorMessage4, sendUsage })
|
4238
4240
|
});
|
4239
4241
|
}
|
4240
4242
|
pipeTextStreamToResponse(response, init) {
|
@@ -4253,7 +4255,8 @@ var DefaultStreamTextResult = class {
|
|
4253
4255
|
}
|
4254
4256
|
toDataStream(options) {
|
4255
4257
|
const stream = this.toDataStreamInternal({
|
4256
|
-
getErrorMessage: options == null ? void 0 : options.getErrorMessage
|
4258
|
+
getErrorMessage: options == null ? void 0 : options.getErrorMessage,
|
4259
|
+
sendUsage: options == null ? void 0 : options.sendUsage
|
4257
4260
|
});
|
4258
4261
|
return (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;
|
4259
4262
|
}
|
@@ -4266,14 +4269,18 @@ var DefaultStreamTextResult = class {
|
|
4266
4269
|
};
|
4267
4270
|
const data = options == null ? void 0 : "data" in options ? options.data : void 0;
|
4268
4271
|
const getErrorMessage4 = options == null ? void 0 : "getErrorMessage" in options ? options.getErrorMessage : void 0;
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4272
|
+
const sendUsage = options == null ? void 0 : "sendUsage" in options ? options.sendUsage : void 0;
|
4273
|
+
return new Response(
|
4274
|
+
this.toDataStream({ data, getErrorMessage: getErrorMessage4, sendUsage }),
|
4275
|
+
{
|
4276
|
+
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
4277
|
+
statusText: init == null ? void 0 : init.statusText,
|
4278
|
+
headers: prepareResponseHeaders(init, {
|
4279
|
+
contentType: "text/plain; charset=utf-8",
|
4280
|
+
dataStreamVersion: "v1"
|
4281
|
+
})
|
4282
|
+
}
|
4283
|
+
);
|
4277
4284
|
}
|
4278
4285
|
toTextStreamResponse(init) {
|
4279
4286
|
var _a11;
|