Skip to content

feat(core): allow JsonOutputParser to stream markdown JSON #8091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RUPOJS
Copy link

@RUPOJS RUPOJS commented Apr 29, 2025

Updates parseJsonMarkdown to correctly extract and parse JSON content from markdown code blocks during streaming, even with incomplete fences or surrounding text. Adjusts tests to reflect accurate streaming behavior.

Fixes #8068

Updates parseJsonMarkdown to correctly extract and parse JSON content
from markdown code blocks during streaming, even with incomplete fences
or surrounding text. Adjusts tests to reflect accurate streaming behavior.

Fixes langchain-ai#8068
Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Apr 30, 2025 6:50am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Apr 30, 2025 6:50am

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. auto:improvement Medium size change to existing code to handle new use-cases labels Apr 29, 2025
Copy link
Collaborator

@benjamincburns benjamincburns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for the submission! Will merge provided CI checks pass.

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Apr 30, 2025
@benjamincburns
Copy link
Collaborator

Not sure why that one test keeps failing. I'm afraid that I'll need to investigate on another day.

@RUPOJS
Copy link
Author

RUPOJS commented Apr 30, 2025

Hi @benjamincburns,

Thanks for the review and for the quick fix to the test file! 🙏.

From the CI logs it looks like the failures are coming from convertToConverseMessages in @langchain/aws, which seems unrelated to the changes in this PR. My best guess is that the function builds its payload from the raw messages array instead of the output from mergeMessageRuns(messages), so consecutive same-role messages aren’t merged and the shared test fails.

I haven’t confirmed this 100 percent, but wanted to flag it. I’m happy to dive in and patch it if that would help—just let me know.

Also, please let me know if you spot anything else!

@benjamincburns
Copy link
Collaborator

Yeah, it was due to an unrelated PR that broke the build. CI should be green now. Will merge now but likely will release tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases lgtm PRs that are ready to be merged as-is size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Make JsonOutputParser able to extract JSON from markdown output
2 participants