Table of Contents

Method ImportTextFromFileAsync

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

ImportTextFromFileAsync(string, Encoding, TextChunking, string, string, CancellationToken)

Asynchronously imports text data from a file into a specified DataSource object, creating or updating a Section entry.

public Task<DataSource> ImportTextFromFileAsync(string path, Encoding encoding, TextChunking textChunking, string dataSourceIdentifier, string sectionIdentifier = "default", CancellationToken cancellationToken = default)

Parameters

path string

The file path from which to read the text data.

encoding Encoding

The character encoding used in the file.

textChunking TextChunking

A TextChunking object specifying the text chunking strategy to be used.

dataSourceIdentifier string

The unique identifier for the DataSource. If this identifier matches an existing DataSource, the data is added to a new section within it. If no matching identifier is found, a new DataSource is created.

sectionIdentifier string

Optional. The identifier for the new Section. Defaults to 'default'.

cancellationToken CancellationToken

Optional. A CancellationToken for canceling the operation.

Returns

Task<DataSource>

A task that represents the asynchronous operation. The task result contains the DataSource object into which the data has been imported.

Exceptions

ArgumentNullException

Thrown if path or dataSourceIdentifier is null or empty.

OperationCanceledException

Thrown if the operation is canceled.