ai 3.0.25 → 3.0.27
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 +33 -29
- package/dist/index.d.ts +33 -29
- package/dist/index.js +33 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -202,13 +202,6 @@ function prepareCallSettings({
|
|
202
202
|
message: "temperature must be a number"
|
203
203
|
});
|
204
204
|
}
|
205
|
-
if (temperature < 0 || temperature > 1) {
|
206
|
-
throw new InvalidArgumentError({
|
207
|
-
parameter: "temperature",
|
208
|
-
value: temperature,
|
209
|
-
message: "temperature must be between 0 and 1 (inclusive)"
|
210
|
-
});
|
211
|
-
}
|
212
205
|
}
|
213
206
|
if (topP != null) {
|
214
207
|
if (typeof topP !== "number") {
|
@@ -218,13 +211,6 @@ function prepareCallSettings({
|
|
218
211
|
message: "topP must be a number"
|
219
212
|
});
|
220
213
|
}
|
221
|
-
if (topP < 0 || topP > 1) {
|
222
|
-
throw new InvalidArgumentError({
|
223
|
-
parameter: "topP",
|
224
|
-
value: topP,
|
225
|
-
message: "topP must be between 0 and 1 (inclusive)"
|
226
|
-
});
|
227
|
-
}
|
228
214
|
}
|
229
215
|
if (presencePenalty != null) {
|
230
216
|
if (typeof presencePenalty !== "number") {
|
@@ -234,13 +220,6 @@ function prepareCallSettings({
|
|
234
220
|
message: "presencePenalty must be a number"
|
235
221
|
});
|
236
222
|
}
|
237
|
-
if (presencePenalty < -1 || presencePenalty > 1) {
|
238
|
-
throw new InvalidArgumentError({
|
239
|
-
parameter: "presencePenalty",
|
240
|
-
value: presencePenalty,
|
241
|
-
message: "presencePenalty must be between -1 and 1 (inclusive)"
|
242
|
-
});
|
243
|
-
}
|
244
223
|
}
|
245
224
|
if (frequencyPenalty != null) {
|
246
225
|
if (typeof frequencyPenalty !== "number") {
|
@@ -250,13 +229,6 @@ function prepareCallSettings({
|
|
250
229
|
message: "frequencyPenalty must be a number"
|
251
230
|
});
|
252
231
|
}
|
253
|
-
if (frequencyPenalty < -1 || frequencyPenalty > 1) {
|
254
|
-
throw new InvalidArgumentError({
|
255
|
-
parameter: "frequencyPenalty",
|
256
|
-
value: frequencyPenalty,
|
257
|
-
message: "frequencyPenalty must be between -1 and 1 (inclusive)"
|
258
|
-
});
|
259
|
-
}
|
260
232
|
}
|
261
233
|
if (seed != null) {
|
262
234
|
if (!Number.isInteger(seed)) {
|
@@ -1420,11 +1392,43 @@ var StreamTextResult = class {
|
|
1420
1392
|
return this.textStream.pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(createStreamDataTransformer());
|
1421
1393
|
}
|
1422
1394
|
/**
|
1395
|
+
Writes stream data output to a Node.js response-like object.
|
1396
|
+
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
1397
|
+
writes each text delta as a separate chunk.
|
1398
|
+
|
1399
|
+
@param response A Node.js response-like object (ServerResponse).
|
1400
|
+
@param init Optional headers and status code.
|
1401
|
+
*/
|
1402
|
+
pipeAIStreamToResponse(response, init) {
|
1403
|
+
var _a;
|
1404
|
+
response.writeHead((_a = init == null ? void 0 : init.status) != null ? _a : 200, {
|
1405
|
+
"Content-Type": "text/plain; charset=utf-8",
|
1406
|
+
...init == null ? void 0 : init.headers
|
1407
|
+
});
|
1408
|
+
const reader = this.textStream.pipeThrough(createCallbacksTransformer(void 0)).pipeThrough(createStreamDataTransformer()).getReader();
|
1409
|
+
const read = async () => {
|
1410
|
+
try {
|
1411
|
+
while (true) {
|
1412
|
+
const { done, value } = await reader.read();
|
1413
|
+
if (done)
|
1414
|
+
break;
|
1415
|
+
response.write(value);
|
1416
|
+
}
|
1417
|
+
} catch (error) {
|
1418
|
+
throw error;
|
1419
|
+
} finally {
|
1420
|
+
response.end();
|
1421
|
+
}
|
1422
|
+
};
|
1423
|
+
read();
|
1424
|
+
}
|
1425
|
+
/**
|
1423
1426
|
Creates a simple text stream response.
|
1424
1427
|
Each text delta is encoded as UTF-8 and sent as a separate chunk.
|
1425
1428
|
Non-text-delta events are ignored.
|
1426
1429
|
*/
|
1427
1430
|
toTextStreamResponse(init) {
|
1431
|
+
var _a;
|
1428
1432
|
const encoder = new TextEncoder();
|
1429
1433
|
return new Response(
|
1430
1434
|
this.textStream.pipeThrough(
|
@@ -1435,8 +1439,7 @@ var StreamTextResult = class {
|
|
1435
1439
|
})
|
1436
1440
|
),
|
1437
1441
|
{
|
1438
|
-
|
1439
|
-
status: 200,
|
1442
|
+
status: (_a = init == null ? void 0 : init.status) != null ? _a : 200,
|
1440
1443
|
headers: {
|
1441
1444
|
"Content-Type": "text/plain; charset=utf-8",
|
1442
1445
|
...init == null ? void 0 : init.headers
|