namespace AIStudio.Tools.RAG; /// /// The retrieval context for text data. /// public sealed class RetrievalTextContext : IRetrievalContext { #region Implementation of IRetrievalContext /// public required string DataSourceName { get; init; } /// public required RetrievalContentCategory Category { get; init; } /// public string SourceCategory { get; init; } = string.Empty; /// public required RetrievalContentType Type { get; init; } /// public required string Path { get; init; } /// public IReadOnlyList Links { get; init; } = []; #endregion /// /// The text content. /// /// /// Should contain the matched text and some small context around it. /// public required string MatchedText { get; set; } /// /// The surrounding content of the matched text. /// /// /// Might give the user some context about the matched text. /// For example, one sentence or paragraph before and after the matched text. /// public IReadOnlyList SurroundingContent { get; set; } = []; /// /// Optional title used when this context is displayed as a source reference. /// public string ReferenceTitle { get; init; } = string.Empty; /// /// Optional link used when this context is displayed as a source reference. /// public string ReferenceLink { get; init; } = string.Empty; /// /// The page this passage was found on, or null when it has none. /// /// /// Kept as a number rather than only inside the reference title: the AI is told the page so it /// can say where an answer comes from, and a source has to name a page a program can be sent /// to. A slide or a sheet has no page and leaves this empty. /// public int? PageNumber { get; init; } /// /// The page this passage ends on when it goes on beyond the page it starts on, or null when it /// stays on that page or the end is not known. /// public int? EndPageNumber { get; init; } /// /// The sheet of a spreadsheet this passage is from, or null when it is from none. /// public string? SheetName { get; init; } /// /// The row this passage starts at, counted from one: a row of its sheet, or of a table such as a CSV file. /// public int? StartRow { get; init; } /// /// The row this passage ends at when it goes on beyond the row it starts at, or null. /// public int? EndRow { get; init; } /// /// The line this passage starts at, counted from one, for text and source code, or null. /// public int? StartLine { get; init; } /// /// The line this passage ends at when it goes on beyond the line it starts at, or null. /// public int? EndLine { get; init; } /// /// Which part of its document this passage is, counted from one, or null when the data source does not say. /// /// /// A document is split into parts to be searched, and each part is one passage. The page says /// better where a passage is, so the part only names the place in a document without pages, /// such as a text file. /// public int? ChunkNumber { get; init; } }