allow optional newline in the action responses of JSON Agent parser (#17186)

Based on my experiments, the newline isn't always there, so we can make
the regex slightly more robust by allowing an optional newline after the
bacticks
This commit is contained in:
Tomaz Bratanic 2024-02-07 19:26:14 +01:00 committed by GitHub
parent 9fa07076da
commit 302989a2b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,7 +42,7 @@ class ReActJsonSingleInputOutputParser(AgentOutputParser):
"""
pattern = re.compile(r"^.*?`{3}(?:json)?\n(.*?)`{3}.*?$", re.DOTALL)
pattern = re.compile(r"^.*?`{3}(?:json)?\n?(.*?)`{3}.*?$", re.DOTALL)
"""Regex pattern to parse the output."""
def get_format_instructions(self) -> str: