Table of Contents

Method ImportTextAsync

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

ImportTextAsync(string, TextChunking, string, string, CancellationToken)

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

public Task<DataSource> ImportTextAsync(string data, TextChunking textChunking, string dataSourceIdentifier, string sectionIdentifier = "default", CancellationToken cancellationToken = default)

Parameters

data string

The textual data to be imported.

textChunking TextChunking

A TextChunking object specifying how text is chunked.

dataSourceIdentifier string

The unique identifier for the DataSource. If it matches an existing DataSource, the data is added as a new section. Otherwise, a new DataSource is created.

sectionIdentifier string

Optional. The new Section's identifier. Defaults to 'default'.

cancellationToken CancellationToken

Optional. A CancellationToken to cancel 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 data or dataSourceIdentifier is null or empty.

OperationCanceledException

Thrown if the operation is canceled.

ImportTextAsync(IList<string>, TextChunking, string, IList<string>, CancellationToken)

Asynchronously imports an array of text data into a specified DataSource object, dynamically creating new Section entries for each item.

public Task<DataSource> ImportTextAsync(IList<string> data, TextChunking textChunking, string dataSourceIdentifier, IList<string> sectionIdentifiers, CancellationToken cancellationToken = default)

Parameters

data IList<string>

An array of text strings to be imported. Each string can represent a "page" of data.

textChunking TextChunking

A TextChunking object specifying how text is chunked.

dataSourceIdentifier string

A unique identifier for the DataSource. If it matches an existing DataSource, new sections are added; otherwise, a new one is created.

sectionIdentifiers IList<string>

A list of identifiers for the new Sections. Its length must match the number of items in data.

cancellationToken CancellationToken

Optional. A CancellationToken for canceling the operation.

Returns

Task<DataSource>

A task that represents the asynchronous operation. The task result contains the updated or newly created DataSource.

Exceptions

ArgumentNullException

Thrown if data, dataSourceIdentifier, or sectionIdentifiers is null or empty.

ArgumentOutOfRangeException

Thrown if the number of sectionIdentifiers does not match the number of items in data.