ai 3.1.11 → 3.1.13
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 +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +25 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
@@ -3114,6 +3114,31 @@ function mergeStreams(stream1, stream2) {
|
|
3114
3114
|
});
|
3115
3115
|
}
|
3116
3116
|
|
3117
|
+
// streams/stream-to-response.ts
|
3118
|
+
function streamToResponse(res, response, init, data) {
|
3119
|
+
var _a;
|
3120
|
+
response.writeHead((_a = init == null ? void 0 : init.status) != null ? _a : 200, {
|
3121
|
+
"Content-Type": "text/plain; charset=utf-8",
|
3122
|
+
...init == null ? void 0 : init.headers
|
3123
|
+
});
|
3124
|
+
let processedStream = res;
|
3125
|
+
if (data) {
|
3126
|
+
processedStream = mergeStreams(data.stream, res);
|
3127
|
+
}
|
3128
|
+
const reader = processedStream.getReader();
|
3129
|
+
function read() {
|
3130
|
+
reader.read().then(({ done, value }) => {
|
3131
|
+
if (done) {
|
3132
|
+
response.end();
|
3133
|
+
return;
|
3134
|
+
}
|
3135
|
+
response.write(value);
|
3136
|
+
read();
|
3137
|
+
});
|
3138
|
+
}
|
3139
|
+
read();
|
3140
|
+
}
|
3141
|
+
|
3117
3142
|
// shared/parse-complex-response.ts
|
3118
3143
|
function assignAnnotationsToMessage(message, annotations) {
|
3119
3144
|
if (!message || !annotations || !annotations.length)
|
@@ -3318,24 +3343,6 @@ var StreamingTextResponse = class extends Response {
|
|
3318
3343
|
});
|
3319
3344
|
}
|
3320
3345
|
};
|
3321
|
-
function streamToResponse(res, response, init) {
|
3322
|
-
response.writeHead((init == null ? void 0 : init.status) || 200, {
|
3323
|
-
"Content-Type": "text/plain; charset=utf-8",
|
3324
|
-
...init == null ? void 0 : init.headers
|
3325
|
-
});
|
3326
|
-
const reader = res.getReader();
|
3327
|
-
function read() {
|
3328
|
-
reader.read().then(({ done, value }) => {
|
3329
|
-
if (done) {
|
3330
|
-
response.end();
|
3331
|
-
return;
|
3332
|
-
}
|
3333
|
-
response.write(value);
|
3334
|
-
read();
|
3335
|
-
});
|
3336
|
-
}
|
3337
|
-
read();
|
3338
|
-
}
|
3339
3346
|
export {
|
3340
3347
|
AIStream,
|
3341
3348
|
APICallError2 as APICallError,
|