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("gemma3:4b");
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).

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