-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
fixed json parsing for multiple generated JSON code segments, plus co… #5037
fixed json parsing for multiple generated JSON code segments, plus co… #5037
Conversation
Can someone approve this workflow at least? This is an incredibly important fix. @hwchase17 |
I also have many failed runs like #2679 . My agent sometimes returns:
Instead of:
|
I guess the issue with the LLM-generated code is not fixed yet. 2023-05-22 14:16:40.713 Uncaught app exception The above exception was the direct cause of the following exception: Traceback (most recent call last): |
Sorry, I just saw that the fix is not in release 0.0.176 yet. |
Can we please approve the workflow - or is there something else needed to proceed? (this is my first pull request, so happy to adjust as appropriate). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - lets adds some tests for things that this can handle so we don't have any regressions in the future
Resolved Black code formatting issue. If additional testers are needed, please advise specifics (e.g., which one to modify or a good example to copy/modify) |
Happy to do so. Can you point me to existing tester you'd suggest that I update? |
don't think any unit tests exist for this class yet, would make a new file at |
I have submitted the fix again, this time addressing the "ruff" code format issues. I have no idea where to start to develop the unit tester... |
Figured it out. Will deliver unit tester soon... |
Okay. Unit tester is now available. |
How should we handle OPEN API keys? _ ERROR collecting tests/unit_tests/agents/conversational_chat/test_output_parser.py _ |
tests/unit_tests/agents/conversational_chat/test_output_parser.py
Outdated
Show resolved
Hide resolved
tests/unit_tests/agents/conversational_chat/test_output_parser.py
Outdated
Show resolved
Hide resolved
The unit tester has been rewritten in accordance with the recommendations. Please re-run the workflow. |
Not sure why the latest commit is a conflict. The entire file was rewritten to replace the prior commit. |
Do the tests cover cases with nested triple backticks ? langchain.schema.OutputParserException: Could not parse LLM output: ```json I wonder how the function
removes all triple backticks, whereas the backticks in action_input should be preserved as they are part of the markdown. |
Yes, it covers the case where code gets returned within the JSON string, starting with triple backticks and followed by type of code... as shown in the working unit tester. |
Who should resolve the conflicts that have cropped up? |
Sorry, I could not see this nested case in the unit tester. |
It was this nested case, where '''python or '''javascript get returned when code is generated that caused the original issues with the output parser. This is what was fixed and why the unit tester was developed to test the code/no-code return cases. I actually added logging to the output parser, captured actual returned code and non-code parser examples, then included those in the unit tester, to ensure they are correctly structured. Please let me know if further refinements are needed to merge. Thanks |
I just tested with langchain version 0.0.184 and the parsing of code blocks including triple backticks fails, see error below: File "/home/user1/scratch/conda/envs/lcpy39/lib/python3.9/site-packages/langchain/agents/conversational_chat/output_parser.py", line 24, in parse |
Clearly this needs more rework... |
Fixes showstopper issue with parsing LLM-generated code that returns one or multiple code segments in JSON format
Fixes # (issue)
Before submitting
Who can review?
Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: