Class
PartialContextQuestionProcessor

Retrieval-augmented Q&A that indexes the document into embeddings and fetches the most similar chunks before prompting; use when the document exceeds the model’s input window.

Definition

Namespace:Telerik.Windows.Documents.AIConnector

Assembly:Telerik.Windows.Documents.AIConnector.dll

Syntax:

cs-api-definition
public sealed class PartialContextQuestionProcessor : AIProcessorBase, IDisposable

Inheritance: objectAIProcessorBasePartialContextQuestionProcessor

Implements: IDisposable

Constructors

PartialContextQuestionProcessor(IChatClient, IContextRetriever, IEmbeddingSettings, SimpleTextDocument)

Initializes a new instance of the PartialContextQuestionProcessor class with the specified chat client, context retriever, context fragments manager, processor settings, and document.

Declaration

cs-api-definition
public PartialContextQuestionProcessor(IChatClient chatClient, IContextRetriever contextRetriever, IEmbeddingSettings settings, SimpleTextDocument document)

Parameters

chatClient

IChatClient

The chat client used to send and receive chat messages within the processing context.

contextRetriever

IContextRetriever

The context retriever responsible for obtaining relevant context information for question processing.

settings

IEmbeddingSettings

The settings that configure the behavior of the partial context processor. Cannot be null.

document

SimpleTextDocument

The text document that provides the source content for context extraction and processing.

Exceptions

ArgumentNullException

Thrown if the settings parameter is null.

PartialContextQuestionProcessor(IChatClient, IEmbedder, IEmbeddingSettings, SimpleTextDocument)

Initializes a new instance of the PartialContextQuestionProcessor class with the specified chat client, embedder, settings, and document.

Declaration

cs-api-definition
public PartialContextQuestionProcessor(IChatClient chatClient, IEmbedder embedder, IEmbeddingSettings settings, SimpleTextDocument document)

Parameters

chatClient

IChatClient

The chat client used to communicate with the AI model.

embedder

IEmbedder

The embedder responsible for generating vector representations of text fragments for similarity calculations.

settings

IEmbeddingSettings

The settings that configure partial context processing behavior, such as token limits and retrieval options.

document

SimpleTextDocument

The document containing the text to be processed for context retrieval. Cannot be null.

Exceptions

ArgumentNullException

Thrown when the settings parameter is null.

Properties

Settings

Gets the settings that control retrieval-augmented behavior, including chunk size and the number of chunks sent.

Declaration

cs-api-definition
public IEmbeddingSettings Settings { get; }

Property Value

IEmbeddingSettings

Methods

AnswerQuestion(string)

Generates an answer by retrieving the most relevant embedded chunks for the question and prompting the model.

Declaration

cs-api-definition
public Task<string> AnswerQuestion(string question)

Parameters

question

string

The question to answer.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the answer to the question.

Dispose()

Disposes the resources used by the PartialContextQuestionProcessor class.

Declaration

cs-api-definition
public override void Dispose()

Overrides AIProcessorBase.Dispose()

Implements IDisposable.Dispose()