Table of Contents

Namespace LMKit.TextGeneration

Classes

MultiTurnConversation

A class specifically designed to handle multi-turn question-answering scenarios. This class maintains a conversation session, allowing for multi-turn interactions with a language model. Typical usage includes creating an instance with a language model, optionally specifying a context size, then repeatedly calling Submit(Prompt, CancellationToken) or SubmitAsync(Prompt, CancellationToken) with user prompts. The ChatHistory retains the conversation's state across multiple turns.

// Example usage:
var model = new LM("path/to/model.bin", 
                   new LM.LoadingOptions { LoadTensors = true });
using var conversation = new MultiTurnConversation(model);

// Optionally override the system prompt before the first user message
conversation.SystemPrompt = "You are a helpful assistant.";

// Submit user messages
var result = conversation.Submit("Hello! How can I use this library?");
Console.WriteLine(result.Content);

// Regenerate the response if needed
var regeneratedResult = conversation.RegenerateResponse();
Console.WriteLine(regeneratedResult.Content);
SingleTurnConversation

A class designed for handling single-turn question answering.
Unlike a multi-turn conversation service, it does not preserve context between questions and answers.

Summarizer

Provides functionality to generate a summary (title and/or content) from an input text using a language model.

Summarizer.SummarizerResult

Represents the result of a summarization operation, including both a title and summarized content.

TextGenerationResult

Holds the result of a text completion operation.

Interfaces

IConversation

Represents a conversation interface for interacting with a text generation model. Provides methods for submitting prompts, both synchronously and asynchronously, and allows for event handling before and after token sampling, as well as after text completion.

Enums

Language

Defines supported languages.

Summarizer.OverflowResolutionStrategy

Specifies how to handle situations where the combined length of the input text and the completion tokens exceed the value handled by MaximumContextLength.

TextGenerationResult.StopReason

Enumerates the various reasons that can lead to the termination of a text completion task.