You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// =========== build chain ===========
chain := compose.NewChain[map[string]any, string]()
chain.
AppendLambda(compose.InvokableLambda(func(ctx context.Context, kvs map[string]any) (map[string]any, error) {
// do some logic to prepare kv as input val for next node
// just pass through
logs.Infof("in view lambda: %v", kvs)
return kvs, nil
})).
AppendBranch(compose.NewChainBranch(branchCond).AddLambda("b1", b1).AddLambda("b2", b2)). // nolint: byted_use_receiver_without_nilcheck
AppendPassthrough().
AppendParallel(parallel).
AppendGraph(rolePlayerChain).
AppendLambda(compose.InvokableLambda(func(ctx context.Context, m *schema.Message) (string, error) {
// do some logic to check the output or something
logs.Infof("in view of messages: %v", m.Content)
return m.Content, nil
}))
Why is AppendPassthrough() needed at this point? Because I think the branch selects one node's output, and Parallel is also a single node overall, and the outputs of b1/b2 are consistent with the input of Parallel, why is AppendPassthrough still needed? Why can't it be connected directly? When is AppendPassthrough() necessary?
The text was updated successfully, but these errors were encountered:
The reason is that Chain is a simplified wrapper of Graph. When encapsulating Graph's multiple node into a parallel node into AppendParallel, to avoid complexity, it temporarily supports only one predecessor node.
In the future, support for multiple predecessor nodes can be added as needed.
Since the BranchNode has multiple branch nodes, a PassthroughNode is added after the BranchNode to bypass the limitation of the ParallelNode on the number of predecessor nodes.
Thank you for pointing out the issue, and we would also love to hear your thoughts and suggestions~
Why is AppendPassthrough() needed at this point? Because I think the branch selects one node's output, and Parallel is also a single node overall, and the outputs of b1/b2 are consistent with the input of Parallel, why is AppendPassthrough still needed? Why can't it be connected directly? When is AppendPassthrough() necessary?
The text was updated successfully, but these errors were encountered: