fix: unwrap the json fence when streaming in schema-less JSON mode - #6
Open
Abhishek-B-R wants to merge 1 commit into
Open
Abhishek-B-R wants to merge 1 commit into
Abhishek-B-R wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
doGenerate strips the
```jsonfence Interfaze puts around json_object output, but doStream didn't. so streamText with Output.json() never produced a partial object andawait outputthrew NoObjectGeneratedError, while generateText with the same arguments worked fine. that's the combination the run tasks docs show for the AI SDK.this adds a small streaming version of stripJsonFence. it only holds text back while it can't yet tell whether a fence is opening or closing (the first few chars, and trailing whitespace or backticks), so partial JSON still streams as it arrives. it only runs in the same mode doGenerate unwraps (json, no schema).
tests: a fixture with the fence split across chunks, doStream in both modes, an end to end streamText + Output.json() case, and unit tests for the filter. the two new stream tests fail on main; all 86 pass with the fix. type-check, prettier, build and check:pkg are clean.