mirror of https://github.com/hwchase17/langchain
Add context to an output parsing error on Pydantic schema to improve exception handling (#7344)
## Changes - [X] Fill the `llm_output` param when there is an output parsing error in a Pydantic schema so that we can get the original text that failed to parse when handling the exception ## Background With this change, we could do something like this: ``` output_parser = PydanticOutputParser(pydantic_object=pydantic_obj) chain = ConversationChain(..., output_parser=output_parser) try: response: PydanticSchema = chain.predict(input=input) except OutputParserException as exc: logger.error( 'OutputParserException while parsing chatbot response: %s', exc.llm_output, ) ``` --------- Co-authored-by: Bagatur <baskaryan@gmail.com>pull/7377/head
parent
1ac6deda89
commit
01dca1e438
Loading…
Reference in New Issue