Skip to content

Commit

Permalink
Change regex to allow multi-line inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
terwey committed Jan 31, 2024
1 parent a8f1d95 commit b0e1283
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions agents/markl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ func TestMRKLOutputParser(t *testing.T) {
expectedFinish: nil,
expectedErr: nil,
},
{
input: "Action: foo\nAction Input:\nbar\nbaz",
expectedActions: []schema.AgentAction{{
Tool: "foo",
ToolInput: "bar\nbaz",
Log: "Action: foo\nAction Input:\nbar\nbaz",
}},
expectedFinish: nil,
expectedErr: nil,
},
}

a := OneShotZeroAgent{}
Expand Down
2 changes: 1 addition & 1 deletion agents/mrkl.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (a *OneShotZeroAgent) parseOutput(output string) ([]schema.AgentAction, *sc
}, nil
}

r := regexp.MustCompile(`Action:\s*(.+)\s*Action Input:\s*(.+)`)
r := regexp.MustCompile(`Action:\s*(.+)\s*Action Input:\s(?s)*(.+)`)
matches := r.FindStringSubmatch(output)
if len(matches) == 0 {
return nil, nil, fmt.Errorf("%w: %s", ErrUnableToParseOutput, output)
Expand Down

0 comments on commit b0e1283

Please sign in to comment.