Package com.axelor.ai.chat.stream
Class PartTracker
java.lang.Object
com.axelor.ai.chat.stream.PartTracker
Tracks open text and reasoning parts to enforce the part lifecycle rule:
*-start → N ×
*-delta → *-end with a single consistent ID per run.
One instance per stream — not thread-safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloseAll()Closes all open parts, returning the end events.booleanReturnstrueif a text or reasoning part is currently open (started but not ended).reasoningDelta(String delta) Processes a reasoning delta.Processes a text delta.
-
Constructor Details
-
PartTracker
public PartTracker()
-
-
Method Details
-
textDelta
Processes a text delta. Opens a new text part if needed (closing any open reasoning part first), then emits the delta event.- Returns:
- the events to write (start + delta, or just delta if already open)
-
reasoningDelta
Processes a reasoning delta. Opens a new reasoning part if needed (closing any open text part first), then emits the delta event.- Returns:
- the events to write (start + delta, or just delta if already open)
-
closeAll
Closes all open parts, returning the end events. Returns an empty list if nothing is open. -
hasOpenPart
public boolean hasOpenPart()Returnstrueif a text or reasoning part is currently open (started but not ended).
-