ai 3.2.1 → 3.2.2
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -528,6 +528,16 @@ function injectJsonSchemaIntoSystem({
|
|
528
528
|
].filter((line) => line != null).join("\n");
|
529
529
|
}
|
530
530
|
|
531
|
+
// core/util/prepare-response-headers.ts
|
532
|
+
function prepareResponseHeaders(init, { contentType }) {
|
533
|
+
var _a;
|
534
|
+
const headers = new Headers((_a = init == null ? void 0 : init.headers) != null ? _a : {});
|
535
|
+
if (!headers.has("Content-Type")) {
|
536
|
+
headers.set("Content-Type", contentType);
|
537
|
+
}
|
538
|
+
return headers;
|
539
|
+
}
|
540
|
+
|
531
541
|
// core/generate-object/generate-object.ts
|
532
542
|
async function generateObject({
|
533
543
|
model,
|
@@ -670,6 +680,19 @@ var GenerateObjectResult = class {
|
|
670
680
|
this.rawResponse = options.rawResponse;
|
671
681
|
this.logprobs = options.logprobs;
|
672
682
|
}
|
683
|
+
/**
|
684
|
+
Converts the object to a JSON response.
|
685
|
+
The response will have a status code of 200 and a content type of `application/json; charset=utf-8`.
|
686
|
+
*/
|
687
|
+
toJsonResponse(init) {
|
688
|
+
var _a;
|
689
|
+
return new Response(JSON.stringify(this.object), {
|
690
|
+
status: (_a = init == null ? void 0 : init.status) != null ? _a : 200,
|
691
|
+
headers: prepareResponseHeaders(init, {
|
692
|
+
contentType: "application/json; charset=utf-8"
|
693
|
+
})
|
694
|
+
});
|
695
|
+
}
|
673
696
|
};
|
674
697
|
var experimental_generateObject = generateObject;
|
675
698
|
|
@@ -697,16 +720,6 @@ function createAsyncIterableStream(source, transformer) {
|
|
697
720
|
return transformedStream;
|
698
721
|
}
|
699
722
|
|
700
|
-
// core/util/prepare-response-headers.ts
|
701
|
-
function prepareResponseHeaders(init, { contentType }) {
|
702
|
-
var _a;
|
703
|
-
const headers = new Headers((_a = init == null ? void 0 : init.headers) != null ? _a : {});
|
704
|
-
if (!headers.has("Content-Type")) {
|
705
|
-
headers.set("Content-Type", contentType);
|
706
|
-
}
|
707
|
-
return headers;
|
708
|
-
}
|
709
|
-
|
710
723
|
// core/generate-object/stream-object.ts
|
711
724
|
async function streamObject({
|
712
725
|
model,
|
@@ -1032,6 +1045,7 @@ var StreamObjectResult = class {
|
|
1032
1045
|
}
|
1033
1046
|
/**
|
1034
1047
|
Creates a simple text stream response.
|
1048
|
+
The response has a `Content-Type` header set to `text/plain; charset=utf-8`.
|
1035
1049
|
Each text delta is encoded as UTF-8 and sent as a separate chunk.
|
1036
1050
|
Non-text-delta events are ignored.
|
1037
1051
|
|