ClassDefaultContextRetriever
Provides a default implementation for retrieving relevant context fragments based on semantic similarity to a given question.
Definition
Namespace:Telerik.Documents.AI.RAG
Assembly:Telerik.Documents.AI.RAG.dll
Syntax:
public class DefaultContextRetriever : IContextRetriever
Inheritance: objectDefaultContextRetriever
Implements:
Constructors
DefaultContextRetriever(IContextFragmentsManager, IEmbedder, ISimilarityCalculator, ITokensCounter, IEmbeddingSettings)
Initializes a new instance of the DefaultContextRetriever class with the specified context fragments manager, embedder, similarity calculator, tokens counter, and embedding settings.
Declaration
public DefaultContextRetriever(IContextFragmentsManager contextFragmentsManager, IEmbedder embedder, ISimilarityCalculator similarityCalculator, ITokensCounter tokensCounter, IEmbeddingSettings settings)
Parameters
contextFragmentsManager
The manager responsible for handling context fragments used in retrieval operations. Cannot be null.
embedder
The component used to generate embeddings for context fragments. Cannot be null.
similarityCalculator
The calculator used to determine similarity between embeddings. Cannot be null.
tokensCounter
The service used to count tokens in context fragments and embeddings. Cannot be null.
settings
The settings that configure embedding parameters, such as the maximum number of embeddings, embedding token size, and model input token limit. Cannot be null.
Properties
ContextFragmentsManager
Gets the manager responsible for handling context fragments within the current instance.
Declaration
protected IContextFragmentsManager ContextFragmentsManager { get; }
Property Value
Methods
GetContextAsync(string)
Gets the text representation of the relevant embeddings for the provided question.
SetContextAsync(string, int)
Asynchronously splits the specified text into fragments based on the provided embedding token size.
Declaration
public Task SetContextAsync(string text, int embeddingTokenSize)
Parameters
text
The text to be divided into fragments. Cannot be null.
embeddingTokenSize
The maximum number of tokens allowed in each fragment. Must be a positive integer.
Returns
A task that represents the asynchronous operation of fragmenting the text.
Implements