Table of Contents

Method SplitAsync

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

SplitAsync(Attachment, CancellationToken)

Asynchronously detects logical document boundaries within the specified attachment.

public Task<DocumentSplittingResult> SplitAsync(Attachment attachment, CancellationToken cancellationToken = default)

Parameters

attachment Attachment

The multi-page PDF Attachment to analyze. Cannot be null.

cancellationToken CancellationToken

A token to monitor for cancellation requests while splitting is running.

Returns

Task<DocumentSplittingResult>

A task that represents the asynchronous operation. The task result contains a DocumentSplittingResult with the detected document segments.

Examples

using LMKit.Model;
using LMKit.Extraction;
using LMKit.Data;
using System;
using System.Threading.Tasks;

// Load a vision-capable model (8B or larger recommended)
LM model = LM.LoadFromModelID("qwen3-vl:8b");

// Create the splitter
var splitter = new DocumentSplitting(model);

// Analyze a multi-page PDF asynchronously
DocumentSplittingResult result = await splitter.SplitAsync(new Attachment("multi_doc.pdf"));

// Display results
Console.WriteLine($"Found {result.DocumentCount} document(s)");
Console.WriteLine($"Confidence: {result.Confidence:P0}");
foreach (DocumentSegment segment in result.Segments)
{
    Console.WriteLine($"  Pages {segment.StartPage}-{segment.EndPage}: {segment.Label}");
}

Exceptions

ArgumentNullException

Thrown if attachment is null.