chore(json): only print warning after stream finished
This commit is contained in:
@ -70,14 +70,13 @@ export async function* parseStreamingJson<T extends z.ZodType>(
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
value: parsed.value as DeepPartial<z.infer<T>>,
|
value: parsed.value as DeepPartial<z.infer<T>>,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.debug(`Failed to parse JSON: ${removeJsonMarkdown(rawText)}`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the last chunk parses failed, return an error
|
// If the last chunk parses failed, return an error
|
||||||
if (!isParseSuccessful) {
|
if (!isParseSuccessful) {
|
||||||
|
console.warn(`[parseStreamingJson] Failed to parse JSON: ${removeJsonMarkdown(rawText)}`)
|
||||||
yield {
|
yield {
|
||||||
type: 'bad-end',
|
type: 'bad-end',
|
||||||
rawText,
|
rawText,
|
||||||
|
Reference in New Issue
Block a user