content
01, Koju strukturnu podataka koristi ReAct petlja
ReAct petlja se sastoji od tri faze: Thought (razmišljanje), Action (delovanje), Observation (posmatranje). U kodu se to manifestira kao while petlja.
Najjednostavniji oblik:
while (iteration < MAX_ITERATIONS) {
ChatResponse response = llmClient.chat(history, tools);
if (response.hasToolCalls()) {
// Action faza
for (ToolCall call : response.toolCalls()) {
String result = executeTool(call);
history.add(Message.tool(call.id(), result));
}
// Observation faza: rezultat se dodaje u istoriju
continue;
} else {
// Thought faza: LLM donosi odluku
return response.content();
}
}
5 minuta
