chatMessagesNode

fun <State> chatMessagesNode(model: ChatModel, messages: suspend (State) -> List<ChatMessage>, update: suspend (State, ChatResponse) -> State): NodeAction<State>

Creates a NodeAction that sends a whole conversation (system, user, AI and tool messages) built from the current state to model. The node gets the full ChatResponse, so it can handle tool execution requests.

Parameters

model

the LangChain4j chat model to call.

messages

builds the conversation from the current state.

update

returns a new state that includes the model's response.