mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-12 12:53:48 +00:00
Integrated data sources into any chat (#282)
This commit is contained in:
1 parent
954cf44939
commit
f4780939fc
70 files changed
+1506
-250
No files matched your search
@@ -17,6 +17,11 @@ public sealed class DataChat
|
||||
/// </summary>
|
||||
public AddChatProviderBehavior AddChatProviderBehavior { get; set; } = AddChatProviderBehavior.ADDED_CHATS_USE_LATEST_PROVIDER;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the data source behavior when sending assistant results to a chat.
|
||||
/// </summary>
|
||||
public SendToChatDataSourceBehavior SendToChatDataSourceBehavior { get; set; } = SendToChatDataSourceBehavior.NO_DATA_SOURCES;
|
||||
|
||||
/// <summary>
|
||||
/// Preselect any chat options?
|
||||
/// </summary>
|
||||
@@ -31,6 +36,11 @@ public sealed class DataChat
|
||||
/// Preselect a profile?
|
||||
/// </summary>
|
||||
public string PreselectedProfile { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Should we preselect data sources options for a created chat?
|
||||
/// </summary>
|
||||
public DataSourceOptions PreselectedDataSourceOptions { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Should we show the latest message after loading? When false, we show the first (aka oldest) message.
|
||||
|
||||
@@ -36,4 +36,7 @@ public readonly record struct DataSourceERI_V1 : IERIDataSource
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Username { get; init; } = string.Empty;
|
||||
|
||||
/// <inheritdoc />
|
||||
public DataSourceSecurity SecurityPolicy { get; init; } = DataSourceSecurity.NOT_SPECIFIED;
|
||||
}
|
||||
@@ -24,6 +24,9 @@ public readonly record struct DataSourceLocalDirectory : IInternalDataSource
|
||||
/// <inheritdoc />
|
||||
public string EmbeddingId { get; init; } = Guid.Empty.ToString();
|
||||
|
||||
/// <inheritdoc />
|
||||
public DataSourceSecurity SecurityPolicy { get; init; } = DataSourceSecurity.NOT_SPECIFIED;
|
||||
|
||||
/// <summary>
|
||||
/// The path to the directory.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,6 +24,9 @@ public readonly record struct DataSourceLocalFile : IInternalDataSource
|
||||
/// <inheritdoc />
|
||||
public string EmbeddingId { get; init; } = Guid.Empty.ToString();
|
||||
|
||||
/// <inheritdoc />
|
||||
public DataSourceSecurity SecurityPolicy { get; init; } = DataSourceSecurity.NOT_SPECIFIED;
|
||||
|
||||
/// <summary>
|
||||
/// The path to the file.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataSourceOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether data sources are disabled in this context.
|
||||
/// </summary>
|
||||
public bool DisableDataSources { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the data sources should be selected automatically.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When true, the appropriate data sources for the current prompt are
|
||||
/// selected automatically. When false, the user has to select the
|
||||
/// data sources manually.
|
||||
///
|
||||
/// This setting does not affect the selection of the actual data
|
||||
/// for augmentation.
|
||||
/// </remarks>
|
||||
public bool AutomaticDataSourceSelection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the retrieved data should be validated for the current prompt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When true, the retrieved data is validated against the current prompt.
|
||||
/// An AI will decide whether the data point is useful for answering the
|
||||
/// prompt or not.
|
||||
/// </remarks>
|
||||
public bool AutomaticValidation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The preselected data source IDs. When these data sources are available
|
||||
/// for the selected provider, they are pre-selected.
|
||||
/// </summary>
|
||||
public List<string> PreselectedDataSourceIds { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when data sources are enabled.
|
||||
/// </summary>
|
||||
/// <returns>True when data sources are enabled.</returns>
|
||||
public bool IsEnabled()
|
||||
{
|
||||
if(this.DisableDataSources)
|
||||
return false;
|
||||
|
||||
if(this.AutomaticDataSourceSelection)
|
||||
return true;
|
||||
|
||||
return this.PreselectedDataSourceIds.Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of the current data source options.
|
||||
/// </summary>
|
||||
/// <returns>A copy of the current data source options.</returns>
|
||||
public DataSourceOptions CreateCopy() => new()
|
||||
{
|
||||
DisableDataSources = this.DisableDataSources,
|
||||
AutomaticDataSourceSelection = this.AutomaticDataSourceSelection,
|
||||
AutomaticValidation = this.AutomaticValidation,
|
||||
PreselectedDataSourceIds = [..this.PreselectedDataSourceIds],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public enum DataSourceSecurity
|
||||
{
|
||||
/// <summary>
|
||||
/// The security of the data source is not specified yet.
|
||||
/// </summary>
|
||||
NOT_SPECIFIED,
|
||||
|
||||
/// <summary>
|
||||
/// This data can be used with any LLM provider.
|
||||
/// </summary>
|
||||
ALLOW_ANY,
|
||||
|
||||
/// <summary>
|
||||
/// This data can only be used for self-hosted LLM providers.
|
||||
/// </summary>
|
||||
SELF_HOSTED,
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public static class DataSourceSecurityExtensions
|
||||
{
|
||||
public static string ToSelectionText(this DataSourceSecurity security) => security switch
|
||||
{
|
||||
DataSourceSecurity.NOT_SPECIFIED => "Please select a security policy",
|
||||
|
||||
DataSourceSecurity.ALLOW_ANY => "This data source can be used with any LLM provider. Your data may be sent to a cloud-based provider.",
|
||||
DataSourceSecurity.SELF_HOSTED => "This data source can only be used with a self-hosted LLM provider. Your data will not be sent to any cloud-based provider.",
|
||||
|
||||
_ => "Unknown security policy"
|
||||
};
|
||||
|
||||
public static string ToInfoText(this DataSourceSecurity security) => security switch
|
||||
{
|
||||
DataSourceSecurity.NOT_SPECIFIED => "The security of the data source is not specified yet. You cannot use this data source until you specify a security policy.",
|
||||
|
||||
DataSourceSecurity.ALLOW_ANY => "This data source can be used with any LLM provider. Your data may be sent to a cloud-based provider.",
|
||||
DataSourceSecurity.SELF_HOSTED => "This data source can only be used with a self-hosted LLM provider. Your data will not be sent to any cloud-based provider.",
|
||||
|
||||
_ => "Unknown security policy"
|
||||
};
|
||||
|
||||
public static TextColor GetColor(this DataSourceSecurity security) => security switch
|
||||
{
|
||||
DataSourceSecurity.ALLOW_ANY => TextColor.WARN,
|
||||
DataSourceSecurity.SELF_HOSTED => TextColor.SUCCESS,
|
||||
|
||||
_ => TextColor.ERROR
|
||||
};
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public static class PreviewFeatureExtensions
|
||||
public static class PreviewFeaturesExtensions
|
||||
{
|
||||
public static string GetPreviewDescription(this PreviewFeatures feature) => feature switch
|
||||
{
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public enum SendToChatDataSourceBehavior
|
||||
{
|
||||
NO_DATA_SOURCES,
|
||||
APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public static class SendToChatDataSourceBehaviorExtensions
|
||||
{
|
||||
public static string Description(this SendToChatDataSourceBehavior behavior) => behavior switch
|
||||
{
|
||||
SendToChatDataSourceBehavior.NO_DATA_SOURCES => "Use no data sources, when sending an assistant result to a chat",
|
||||
SendToChatDataSourceBehavior.APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS => "Apply standard chat data source options, when sending an assistant result to a chat",
|
||||
|
||||
_ => "Unknown behavior",
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user