refactor: remove unused chain variables in example 1

Change-Id: I1fcd725de100d42d7c496fb3ea2e8701c72af42f
drew/english
shentong.martin 4 months ago committed by shentongmartin
parent c5df2f12e4
commit a05f4e9a5d

@ -64,40 +64,6 @@ The summary should flow naturally and capture the essence of the original conten
Create a summary in approximately {max_words} words:`))
chain := compose.NewChain[map[string]any, *SummarizeOutput]()
chain.
AppendChatTemplate(extractKeyPointsPrompt).
AppendChatModel(cm).
AppendLambda(compose.InvokableLambda(func(ctx context.Context, msg *schema.Message) (map[string]any, error) {
return map[string]any{
"key_points": msg.Content,
"max_words": ctx.Value("max_words"),
}, nil
})).
AppendChatTemplate(condenseSummaryPrompt).
AppendChatModel(cm).
AppendLambda(compose.InvokableLambda(func(ctx context.Context, msg *schema.Message) (*SummarizeOutput, error) {
keyPoints := ctx.Value("key_points_list").([]string)
return &SummarizeOutput{
Summary: msg.Content,
KeyPoints: keyPoints,
WordCount: countWords(msg.Content),
}, nil
}))
inputTransformChain := compose.NewChain[*SummarizeInput, map[string]any]()
inputTransformChain.AppendLambda(compose.InvokableLambda(func(ctx context.Context, input *SummarizeInput) (map[string]any, error) {
maxWords := input.MaxWords
if maxWords <= 0 {
maxWords = 100
}
return map[string]any{
"document": input.Document,
"max_words": maxWords,
}, nil
}))
fullChain := compose.NewChain[*SummarizeInput, *SummarizeOutput]()
fullChain.
AppendLambda(compose.InvokableLambda(func(ctx context.Context, input *SummarizeInput) (map[string]any, error) {

Loading…
Cancel
Save