Skip to content
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

fix: structured output parser #7144

Closed
wants to merge 4 commits into from

Conversation

anadi45
Copy link
Contributor

@anadi45 anadi45 commented Nov 3, 2024

Fixes #(6734)

  1. Capture JSON object using outer curly brackets.
  2. Fix existing integration tests

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 3, 2024
Copy link

vercel bot commented Nov 3, 2024

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

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Nov 5, 2024 9:08am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Nov 5, 2024 9:08am

@anadi45 anadi45 changed the title Anadi45/str out parser fix: structured output parser Nov 3, 2024
@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Nov 3, 2024
@jacoblee93
Copy link
Collaborator

jacoblee93 commented Nov 5, 2024

Hey @anadi45, thanks for this!

Am a bit nervous about swapping this out wholesale since LLMs could perhaps output curly braces in other contexts and I wouldn't want to break anyone depending on the old behavior - what is the issue you are encountering?

At minimum this needs a lot more unit tests.

@jacoblee93 jacoblee93 added the hold On hold label Nov 5, 2024
@anadi45
Copy link
Contributor Author

anadi45 commented Nov 12, 2024

Hi @jacoblee93, thank you so much for the review! I'm new to open source and wanted to contribute to LangChain since we use it at our organization. I chose this issue as a starting point where the parser currently breaks if there are nested triple backticks.

I agree that changing the parsing logic entirely could be risky. To maintain backward compatibility, I could incorporate my logic within a catch block, and only throw an error if both approaches fail. I’ll also explore alternative ways to handle this issue.

If you have any other suggestions, I’d be happy to incorporate them! Regardless, I'll add more test cases to cover these scenarios.

@jacoblee93
Copy link
Collaborator

Hey @anadi45, sounds good - please ping again when ready.

@anadi45
Copy link
Contributor Author

anadi45 commented Nov 19, 2024

@jacoblee93 should I close this? Looks like #7199 already solved this issue.

@anadi45 anadi45 closed this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature hold On hold size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants