Files
langchain/tests/unit_tests
Junlin Zhou 5f17c57174 Update chat agents' output parser to extract action by regex (#7511)
Currently `ChatOutputParser` extracts actions by splitting the text on
"```", and then load the second part as a json string.

But sometimes the LLM will wrap the action in markdown code block like:

````markdown
```json
{
  "action": "foo",
  "action_input": "bar"
}
```
````

Splitting text on "```" will cause `OutputParserException` in such case.

This PR changes the behaviour to extract the `$JSON_BLOB` by regex, so
that it can handle both ` ``` ``` ` and ` ```json ``` `

@hinthornw

---------

Co-authored-by: Junlin Zhou <jlzhou@zjuici.com>
2023-07-12 03:12:02 -04:00
..
2023-06-16 11:52:56 -07:00
2023-07-01 13:39:19 -04:00
2023-05-19 15:27:50 -07:00
2022-10-24 14:51:15 -07:00
2023-05-22 16:43:07 -07:00
2023-07-07 11:05:09 -07:00
2022-10-24 14:51:15 -07:00