@@ -64,40 +64,6 @@ The summary should flow naturally and capture the essence of the original conten
6464
6565Create a summary in approximately {max_words} words:` ))
6666
67- chain := compose .NewChain [map [string ]any , * SummarizeOutput ]()
68-
69- chain .
70- AppendChatTemplate (extractKeyPointsPrompt ).
71- AppendChatModel (cm ).
72- AppendLambda (compose .InvokableLambda (func (ctx context.Context , msg * schema.Message ) (map [string ]any , error ) {
73- return map [string ]any {
74- "key_points" : msg .Content ,
75- "max_words" : ctx .Value ("max_words" ),
76- }, nil
77- })).
78- AppendChatTemplate (condenseSummaryPrompt ).
79- AppendChatModel (cm ).
80- AppendLambda (compose .InvokableLambda (func (ctx context.Context , msg * schema.Message ) (* SummarizeOutput , error ) {
81- keyPoints := ctx .Value ("key_points_list" ).([]string )
82- return & SummarizeOutput {
83- Summary : msg .Content ,
84- KeyPoints : keyPoints ,
85- WordCount : countWords (msg .Content ),
86- }, nil
87- }))
88-
89- inputTransformChain := compose .NewChain [* SummarizeInput , map [string ]any ]()
90- inputTransformChain .AppendLambda (compose .InvokableLambda (func (ctx context.Context , input * SummarizeInput ) (map [string ]any , error ) {
91- maxWords := input .MaxWords
92- if maxWords <= 0 {
93- maxWords = 100
94- }
95- return map [string ]any {
96- "document" : input .Document ,
97- "max_words" : maxWords ,
98- }, nil
99- }))
100-
10167 fullChain := compose .NewChain [* SummarizeInput , * SummarizeOutput ]()
10268 fullChain .
10369 AppendLambda (compose .InvokableLambda (func (ctx context.Context , input * SummarizeInput ) (map [string ]any , error ) {
0 commit comments