mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 19:16:27 +00:00
adding the tools and the confidence level to the SettingsManager
This commit is contained in:
parent
7c5acf3b45
commit
4c9e9b7a9c
@ -212,6 +212,16 @@ CONFIG["SETTINGS"] = {}
|
|||||||
-- Examples are: "CmdOrControl+Shift+D", "Alt+F9", "F8"
|
-- Examples are: "CmdOrControl+Shift+D", "Alt+F9", "F8"
|
||||||
-- CONFIG["SETTINGS"]["DataApp.ShortcutVoiceRecording"] = "CmdOrControl+1"
|
-- CONFIG["SETTINGS"]["DataApp.ShortcutVoiceRecording"] = "CmdOrControl+1"
|
||||||
|
|
||||||
|
-- Configure the minimum provider confidence level required for individual tools.
|
||||||
|
-- Tool IDs include: web_search, read_web_page, get_current_weather
|
||||||
|
-- Allowed values are: NONE, UNTRUSTED, VERY_LOW, LOW, MODERATE, MEDIUM, HIGH
|
||||||
|
-- Defaults: web_search = MEDIUM, read_web_page = MEDIUM, get_current_weather = NONE
|
||||||
|
-- CONFIG["SETTINGS"]["DataTools.MinimumProviderConfidenceByToolId"] = {
|
||||||
|
-- ["web_search"] = "MEDIUM",
|
||||||
|
-- ["read_web_page"] = "MEDIUM",
|
||||||
|
-- ["get_current_weather"] = "NONE"
|
||||||
|
-- }
|
||||||
|
|
||||||
-- Example chat templates for this configuration:
|
-- Example chat templates for this configuration:
|
||||||
CONFIG["CHAT_TEMPLATES"] = {}
|
CONFIG["CHAT_TEMPLATES"] = {}
|
||||||
|
|
||||||
|
|||||||
@ -137,5 +137,5 @@ public sealed class Data
|
|||||||
|
|
||||||
public DataI18N I18N { get; init; } = new();
|
public DataI18N I18N { get; init; } = new();
|
||||||
|
|
||||||
public DataTools Tools { get; init; } = new();
|
public DataTools Tools { get; init; } = new(x => x.Tools);
|
||||||
}
|
}
|
||||||
@ -1,10 +1,23 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Settings.DataModel;
|
namespace AIStudio.Settings.DataModel;
|
||||||
|
|
||||||
public sealed class DataTools
|
public sealed class DataTools(Expression<Func<Data, DataTools>>? configSelection = null)
|
||||||
{
|
{
|
||||||
|
public DataTools() : this(null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public Dictionary<string, Dictionary<string, string>> Settings { get; set; } = [];
|
public Dictionary<string, Dictionary<string, string>> Settings { get; set; } = [];
|
||||||
|
|
||||||
public Dictionary<string, HashSet<string>> DefaultToolIdsByComponent { get; set; } = [];
|
public Dictionary<string, HashSet<string>> DefaultToolIdsByComponent { get; set; } = [];
|
||||||
|
|
||||||
public HashSet<string> VisibleToolSelectionComponents { get; set; } = [];
|
public HashSet<string> VisibleToolSelectionComponents { get; set; } = [];
|
||||||
|
|
||||||
|
public Dictionary<string, string> MinimumProviderConfidenceByToolId { get; set; } = ManagedConfiguration.Register<DataTools, Dictionary<string, string>>(
|
||||||
|
configSelection,
|
||||||
|
x => x.MinimumProviderConfidenceByToolId,
|
||||||
|
new Dictionary<string, string>(StringComparer.Ordinal));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -373,6 +373,30 @@ public sealed class SettingsManager
|
|||||||
this.ConfigurationData.Tools.VisibleToolSelectionComponents.Remove(key);
|
this.ConfigurationData.Tools.VisibleToolSelectionComponents.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfidenceLevel GetMinimumProviderConfidenceForTool(string toolId)
|
||||||
|
{
|
||||||
|
if (this.ConfigurationData.Tools.MinimumProviderConfidenceByToolId.TryGetValue(toolId, out var configuredLevel) &&
|
||||||
|
Enum.TryParse<ConfidenceLevel>(configuredLevel, true, out var confidenceLevel) &&
|
||||||
|
confidenceLevel is not ConfidenceLevel.UNKNOWN)
|
||||||
|
{
|
||||||
|
return confidenceLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ToolSelectionRules.GetDefaultMinimumProviderConfidence(toolId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMinimumProviderConfidenceForTool(string toolId, ConfidenceLevel confidenceLevel)
|
||||||
|
{
|
||||||
|
var defaultLevel = ToolSelectionRules.GetDefaultMinimumProviderConfidence(toolId);
|
||||||
|
if (confidenceLevel == defaultLevel)
|
||||||
|
{
|
||||||
|
this.ConfigurationData.Tools.MinimumProviderConfidenceByToolId.Remove(toolId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ConfigurationData.Tools.MinimumProviderConfidenceByToolId[toolId] = confidenceLevel.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
public ConfidenceLevel GetConfiguredConfidenceLevel(LLMProviders llmProvider)
|
public ConfidenceLevel GetConfiguredConfidenceLevel(LLMProviders llmProvider)
|
||||||
{
|
{
|
||||||
if(llmProvider is LLMProviders.NONE)
|
if(llmProvider is LLMProviders.NONE)
|
||||||
|
|||||||
@ -133,6 +133,9 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
|||||||
// Config: global voice recording shortcut
|
// Config: global voice recording shortcut
|
||||||
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.ShortcutVoiceRecording, this.Id, settingsTable, dryRun);
|
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.ShortcutVoiceRecording, this.Id, settingsTable, dryRun);
|
||||||
|
|
||||||
|
// Config: minimum provider confidence per tool
|
||||||
|
ManagedConfiguration.TryProcessConfiguration(x => x.Tools, x => x.MinimumProviderConfidenceByToolId, this.Id, settingsTable, dryRun);
|
||||||
|
|
||||||
// Handle configured LLM providers:
|
// Handle configured LLM providers:
|
||||||
PluginConfigurationObject.TryParse(PluginConfigurationObjectType.LLM_PROVIDER, x => x.Providers, x => x.NextProviderNum, mainTable, this.Id, ref this.configObjects, dryRun);
|
PluginConfigurationObject.TryParse(PluginConfigurationObjectType.LLM_PROVIDER, x => x.Providers, x => x.NextProviderNum, mainTable, this.Id, ref this.configObjects, dryRun);
|
||||||
|
|
||||||
|
|||||||
@ -238,6 +238,10 @@ public static partial class PluginFactory
|
|||||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.ShortcutVoiceRecording, AVAILABLE_PLUGINS))
|
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.ShortcutVoiceRecording, AVAILABLE_PLUGINS))
|
||||||
wasConfigurationChanged = true;
|
wasConfigurationChanged = true;
|
||||||
|
|
||||||
|
// Check for minimum provider confidence per tool:
|
||||||
|
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Tools, x => x.MinimumProviderConfidenceByToolId, AVAILABLE_PLUGINS))
|
||||||
|
wasConfigurationChanged = true;
|
||||||
|
|
||||||
if (wasConfigurationChanged)
|
if (wasConfigurationChanged)
|
||||||
{
|
{
|
||||||
await SETTINGS_MANAGER.StoreSettings();
|
await SETTINGS_MANAGER.StoreSettings();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user