Skip to content

Commit

Permalink
allow optional newline in the action responses of JSON Agent parser (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
tomasonjo authored Feb 7, 2024
1 parent 9fa0707 commit 302989a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 302989a

Please sign in to comment.