diff --git a/app/MindWork AI Studio/Tools/RAG/IRetrievalContext.cs b/app/MindWork AI Studio/Tools/RAG/IRetrievalContext.cs new file mode 100644 index 00000000..27a03dfd --- /dev/null +++ b/app/MindWork AI Studio/Tools/RAG/IRetrievalContext.cs @@ -0,0 +1,45 @@ +namespace AIStudio.Tools.RAG; + +/// +/// The common interface for any retrieval context. +/// +public interface IRetrievalContext +{ + /// + /// The name of the data source. + /// + /// + /// Depending on the configuration, the AI is selecting the appropriate data source. + /// In order to inform the user about where the information is coming from, the data + /// source name is necessary. + /// + public string DataSourceName { get; init; } + + /// + /// The category of the content, like e.g., text, audio, image, etc. + /// + public RetrievalContentCategory Category { get; init; } + + /// + /// What type of content is being retrieved? Like e.g., a project proposal, spreadsheet, art, etc. + /// + public RetrievalContentType Type { get; init; } + + /// + /// The path to the content, e.g., a URL, a file path, a path in a graph database, etc. + /// + public string Path { get; init; } + + /// + /// Links to related content, e.g., links to Wikipedia articles, links to sources, etc. + /// + /// + /// Why would you need links for retrieval? You are right that not all retrieval + /// contexts need links. But think about a web search feature, where we want to + /// query a search engine and get back a list of links to the most relevant + /// matches. Think about a continuous web crawler that is constantly looking for + /// new information and adding it to the knowledge base. In these cases, links + /// are essential. + /// + public IReadOnlyList Links { get; init; } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/RAG/RetrievalImageContext.cs b/app/MindWork AI Studio/Tools/RAG/RetrievalImageContext.cs new file mode 100644 index 00000000..25155a3f --- /dev/null +++ b/app/MindWork AI Studio/Tools/RAG/RetrievalImageContext.cs @@ -0,0 +1,33 @@ +using AIStudio.Chat; + +namespace AIStudio.Tools.RAG; + +public sealed class RetrievalImageContext : IRetrievalContext +{ + #region Implementation of IRetrievalContext + + public required string DataSourceName { get; init; } + + public required RetrievalContentCategory Category { get; init; } + + public required RetrievalContentType Type { get; init; } + + public required string Path { get; init; } + + public IReadOnlyList Links { get; init; } = []; + + #endregion + + /// + /// The type of the image source. + /// + /// + /// Is the image source a URL, a local file path, a base64 string, etc.? + /// + public required ContentImageSource SourceType { get; init; } + + /// + /// The image source. + /// + public required string Source { get; set; } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/RAG/RetrievalTextContext.cs b/app/MindWork AI Studio/Tools/RAG/RetrievalTextContext.cs new file mode 100644 index 00000000..b421c209 --- /dev/null +++ b/app/MindWork AI Studio/Tools/RAG/RetrievalTextContext.cs @@ -0,0 +1,38 @@ +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 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; } = []; +} \ No newline at end of file