Skip to content

Commit 78b6d81

Browse files
committed
remove useless Build()
1 parent 442a9c8 commit 78b6d81

File tree

17 files changed

+24
-52
lines changed

17 files changed

+24
-52
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ node := flyt.NewNode().
113113
return flyt.R("done"), nil
114114
})
115115

116-
// The Build() method is optional since NodeBuilder implements Node
117-
// node := flyt.NewNode().WithExecFunc(fn).Build()
116+
// NodeBuilder directly implements Node interface, so you can use it as-is
117+
// node := flyt.NewNode().WithExecFunc(fn)
118118
```
119119

120120
You can mix traditional and builder patterns:

builder.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,3 @@ func (b *NodeBuilder) WithPostFuncAny(fn func(context.Context, *SharedStore, any
120120
}
121121
return b
122122
}
123-
124-
// Build returns the configured Node.
125-
// This method is optional as NodeBuilder already implements Node,
126-
// but it provides explicit intent when ending the builder chain.
127-
func (b *NodeBuilder) Build() Node {
128-
return b
129-
}

builder_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ func TestNodeBuilderChaining(t *testing.T) {
226226
return flyt.NewNode().
227227
WithExecFunc(func(ctx context.Context, prepResult flyt.Result) (flyt.Result, error) {
228228
return flyt.R("built"), nil
229-
}).
230-
Build() // Explicitly call Build()
229+
})
231230
},
232231
validate: func(t *testing.T, node flyt.Node) {
233232
ctx := context.Background()

cookbook/agent/agent

-8.36 MB
Binary file not shown.

cookbook/agent/nodes.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ Example responses:
9797
}
9898

9999
return flyt.Action(action), nil
100-
}).
101-
Build()
100+
})
102101
}
103102

104103
// NewSearchWebNode creates a node that searches the web for information
@@ -141,8 +140,7 @@ func NewSearchWebNode(searcher Searcher) flyt.Node {
141140
fmt.Println("📚 Found information, analyzing results...")
142141

143142
return "decide", nil
144-
}).
145-
Build()
143+
})
146144
}
147145

148146
// NewAnswerQuestionNode creates a node that generates the final answer
@@ -189,6 +187,5 @@ Provide a short concise answer using the research results.`, question, contextSt
189187

190188
// End the flow
191189
return "done", nil
192-
}).
193-
Build()
190+
})
194191
}

cookbook/chat/chat

-8.28 MB
Binary file not shown.

cookbook/chat/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ func CreateChatNode(llm *LLM) flyt.Node {
8181
shared.Set("messages", messageList)
8282

8383
return "continue", nil
84-
}).
85-
Build()
84+
})
8685
}
8786

8887
func main() {
-8.3 MB
Binary file not shown.

cookbook/llm-streaming/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ func CreateStreamNode(llm *LLM) flyt.Node {
6161
}
6262

6363
return flyt.DefaultAction, nil
64-
}).
65-
Build()
64+
})
6665
}
6766

6867
// CreateInteractiveChatFlow creates a flow that continuously prompts for input and streams responses
@@ -110,8 +109,7 @@ func CreateInteractiveChatFlow(llm *LLM) *flyt.Flow {
110109
shared.Set("messages", messageList)
111110

112111
return "stream", nil
113-
}).
114-
Build()
112+
})
115113

116114
// Create stream node
117115
streamNode := CreateStreamNode(llm)

cookbook/mcp/mcp

-9.35 MB
Binary file not shown.

0 commit comments

Comments
 (0)