@@ -12,8 +12,8 @@ import (
1212// NewDecideActionNode creates a node that decides whether to search for more information or provide an answer.
1313// It uses an LLM to analyze the question and context to make this decision.
1414func NewDecideActionNode (llm * LLM ) flyt.Node {
15- return flyt .NewNode (
16- flyt . WithPrepFuncAny (func (ctx context.Context , shared * flyt.SharedStore ) (any , error ) {
15+ return flyt .NewNode ().
16+ WithPrepFuncAny (func (ctx context.Context , shared * flyt.SharedStore ) (any , error ) {
1717 question := shared .GetString ("question" )
1818 context := shared .GetStringOr ("context" , "No previous search" )
1919 searchCount := shared .GetInt ("search_count" )
@@ -23,8 +23,8 @@ func NewDecideActionNode(llm *LLM) flyt.Node {
2323 "context" : context ,
2424 "search_count" : searchCount ,
2525 }, nil
26- }),
27- flyt . WithExecFuncAny (func (ctx context.Context , prepResult any ) (any , error ) {
26+ }).
27+ WithExecFuncAny (func (ctx context.Context , prepResult any ) (any , error ) {
2828 data := prepResult .(map [string ]any )
2929 question := data ["question" ].(string )
3030 contextStr := data ["context" ].(string )
@@ -71,8 +71,8 @@ Example responses:
7171 "contextStr" : contextStr ,
7272 "searchCount" : searchCount ,
7373 }, nil
74- }),
75- flyt . WithPostFuncAny (func (ctx context.Context , shared * flyt.SharedStore , prepResult , execResult any ) (flyt.Action , error ) {
74+ }).
75+ WithPostFuncAny (func (ctx context.Context , shared * flyt.SharedStore , prepResult , execResult any ) (flyt.Action , error ) {
7676 data := execResult .(map [string ]any )
7777 response := data ["response" ].(string )
7878
@@ -97,21 +97,21 @@ Example responses:
9797 }
9898
9999 return flyt .Action (action ), nil
100- }),
101- )
100+ }).
101+ Build ( )
102102}
103103
104104// NewSearchWebNode creates a node that searches the web for information
105105func NewSearchWebNode (searcher Searcher ) flyt.Node {
106- return flyt .NewNode (
107- flyt . WithPrepFuncAny (func (ctx context.Context , shared * flyt.SharedStore ) (any , error ) {
106+ return flyt .NewNode ().
107+ WithPrepFuncAny (func (ctx context.Context , shared * flyt.SharedStore ) (any , error ) {
108108 query := shared .GetString ("search_query" )
109109
110110 return map [string ]any {
111111 "query" : query ,
112112 }, nil
113- }),
114- flyt . WithExecFuncAny (func (ctx context.Context , prepResult any ) (any , error ) {
113+ }).
114+ WithExecFuncAny (func (ctx context.Context , prepResult any ) (any , error ) {
115115 data := prepResult .(map [string ]any )
116116 query := data ["query" ].(string )
117117
@@ -127,8 +127,8 @@ func NewSearchWebNode(searcher Searcher) flyt.Node {
127127 "results" : results ,
128128 "query" : query ,
129129 }, nil
130- }),
131- flyt . WithPostFuncAny (func (ctx context.Context , shared * flyt.SharedStore , prepResult , execResult any ) (flyt.Action , error ) {
130+ }).
131+ WithPostFuncAny (func (ctx context.Context , shared * flyt.SharedStore , prepResult , execResult any ) (flyt.Action , error ) {
132132 data := execResult .(map [string ]any )
133133 results := data ["results" ].(string )
134134 query := data ["query" ].(string )
@@ -141,23 +141,23 @@ func NewSearchWebNode(searcher Searcher) flyt.Node {
141141 fmt .Println ("📚 Found information, analyzing results..." )
142142
143143 return "decide" , nil
144- }),
145- )
144+ }).
145+ Build ( )
146146}
147147
148148// NewAnswerQuestionNode creates a node that generates the final answer
149149func NewAnswerQuestionNode (llm * LLM ) flyt.Node {
150- return flyt .NewNode (
151- flyt . WithPrepFuncAny (func (ctx context.Context , shared * flyt.SharedStore ) (any , error ) {
150+ return flyt .NewNode ().
151+ WithPrepFuncAny (func (ctx context.Context , shared * flyt.SharedStore ) (any , error ) {
152152 question := shared .GetString ("question" )
153153 context := shared .GetString ("context" )
154154
155155 return map [string ]any {
156156 "question" : question ,
157157 "context" : context ,
158158 }, nil
159- }),
160- flyt . WithExecFuncAny (func (ctx context.Context , prepResult any ) (any , error ) {
159+ }).
160+ WithExecFuncAny (func (ctx context.Context , prepResult any ) (any , error ) {
161161 data := prepResult .(map [string ]any )
162162 question := data ["question" ].(string )
163163 contextStr := ""
@@ -180,15 +180,15 @@ Provide a short concise answer using the research results.`, question, contextSt
180180 }
181181
182182 return answer , nil
183- }),
184- flyt . WithPostFuncAny (func (ctx context.Context , shared * flyt.SharedStore , prepResult , execResult any ) (flyt.Action , error ) {
183+ }).
184+ WithPostFuncAny (func (ctx context.Context , shared * flyt.SharedStore , prepResult , execResult any ) (flyt.Action , error ) {
185185 answer := execResult .(string )
186186
187187 shared .Set ("answer" , answer )
188188 fmt .Println ("✅ Answer generated successfully" )
189189
190190 // End the flow
191191 return "done" , nil
192- }),
193- )
192+ }).
193+ Build ( )
194194}
0 commit comments