Skip to content

Commit 6cf46ef

Browse files
committed
revert OBJECT back to ELEMENT
1 parent 7b3d1f2 commit 6cf46ef

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/ai/core/generate-object/output-strategy.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ const objectOutputStrategy = <OBJECT>(
134134
},
135135
});
136136

137-
const arrayOutputStrategy = <OBJECT>(
138-
schema: Schema<OBJECT>,
137+
const arrayOutputStrategy = <ELEMENT>(
138+
schema: Schema<ELEMENT>,
139139
): OutputStrategy<
140-
OBJECT[],
141-
OBJECT[],
142-
AsyncIterableStream<OBJECT>
140+
ELEMENT[],
141+
ELEMENT[],
142+
AsyncIterableStream<ELEMENT>
143143
> => {
144144
// remove $schema from schema.jsonSchema:
145145
const { $schema, ...itemSchema } = schema.jsonSchema;
@@ -178,7 +178,7 @@ const arrayOutputStrategy = <OBJECT>(
178178
}
179179

180180
const inputArray = value.elements as Array<JSONObject>;
181-
const resultArray: Array<OBJECT> = [];
181+
const resultArray: Array<ELEMENT> = [];
182182

183183
for (let i = 0; i < inputArray.length; i++) {
184184
const element = inputArray[i];
@@ -233,7 +233,7 @@ const arrayOutputStrategy = <OBJECT>(
233233
async validateFinalResult(
234234
value: JSONValue | undefined,
235235
): Promise<
236-
ValidationResult<Array<OBJECT>>
236+
ValidationResult<Array<ELEMENT>>
237237
> {
238238
// check that the value is an object that contains an array of elements:
239239
if (!isJSONObject(value) || !isJSONArray(value.elements)) {
@@ -258,22 +258,22 @@ const arrayOutputStrategy = <OBJECT>(
258258

259259
return {
260260
success: true,
261-
value: inputArray as Array<OBJECT>,
261+
value: inputArray as Array<ELEMENT>,
262262
};
263263
},
264264

265265
createElementStream(
266266
originalStream: ReadableStream<
267-
ObjectStreamPart<OBJECT[]>
267+
ObjectStreamPart<ELEMENT[]>
268268
>,
269269
) {
270270
let publishedElements = 0;
271271

272272
return createAsyncIterableStream(
273273
originalStream.pipeThrough(
274274
new TransformStream<
275-
ObjectStreamPart<OBJECT[]>,
276-
OBJECT
275+
ObjectStreamPart<ELEMENT[]>,
276+
ELEMENT
277277
>({
278278
transform(chunk, controller) {
279279
switch (chunk.type) {

0 commit comments

Comments
 (0)