Skip to content

Commit

Permalink
MRKL output parser no longer breaks well formed queries
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 30, 2023
1 parent ee57054 commit f41fa91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion langchain/agents/mrkl/output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ def parse(self, text: str) -> Union[AgentAction, AgentFinish]:
raise OutputParserException(f"Could not parse LLM output: `{text}`")
action = match.group(1).strip()
action_input = match.group(2)
return AgentAction(action, action_input.strip(" ").strip('"'), text)

output = action_input.strip(" ")
# ensure if its a well formed SQL query we don't remove any trailing " chars
if action_input.startswith('SELECT ') is False:
output = output.strip('"')

return AgentAction(action, output, text)

@property
def _type(self) -> str:
Expand Down

0 comments on commit f41fa91

Please sign in to comment.