Configure data sources (#259)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-01-13 19:51:26 +01:00
1 parent 06f66fdab2
commit 63be312bb4
47 files changed
+3388 -283

No files matched your search

@@ -25,6 +25,11 @@ public sealed class Data
/// A collection of embedding providers configured.
/// </summary>
public List<EmbeddingProvider> EmbeddingProviders { get; init; } = [];
/// <summary>
/// A collection of data sources configured.
/// </summary>
public List<IDataSource> DataSources { get; set; } = [];
/// <summary>
/// List of configured profiles.
@@ -41,6 +46,11 @@ public sealed class Data
/// </summary>
public uint NextEmbeddingNum { get; set; } = 1;
/// <summary>
/// The next data source number to use.
/// </summary>
public uint NextDataSourceNum { get; set; } = 1;
/// <summary>
/// The next profile number to use.
/// </summary>
@@ -0,0 +1,46 @@
using ERI_Client.V1;
// ReSharper disable InconsistentNaming
namespace AIStudio.Settings.DataModel;
/// <summary>
/// An external data source, accessed via an ERI server, cf. https://github.com/MindWorkAI/ERI.
/// </summary>
public readonly record struct DataSourceERI_V1 : IERIDataSource
{
public DataSourceERI_V1()
{
}
/// <inheritdoc />
public uint Num { get; init; }
/// <inheritdoc />
public string Id { get; init; } = Guid.Empty.ToString();
/// <inheritdoc />
public string Name { get; init; } = string.Empty;
/// <inheritdoc />
public DataSourceType Type { get; init; } = DataSourceType.NONE;
/// <summary>
/// The hostname of the ERI server.
/// </summary>
public string Hostname { get; init; } = string.Empty;
/// <summary>
/// The port of the ERI server.
/// </summary>
public int Port { get; init; }
/// <summary>
/// The authentication method to use.
/// </summary>
public AuthMethod AuthMethod { get; init; } = AuthMethod.NONE;
/// <summary>
/// The username to use for authentication, when the auth. method is USERNAME_PASSWORD.
/// </summary>
public string Username { get; init; } = string.Empty;
}
@@ -0,0 +1,31 @@
namespace AIStudio.Settings.DataModel;
/// <summary>
/// Represents a local directory as a data source.
/// </summary>
public readonly record struct DataSourceLocalDirectory : IInternalDataSource
{
public DataSourceLocalDirectory()
{
}
/// <inheritdoc />
public uint Num { get; init; }
/// <inheritdoc />
public string Id { get; init; } = Guid.Empty.ToString();
/// <inheritdoc />
public string Name { get; init; } = string.Empty;
/// <inheritdoc />
public DataSourceType Type { get; init; } = DataSourceType.NONE;
/// <inheritdoc />
public string EmbeddingId { get; init; } = Guid.Empty.ToString();
/// <summary>
/// The path to the directory.
/// </summary>
public string Path { get; init; } = string.Empty;
}
@@ -0,0 +1,31 @@
namespace AIStudio.Settings.DataModel;
/// <summary>
/// Represents one local file as a data source.
/// </summary>
public readonly record struct DataSourceLocalFile : IInternalDataSource
{
public DataSourceLocalFile()
{
}
/// <inheritdoc />
public uint Num { get; init; }
/// <inheritdoc />
public string Id { get; init; } = Guid.Empty.ToString();
/// <inheritdoc />
public string Name { get; init; } = string.Empty;
/// <inheritdoc />
public DataSourceType Type { get; init; } = DataSourceType.NONE;
/// <inheritdoc />
public string EmbeddingId { get; init; } = Guid.Empty.ToString();
/// <summary>
/// The path to the file.
/// </summary>
public string FilePath { get; init; } = string.Empty;
}
@@ -0,0 +1,27 @@
namespace AIStudio.Settings.DataModel;
/// <summary>
/// AI Studio data source types.
/// </summary>
public enum DataSourceType
{
/// <summary>
/// No data source.
/// </summary>
NONE = 0,
/// <summary>
/// One file on the local machine (or a network share).
/// </summary>
LOCAL_FILE,
/// <summary>
/// A directory on the local machine (or a network share).
/// </summary>
LOCAL_DIRECTORY,
/// <summary>
/// External data source accessed via an ERI server, cf. https://github.com/MindWorkAI/ERI.
/// </summary>
ERI_V1,
}
@@ -0,0 +1,24 @@
namespace AIStudio.Settings.DataModel;
/// <summary>
/// Extension methods for data source types.
/// </summary>
public static class DataSourceTypeExtension
{
/// <summary>
/// Get the display name of the data source type.
/// </summary>
/// <param name="type">The data source type.</param>
/// <returns>The display name of the data source type.</returns>
public static string GetDisplayName(this DataSourceType type)
{
return type switch
{
DataSourceType.LOCAL_FILE => "Local File",
DataSourceType.LOCAL_DIRECTORY => "Local Directory",
DataSourceType.ERI_V1 => "External ERI Server (v1)",
_ => "None",
};
}
}