Table of Contents

Method LoadDocument

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

LoadDocument(string, DocumentMetadata, CancellationToken)

Loads a PDF document from the specified file path.

public DocumentIndexingResult LoadDocument(string filePath, DocumentRag.DocumentMetadata documentMetadata = null, CancellationToken cancellationToken = default)

Parameters

filePath string

Path to the PDF file.

documentMetadata DocumentRag.DocumentMetadata

Optional metadata to associate with the document. If null, default metadata is created using the file name. Use this to specify a custom document name, reference URL, or additional metadata fields for source attribution in query results.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

DocumentIndexingResult

A DocumentIndexingResult describing how the document was processed, including the indexing mode, page count, and token count.

Exceptions

InvalidOperationException

Thrown if the conversation has already started.

FileNotFoundException

Thrown if the specified file does not exist.

ObjectDisposedException

Thrown if this instance has been disposed.

LoadDocument(Stream, string, DocumentMetadata, CancellationToken)

Loads a PDF document from a stream.

public DocumentIndexingResult LoadDocument(Stream stream, string documentName, DocumentRag.DocumentMetadata documentMetadata = null, CancellationToken cancellationToken = default)

Parameters

stream Stream

Stream containing PDF data.

documentName string

Display name for the document.

documentMetadata DocumentRag.DocumentMetadata

Optional metadata to associate with the document. If null, default metadata is created using documentName. Use this to specify a custom document name, reference URL, or additional metadata fields for source attribution in query results.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

DocumentIndexingResult

A DocumentIndexingResult describing how the document was processed, including the indexing mode, page count, and token count.

Exceptions

InvalidOperationException

Thrown if the conversation has already started, or if PageProcessingMode is DocumentUnderstanding and DocumentVisionParser is not set.

ArgumentNullException

Thrown if stream or documentName is null or empty.

ObjectDisposedException

Thrown if this instance has been disposed.