Back to Portal
Phase 04 / Data Consumption

Output: Consumption

Streaming Render, Physical Metrics, and Structured Action Consumption

01 / Data Marshalling Sequence
            sequenceDiagram
                participant K as Plugin Kernel
                participant GT as Game Thread (UI)
                
                Note over K: Token Chunk Ready
                K->>GT: OnChunk(FString) [Auto Marshalling]
                GT->>GT: Update UMG Typewriter
                
                Note over K: Inference Completed
                K->>GT: OnDone(Result Object)
                GT->>GT: Parse ToolCalls for Logic
                GT->>GT: Display Latency/TPS Stats
            
02 / Three Consumption Paths

Path A: Streaming UI Render (OnChunk)

Listen for fragments to achieve zero-wait visual feedback.

// Consumed in WinyunqDialogueWidget
void OnChunk(const FString& Chunk) {
    CurrentText += Chunk;
    Text_Block->SetText(FText::FromString(CurrentText));
}

Path B: Structured Action (ToolCalls)

Extract AI "Thoughts" to drive game logic.

// Parse actions in OnDone
for (auto Call : Result.ToolCalls) {
    if (Call->Name == "OpenDoor") { ExecuteOpenDoor(Call->Params); }
}

Path C: Physical Metrics (Stats)

Show speed and latency to the user.

// Extract physical results
float TPS = Result.TokensPerSec;
float Latency = Result.TimeMs;
03 / Related Concepts
VISUALStreaming Paradigm

AI drops tokens one by one. The plugin marshals these from background threads to GameThread, ensuring UI safety.

LOGICConstrained Decoding

How to force JSON? Logits probability filtering allows us to block hallucinations and only allow valid structural output.