mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-20 22:12:56 +00:00
Add dryRun checks to provider and chat template configuration logic
This commit is contained in:
parent
f221119d71
commit
3963da1366
@ -90,6 +90,8 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
|||||||
// Apply the configured providers to the system settings:
|
// Apply the configured providers to the system settings:
|
||||||
//
|
//
|
||||||
#pragma warning disable MWAIS0001
|
#pragma warning disable MWAIS0001
|
||||||
|
if (!dryRun)
|
||||||
|
{
|
||||||
foreach (var configuredProvider in configuredProviders)
|
foreach (var configuredProvider in configuredProviders)
|
||||||
{
|
{
|
||||||
// The iterating variable is immutable, so we need to create a local copy:
|
// The iterating variable is immutable, so we need to create a local copy:
|
||||||
@ -110,6 +112,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
|||||||
SETTINGS_MANAGER.ConfigurationData.Providers.Add(provider);
|
SETTINGS_MANAGER.ConfigurationData.Providers.Add(provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#pragma warning restore MWAIS0001
|
#pragma warning restore MWAIS0001
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -135,23 +138,29 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply configured chat templates to the system settings:
|
// Apply configured chat templates to the system settings:
|
||||||
|
if (!dryRun)
|
||||||
|
{
|
||||||
foreach (var configuredTemplate in configuredTemplates)
|
foreach (var configuredTemplate in configuredTemplates)
|
||||||
{
|
{
|
||||||
|
// The iterating variable is immutable, so we need to create a local copy:
|
||||||
var template = configuredTemplate;
|
var template = configuredTemplate;
|
||||||
var tplIndex = SETTINGS_MANAGER.ConfigurationData.ChatTemplates.FindIndex(t => t.Id == template.Id);
|
var tplIndex = SETTINGS_MANAGER.ConfigurationData.ChatTemplates.FindIndex(t => t.Id == template.Id);
|
||||||
if (tplIndex > -1)
|
if (tplIndex > -1)
|
||||||
{
|
{
|
||||||
|
// Case: The template already exists, we update it:
|
||||||
var existingTemplate = SETTINGS_MANAGER.ConfigurationData.ChatTemplates[tplIndex];
|
var existingTemplate = SETTINGS_MANAGER.ConfigurationData.ChatTemplates[tplIndex];
|
||||||
template = template with { Num = existingTemplate.Num };
|
template = template with { Num = existingTemplate.Num };
|
||||||
SETTINGS_MANAGER.ConfigurationData.ChatTemplates[tplIndex] = template;
|
SETTINGS_MANAGER.ConfigurationData.ChatTemplates[tplIndex] = template;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Case: The template does not exist, we add it:
|
||||||
template = template with { Num = SETTINGS_MANAGER.ConfigurationData.NextChatTemplateNum++ };
|
template = template with { Num = SETTINGS_MANAGER.ConfigurationData.NextChatTemplateNum++ };
|
||||||
SETTINGS_MANAGER.ConfigurationData.ChatTemplates.Add(template);
|
SETTINGS_MANAGER.ConfigurationData.ChatTemplates.Add(template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user