forked from tmc/langchaingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkl_test.go
48 lines (43 loc) · 1.06 KB
/
markl_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package agents
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tmc/langchaingo/schema"
)
func TestMRKLOutputParser(t *testing.T) {
t.Parallel()
testCases := []struct {
input string
expectedActions []schema.AgentAction
expectedFinish *schema.AgentFinish
expectedErr error
}{
{
input: "Action: foo Action Input: bar",
expectedActions: []schema.AgentAction{{
Tool: "foo",
ToolInput: "bar",
Log: "Action: foo Action Input: bar",
}},
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{}
for _, tc := range testCases {
actions, finish, err := a.parseOutput(tc.input)
require.ErrorIs(t, tc.expectedErr, err)
require.Equal(t, tc.expectedActions, actions)
require.Equal(t, tc.expectedFinish, finish)
}
}