Added an option to all data sources to select a local security policy

This commit is contained in:
tsommer committed 2025-02-10 22:19:27 +01:00
1 parent ea671a1fcd
commit e85a75aa96
17 files changed
+151 -2

No files matched your search

@@ -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,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
};
}