mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 22:49:40 +00:00
Allow chat templates in config plugins (#537)
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
1 parent
7d10bb00f7
commit
be11efed67
20 files changed
+363
-28
No files matched your search
@@ -40,6 +40,8 @@ public static partial class PluginFactory
|
||||
if (!await PLUGIN_LOAD_SEMAPHORE.WaitAsync(0, cancellationToken))
|
||||
return;
|
||||
|
||||
var configObjectList = new List<PluginConfigurationObject>();
|
||||
|
||||
try
|
||||
{
|
||||
LOG.LogInformation("Start loading plugins.");
|
||||
@@ -112,7 +114,8 @@ public static partial class PluginFactory
|
||||
}
|
||||
|
||||
// Start or restart all plugins:
|
||||
await RestartAllPlugins(cancellationToken);
|
||||
var configObjects = await RestartAllPlugins(cancellationToken);
|
||||
configObjectList.AddRange(configObjects);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -149,9 +152,51 @@ public static partial class PluginFactory
|
||||
SETTINGS_MANAGER.ConfigurationData.Providers.Remove(configuredProvider);
|
||||
wasConfigurationChanged = true;
|
||||
}
|
||||
|
||||
if(!configObjectList.Any(configObject =>
|
||||
configObject.Type is PluginConfigurationObjectType.LLM_PROVIDER &&
|
||||
configObject.ConfigPluginId == providerSourcePluginId &&
|
||||
configObject.Id.ToString() == configuredProvider.Id))
|
||||
{
|
||||
LOG.LogWarning($"The configured LLM provider '{configuredProvider.InstanceName}' (id={configuredProvider.Id}) is not present in the configuration plugin anymore. Removing the provider from the settings.");
|
||||
SETTINGS_MANAGER.ConfigurationData.Providers.Remove(configuredProvider);
|
||||
wasConfigurationChanged = true;
|
||||
}
|
||||
}
|
||||
#pragma warning restore MWAIS0001
|
||||
|
||||
//
|
||||
// Check chat templates:
|
||||
//
|
||||
var configuredTemplates = SETTINGS_MANAGER.ConfigurationData.ChatTemplates.ToList();
|
||||
foreach (var configuredTemplate in configuredTemplates)
|
||||
{
|
||||
if(!configuredTemplate.IsEnterpriseConfiguration)
|
||||
continue;
|
||||
|
||||
var templateSourcePluginId = configuredTemplate.EnterpriseConfigurationPluginId;
|
||||
if(templateSourcePluginId == Guid.Empty)
|
||||
continue;
|
||||
|
||||
var templateSourcePlugin = AVAILABLE_PLUGINS.FirstOrDefault(plugin => plugin.Id == templateSourcePluginId);
|
||||
if(templateSourcePlugin is null)
|
||||
{
|
||||
LOG.LogWarning($"The configured chat template '{configuredTemplate.Name}' (id={configuredTemplate.Id}) is based on a plugin that is not available anymore. Removing the chat template from the settings.");
|
||||
SETTINGS_MANAGER.ConfigurationData.ChatTemplates.Remove(configuredTemplate);
|
||||
wasConfigurationChanged = true;
|
||||
}
|
||||
|
||||
if(!configObjectList.Any(configObject =>
|
||||
configObject.Type is PluginConfigurationObjectType.CHAT_TEMPLATE &&
|
||||
configObject.ConfigPluginId == templateSourcePluginId &&
|
||||
configObject.Id.ToString() == configuredTemplate.Id))
|
||||
{
|
||||
LOG.LogWarning($"The configured chat template '{configuredTemplate.Name}' (id={configuredTemplate.Id}) is not present in the configuration plugin anymore. Removing the chat template from the settings.");
|
||||
SETTINGS_MANAGER.ConfigurationData.ChatTemplates.Remove(configuredTemplate);
|
||||
wasConfigurationChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ==========================================================
|
||||
// Check all possible settings:
|
||||
|
||||
Reference in new issue
Block a user