-
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
Update Conversational Chat output_parser.py to support more final response cases #4539
Update Conversational Chat output_parser.py to support more final response cases #4539
Conversation
…rsonality while doing it
…h Option 1 included non-markdown. added a notebook to execute this.
response = json.loads(cleaned_output) | ||
try: | ||
response = json.loads(cleaned_output) | ||
except: # Response isn't JSON! |
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.
It's considered bad practice to 'catch the universal Exception
. JSON decoder errors will typically return a ValueError
, which includes the JSONDecodeError
child class.
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.
lets add test cases for this
good idea. where's the best place to put them? |
…added better exception handling.
@hwchase17 added a test for output_parser, but wasn't sure where to put it so for now just dumped it into the same directory. please let me know where to move it. i merged with the latest release on master and also added a specific exception for JSON decoding. it is slightly opinionated because it assumes the developer wants to see an output if tokens get exhausted or if the completion responds without any markdown which in my experience only happens when it is the final answer. |
stale, @treppers feel free to ping if you return to it |
In heavily utilizing the conversational chat agent, I found that it didn't account for the many potential outputs that the agent could respond with.
The use-cases this now supports are:
json
after the markdown escapeFixes # 2567
Fixes # 3448
Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested:
@hwchase17
@mbchang