@xsai/stream-object 0.3.3 → 0.3.5
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.ts +2 -0
- package/dist/index.js +6 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -696,6 +696,8 @@ interface StreamObjectOptions<T extends Schema> extends StreamTextOptions {
|
|
|
696
696
|
schema: T;
|
|
697
697
|
schemaDescription?: string;
|
|
698
698
|
schemaName?: string;
|
|
699
|
+
/** @default true */
|
|
700
|
+
strict?: boolean;
|
|
699
701
|
}
|
|
700
702
|
interface StreamObjectResult<T extends Schema> extends StreamTextResult {
|
|
701
703
|
elementStream?: ReadableStream<Infer<T>>;
|
package/dist/index.js
CHANGED
|
@@ -282,8 +282,9 @@ const toPartialObjectStream = (stream) => {
|
|
|
282
282
|
};
|
|
283
283
|
|
|
284
284
|
async function streamObject(options) {
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
let schema = await toJsonSchema(options.schema);
|
|
286
|
+
if (options.strict !== false)
|
|
287
|
+
schema = strictJsonSchema(schema);
|
|
287
288
|
if (options.output === "array")
|
|
288
289
|
schema = wrap(schema);
|
|
289
290
|
return streamText({
|
|
@@ -293,13 +294,14 @@ async function streamObject(options) {
|
|
|
293
294
|
description: options.schemaDescription,
|
|
294
295
|
name: options.schemaName ?? "json_schema",
|
|
295
296
|
schema,
|
|
296
|
-
strict: true
|
|
297
|
+
strict: options.strict ?? true
|
|
297
298
|
},
|
|
298
299
|
type: "json_schema"
|
|
299
300
|
},
|
|
300
301
|
schema: void 0,
|
|
301
302
|
schemaDescription: void 0,
|
|
302
|
-
schemaName: void 0
|
|
303
|
+
schemaName: void 0,
|
|
304
|
+
strict: void 0
|
|
303
305
|
}).then(({ textStream, ...rest }) => {
|
|
304
306
|
let elementStream;
|
|
305
307
|
let partialObjectStream;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsai/stream-object",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.5",
|
|
5
5
|
"description": "extra-small AI SDK.",
|
|
6
6
|
"author": "Moeru AI",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"xsschema": "~0.3.5",
|
|
33
|
+
"@xsai/stream-text": "~0.3.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@valibot/to-json-schema": "^1.0.0",
|