using System.Text.Json.Serialization; using AIStudio.Chat; using AIStudio.Settings.DataModel; using AIStudio.Tools.PluginSystem; using AIStudio.Tools.RAG; namespace AIStudio.Settings; /// /// The common interface for all data sources. /// [JsonPolymorphic(TypeDiscriminatorPropertyName = "$type_discriminator")] [JsonDerivedType(typeof(DataSourceLocalDirectory), nameof(DataSourceType.LOCAL_DIRECTORY))] [JsonDerivedType(typeof(DataSourceLocalFile), nameof(DataSourceType.LOCAL_FILE))] [JsonDerivedType(typeof(DataSourceERI_V1), nameof(DataSourceType.ERI_V1))] public interface IDataSource : IConfigurationObject { /// /// Which type of data source is this? /// public DataSourceType Type { get; init; } /// /// Which data security policy is applied to this data source? /// public DataSourceSecurity SecurityPolicy { get; init; } /// /// The maximum number of matches to return when retrieving data from the ERI server. /// public ushort MaxMatches { get; init; } /// /// Perform the data retrieval process. /// /// The last user prompt from the chat. /// The chat thread. /// The cancellation token. /// The retrieved data context. public Task> RetrieveDataAsync(IContent lastUserPrompt, ChatThread thread, CancellationToken token = default); }