Table of Contents

Method SummarizeAsync

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

SummarizeAsync(string, CancellationToken)

Asynchronously generates a summary from the provided content.

public Task<Summarizer.SummarizerResult> SummarizeAsync(string content, CancellationToken cancellationToken = default)

Parameters

content string

The input text to be summarized.

cancellationToken CancellationToken

An optional cancellation token that can be used to cancel the operation.

Returns

Task<Summarizer.SummarizerResult>

A task that represents the asynchronous operation, containing a Summarizer.SummarizerResult with the summary.

Examples

// Summarizing text retrieved from a web API asynchronously.
var model = new LMKit.Model.LM("api-model.gguf");
var summarizer = new LMKit.TextGeneration.Summarizer(model)
{
    MaxTitleWords = 8,
    MaxContentWords = 250
};

// Assume FetchArticleAsync fetches text from a remote source
string articleContent = await FetchArticleAsync("https://example.com/article");

var result = await summarizer.SummarizeAsync(articleContent);
Console.WriteLine("Generated Title: " + result.Title);
Console.WriteLine("Generated Summary: " + result.Content);

Exceptions

ArgumentException

Thrown if the provided content is null or empty.