Table of Contents

Class AfterTextCompletionEventArgs

Namespace
LMKit.TextGeneration.Events
Assembly
LM-Kit.NET.dll

Provides details for the event that occurs after a text completion operation.

public sealed class AfterTextCompletionEventArgs : EventArgs
Inheritance
AfterTextCompletionEventArgs
Inherited Members

Examples

The following example shows how to subscribe to the AfterTextCompletion event and stream each text segment to the console, stopping generation when a keyword is detected.

using LMKit.Model;
using LMKit.TextGeneration;
using LMKit.TextGeneration.Events;

LM model = LM.LoadFromModelID("gemma4:e4b");
var chat = new MultiTurnConversation(model);

chat.AfterTextCompletion += (sender, e) =>
{
    // Stream each text segment to the console.
    Console.Write(e.Text);

    // Optionally stop generation when a sentinel value appears.
    if (e.Text.Contains("[END]"))
    {
        e.Stop = true;
    }
};

var response = chat.Submit("Explain quantum entanglement.");

Fields

SegmentType

Indicates the kind of segment associated with Text. Use to decide how to render, log, or act on the segment (see TextSegmentType).

SkipThinking

When set to true during an InternalReasoning segment, the model will immediately end its thinking phase and begin generating the user-visible answer.

This injects the thinking-close tokens (e.g. </think>) into the context and resumes generation in UserVisible mode. Has no effect when the current segment is not InternalReasoning.

Stop

A flag indicating whether the text completion process should be terminated prematurely.

Text

Gets the last text segment produced by the completion process.

Share