6
6
"fmt"
7
7
"strings"
8
8
9
- "github.com/tmc/langchaingo/internal/util"
9
+ "github.com/tmc/langchaingo/internal/maputil"
10
+ "github.com/tmc/langchaingo/internal/setutil"
10
11
"github.com/tmc/langchaingo/memory"
11
12
"github.com/tmc/langchaingo/schema"
12
13
)
@@ -42,11 +43,11 @@ func NewSequentialChain(chains []Chain, inputKeys []string, outputKeys []string,
42
43
}
43
44
44
45
func (c * SequentialChain ) validateSeqChain () error {
45
- knownKeys := util .ToSet (c .inputKeys )
46
+ knownKeys := setutil .ToSet (c .inputKeys )
46
47
47
48
// Make sure memory keys don't collide with input keys
48
49
memoryKeys := c .memory .MemoryVariables (context .Background ())
49
- overlappingKeys := util .Intersection (memoryKeys , knownKeys )
50
+ overlappingKeys := setutil .Intersection (memoryKeys , knownKeys )
50
51
if len (overlappingKeys ) > 0 {
51
52
return fmt .Errorf (
52
53
"%w: input keys [%v] also exist in the memory keys: [%v] - please use input keys and memory keys that don't overlap" ,
@@ -61,16 +62,16 @@ func (c *SequentialChain) validateSeqChain() error {
61
62
62
63
for i , c := range c .chains {
63
64
// Check that chain has input keys that are in knownKeys
64
- missingKeys := util .Difference (c .GetInputKeys (), knownKeys )
65
+ missingKeys := setutil .Difference (c .GetInputKeys (), knownKeys )
65
66
if len (missingKeys ) > 0 {
66
67
return fmt .Errorf (
67
68
"%w: missing required input keys: [%v], only had: [%v]" ,
68
- ErrChainInitialization , strings .Join (missingKeys , delimiter ), strings .Join (util .ListKeys (knownKeys ), delimiter ),
69
+ ErrChainInitialization , strings .Join (missingKeys , delimiter ), strings .Join (maputil .ListKeys (knownKeys ), delimiter ),
69
70
)
70
71
}
71
72
72
73
// Check that chain does not have output keys that are already in knownKeys
73
- overlappingKeys := util .Intersection (c .GetOutputKeys (), knownKeys )
74
+ overlappingKeys := setutil .Intersection (c .GetOutputKeys (), knownKeys )
74
75
if len (overlappingKeys ) > 0 {
75
76
return fmt .Errorf (
76
77
"%w: chain at index %d has output keys that already exist: %v" ,
0 commit comments