Added importing of configurations exported from AI Studio (#1007)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-10-16 17:22:23 +02:00
1 parent f8c0232cfd
commit 22065783c2
49 files changed
+3257 -263

No files matched your search

@@ -1,5 +1,7 @@
using System.Linq.Expressions;
using AIStudio.Tools.PluginSystem;
namespace AIStudio.Settings.DataModel;
public sealed class DataApp(Expression<Func<Data, DataApp>>? configSelection = null)
@@ -199,6 +201,77 @@ public sealed class DataApp(Expression<Func<Data, DataApp>>? configSelection = n
/// </remarks>
public bool AllowUserToAddMailbox { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToAddMailbox, true);
/// <summary>
/// Should the user be allowed to import configurations which others exported?
/// </summary>
/// <remarks>
/// The master switch of the import: the switch of each type allows its import only while this
/// one does as well. Use CanImportConfigurationSnippet rather than reading the switches one by one.
/// </remarks>
public bool AllowUserToImportConfigurationSnippets { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportConfigurationSnippets, true);
/// <summary>
/// Should the user be allowed to import profiles?
/// </summary>
public bool AllowUserToImportProfile { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportProfile, true);
/// <summary>
/// Should the user be allowed to import LLM providers?
/// </summary>
/// <remarks>
/// An import adds a provider, so AllowUserToAddProvider and AllowUserToAddLLMProvider must allow it as well.
/// </remarks>
public bool AllowUserToImportLLMProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportLLMProvider, true);
/// <summary>
/// Should the user be allowed to import embedding providers?
/// </summary>
/// <remarks>
/// An import adds a provider, so AllowUserToAddProvider and AllowUserToAddEmbeddingProvider must allow it as well.
/// </remarks>
public bool AllowUserToImportEmbeddingProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportEmbeddingProvider, true);
/// <summary>
/// Should the user be allowed to import transcription providers?
/// </summary>
/// <remarks>
/// An import adds a provider, so AllowUserToAddProvider and AllowUserToAddTranscriptionProvider must allow it as well.
/// </remarks>
public bool AllowUserToImportTranscriptionProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportTranscriptionProvider, true);
/// <summary>
/// Should the user be allowed to import chat templates?
/// </summary>
public bool AllowUserToImportChatTemplate { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportChatTemplate, true);
/// <summary>
/// Should the user be allowed to import external data sources (ERI servers)?
/// </summary>
public bool AllowUserToImportERIDataSource { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportERIDataSource, true);
/// <summary>
/// Should the user be allowed to import document analysis policies?
/// </summary>
public bool AllowUserToImportDocumentAnalysisPolicy { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportDocumentAnalysisPolicy, true);
/// <summary>
/// May the user import a configuration of this type, which somebody else exported?
/// </summary>
/// <param name="type">The type of configuration object to import.</param>
/// <returns>True when the master switch and the switch of the type allow it, and for providers also the permission to add one.</returns>
public bool CanImportConfigurationSnippet(PluginConfigurationObjectType type) => this.AllowUserToImportConfigurationSnippets && type switch
{
PluginConfigurationObjectType.PROFILE => this.AllowUserToImportProfile,
PluginConfigurationObjectType.LLM_PROVIDER => this.AllowUserToImportLLMProvider && this.AllowUserToAddProvider && this.AllowUserToAddLLMProvider,
PluginConfigurationObjectType.EMBEDDING_PROVIDER => this.AllowUserToImportEmbeddingProvider && this.AllowUserToAddProvider && this.AllowUserToAddEmbeddingProvider,
PluginConfigurationObjectType.TRANSCRIPTION_PROVIDER => this.AllowUserToImportTranscriptionProvider && this.AllowUserToAddProvider && this.AllowUserToAddTranscriptionProvider,
PluginConfigurationObjectType.CHAT_TEMPLATE => this.AllowUserToImportChatTemplate,
PluginConfigurationObjectType.DATA_SOURCE => this.AllowUserToImportERIDataSource,
PluginConfigurationObjectType.DOCUMENT_ANALYSIS_POLICY => this.AllowUserToImportDocumentAnalysisPolicy,
_ => false,
};
/// <summary>
/// Should the user be allowed to import plugin archives from disk?
/// </summary>
@@ -251,4 +324,4 @@ public sealed class DataApp(Expression<Func<Data, DataApp>>? configSelection = n
/// List of assistants that should be hidden from the UI.
/// </summary>
public HashSet<ConfigurableAssistant> HiddenAssistants { get; set; } = ManagedConfiguration.Register(configSelection, n => n.HiddenAssistants, []);
}
}