mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 15:36:26 +00:00
Setting the Websearch base URL with the Config plugin is now possible
This commit is contained in:
parent
24217c2928
commit
623ffec4c7
@ -52,11 +52,19 @@ public partial class ToolSettingsDialog : SettingsDialogBase
|
|||||||
return string.Format(T("{0} Default: {1}"), description, defaultValue);
|
return string.Format(T("{0} Default: {1}"), description, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsFieldDisabled(string fieldName) =>
|
private bool IsFieldDisabled(string fieldName)
|
||||||
this.toolDefinition?.Id.Equals(ToolSelectionRules.READ_WEB_PAGE_TOOL_ID, StringComparison.Ordinal) is true &&
|
{
|
||||||
fieldName.Equals("allowedPrivateHosts", StringComparison.Ordinal) &&
|
if (this.toolDefinition?.Id.Equals(ToolSelectionRules.WEB_SEARCH_TOOL_ID, StringComparison.Ordinal) is true &&
|
||||||
ManagedConfiguration.TryGet(x => x.Tools, x => x.ReadWebPageAllowedPrivateHosts, out var meta) &&
|
fieldName.Equals("baseUrl", StringComparison.Ordinal) &&
|
||||||
meta.IsLocked;
|
ManagedConfiguration.TryGet(x => x.Tools, x => x.WebSearchBaseUrl, out var webSearchMeta) &&
|
||||||
|
webSearchMeta.IsLocked)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return this.toolDefinition?.Id.Equals(ToolSelectionRules.READ_WEB_PAGE_TOOL_ID, StringComparison.Ordinal) is true &&
|
||||||
|
fieldName.Equals("allowedPrivateHosts", StringComparison.Ordinal) &&
|
||||||
|
ManagedConfiguration.TryGet(x => x.Tools, x => x.ReadWebPageAllowedPrivateHosts, out var readWebPageMeta) &&
|
||||||
|
readWebPageMeta.IsLocked;
|
||||||
|
}
|
||||||
|
|
||||||
private string GetFieldPlaceholder(string fieldName, ToolSettingsFieldDefinition fieldDefinition) =>
|
private string GetFieldPlaceholder(string fieldName, ToolSettingsFieldDefinition fieldDefinition) =>
|
||||||
string.IsNullOrWhiteSpace(this.GetValue(fieldName)) ? this.GetFieldDefaultValue(fieldName, fieldDefinition) : string.Empty;
|
string.IsNullOrWhiteSpace(this.GetValue(fieldName)) ? this.GetFieldDefaultValue(fieldName, fieldDefinition) : string.Empty;
|
||||||
|
|||||||
@ -269,6 +269,11 @@ CONFIG["SETTINGS"] = {}
|
|||||||
-- ["read_web_page"] = "MEDIUM"
|
-- ["read_web_page"] = "MEDIUM"
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
|
-- Configure the SearXNG instance URL used by the Web Search tool.
|
||||||
|
-- You can enter either the instance root URL or the /search endpoint.
|
||||||
|
-- CONFIG["SETTINGS"]["DataTools.WebSearchBaseUrl"] = "https://searxng.website/"
|
||||||
|
-- CONFIG["SETTINGS"]["DataTools.WebSearchBaseUrl.AllowUserOverride"] = false
|
||||||
|
|
||||||
-- Configure private or VPN hosts that the Read Web Page tool may access.
|
-- Configure private or VPN hosts that the Read Web Page tool may access.
|
||||||
-- Public web pages do not need to be listed here.
|
-- Public web pages do not need to be listed here.
|
||||||
-- Private hosts listed here still require a provider with HIGH confidence before any page content is sent to the model.
|
-- Private hosts listed here still require a provider with HIGH confidence before any page content is sent to the model.
|
||||||
|
|||||||
@ -21,6 +21,11 @@ public sealed class DataTools(Expression<Func<Data, DataTools>>? configSelection
|
|||||||
x => x.MinimumProviderConfidenceByToolId,
|
x => x.MinimumProviderConfidenceByToolId,
|
||||||
new Dictionary<string, string>(StringComparer.Ordinal));
|
new Dictionary<string, string>(StringComparer.Ordinal));
|
||||||
|
|
||||||
|
public string WebSearchBaseUrl { get; set; } = ManagedConfiguration.Register<DataTools>(
|
||||||
|
configSelection,
|
||||||
|
x => x.WebSearchBaseUrl,
|
||||||
|
string.Empty);
|
||||||
|
|
||||||
public string ReadWebPageAllowedPrivateHosts { get; set; } = ManagedConfiguration.Register<DataTools>(
|
public string ReadWebPageAllowedPrivateHosts { get; set; } = ManagedConfiguration.Register<DataTools>(
|
||||||
configSelection,
|
configSelection,
|
||||||
x => x.ReadWebPageAllowedPrivateHosts,
|
x => x.ReadWebPageAllowedPrivateHosts,
|
||||||
|
|||||||
@ -175,6 +175,9 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
|||||||
// Config: minimum provider confidence per tool
|
// Config: minimum provider confidence per tool
|
||||||
ManagedConfiguration.TryProcessConfiguration(x => x.Tools, x => x.MinimumProviderConfidenceByToolId, this.Id, settingsTable, dryRun);
|
ManagedConfiguration.TryProcessConfiguration(x => x.Tools, x => x.MinimumProviderConfidenceByToolId, this.Id, settingsTable, dryRun);
|
||||||
|
|
||||||
|
// Config: SearXNG base URL for the web search tool
|
||||||
|
ManagedConfiguration.TryProcessConfiguration(x => x.Tools, x => x.WebSearchBaseUrl, this.Id, settingsTable, dryRun);
|
||||||
|
|
||||||
// Config: private hosts allowed for the read web page tool
|
// Config: private hosts allowed for the read web page tool
|
||||||
ManagedConfiguration.TryProcessConfiguration(x => x.Tools, x => x.ReadWebPageAllowedPrivateHosts, this.Id, settingsTable, dryRun);
|
ManagedConfiguration.TryProcessConfiguration(x => x.Tools, x => x.ReadWebPageAllowedPrivateHosts, this.Id, settingsTable, dryRun);
|
||||||
|
|
||||||
|
|||||||
@ -249,6 +249,10 @@ public static partial class PluginFactory
|
|||||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Tools, x => x.MinimumProviderConfidenceByToolId, AVAILABLE_PLUGINS))
|
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Tools, x => x.MinimumProviderConfidenceByToolId, AVAILABLE_PLUGINS))
|
||||||
wasConfigurationChanged = true;
|
wasConfigurationChanged = true;
|
||||||
|
|
||||||
|
// Check for the SearXNG base URL for the web search tool:
|
||||||
|
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Tools, x => x.WebSearchBaseUrl, AVAILABLE_PLUGINS))
|
||||||
|
wasConfigurationChanged = true;
|
||||||
|
|
||||||
// Check for private hosts allowed for the read web page tool:
|
// Check for private hosts allowed for the read web page tool:
|
||||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Tools, x => x.ReadWebPageAllowedPrivateHosts, AVAILABLE_PLUGINS))
|
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Tools, x => x.ReadWebPageAllowedPrivateHosts, AVAILABLE_PLUGINS))
|
||||||
wasConfigurationChanged = true;
|
wasConfigurationChanged = true;
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace AIStudio.Tools.ToolCallingSystem;
|
|||||||
|
|
||||||
public sealed class ToolSettingsService(SettingsManager settingsManager, RustService rustService)
|
public sealed class ToolSettingsService(SettingsManager settingsManager, RustService rustService)
|
||||||
{
|
{
|
||||||
|
private const string WEB_SEARCH_BASE_URL_FIELD = "baseUrl";
|
||||||
private const string READ_WEB_PAGE_ALLOWED_PRIVATE_HOSTS_FIELD = "allowedPrivateHosts";
|
private const string READ_WEB_PAGE_ALLOWED_PRIVATE_HOSTS_FIELD = "allowedPrivateHosts";
|
||||||
|
|
||||||
public async Task<Dictionary<string, string>> GetSettingsAsync(ToolDefinition definition)
|
public async Task<Dictionary<string, string>> GetSettingsAsync(ToolDefinition definition)
|
||||||
@ -15,6 +16,12 @@ public sealed class ToolSettingsService(SettingsManager settingsManager, RustSer
|
|||||||
{
|
{
|
||||||
var fieldName = property.Key;
|
var fieldName = property.Key;
|
||||||
var fieldDefinition = property.Value;
|
var fieldDefinition = property.Value;
|
||||||
|
if (IsWebSearchBaseUrlField(definition, fieldName))
|
||||||
|
{
|
||||||
|
values[fieldName] = settingsManager.ConfigurationData.Tools.WebSearchBaseUrl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsReadWebPageAllowedPrivateHostsField(definition, fieldName))
|
if (IsReadWebPageAllowedPrivateHostsField(definition, fieldName))
|
||||||
{
|
{
|
||||||
values[fieldName] = settingsManager.ConfigurationData.Tools.ReadWebPageAllowedPrivateHosts;
|
values[fieldName] = settingsManager.ConfigurationData.Tools.ReadWebPageAllowedPrivateHosts;
|
||||||
@ -87,6 +94,14 @@ public sealed class ToolSettingsService(SettingsManager settingsManager, RustSer
|
|||||||
values.TryGetValue(fieldName, out var value);
|
values.TryGetValue(fieldName, out var value);
|
||||||
value ??= string.Empty;
|
value ??= string.Empty;
|
||||||
|
|
||||||
|
if (IsWebSearchBaseUrlField(definition, fieldName))
|
||||||
|
{
|
||||||
|
if (!IsWebSearchBaseUrlLocked())
|
||||||
|
settingsManager.ConfigurationData.Tools.WebSearchBaseUrl = value;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsReadWebPageAllowedPrivateHostsField(definition, fieldName))
|
if (IsReadWebPageAllowedPrivateHostsField(definition, fieldName))
|
||||||
{
|
{
|
||||||
if (!IsReadWebPageAllowedPrivateHostsLocked())
|
if (!IsReadWebPageAllowedPrivateHostsLocked())
|
||||||
@ -113,6 +128,13 @@ public sealed class ToolSettingsService(SettingsManager settingsManager, RustSer
|
|||||||
await MessageBus.INSTANCE.SendMessage<object?>(null, Event.CONFIGURATION_CHANGED, null);
|
await MessageBus.INSTANCE.SendMessage<object?>(null, Event.CONFIGURATION_CHANGED, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsWebSearchBaseUrlField(ToolDefinition definition, string fieldName) =>
|
||||||
|
definition.Id.Equals(ToolSelectionRules.WEB_SEARCH_TOOL_ID, StringComparison.Ordinal) &&
|
||||||
|
fieldName.Equals(WEB_SEARCH_BASE_URL_FIELD, StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static bool IsWebSearchBaseUrlLocked() =>
|
||||||
|
ManagedConfiguration.TryGet(x => x.Tools, x => x.WebSearchBaseUrl, out var meta) && meta.IsLocked;
|
||||||
|
|
||||||
private static bool IsReadWebPageAllowedPrivateHostsField(ToolDefinition definition, string fieldName) =>
|
private static bool IsReadWebPageAllowedPrivateHostsField(ToolDefinition definition, string fieldName) =>
|
||||||
definition.Id.Equals(ToolSelectionRules.READ_WEB_PAGE_TOOL_ID, StringComparison.Ordinal) &&
|
definition.Id.Equals(ToolSelectionRules.READ_WEB_PAGE_TOOL_ID, StringComparison.Ordinal) &&
|
||||||
fieldName.Equals(READ_WEB_PAGE_ALLOWED_PRIVATE_HOSTS_FIELD, StringComparison.Ordinal);
|
fieldName.Equals(READ_WEB_PAGE_ALLOWED_PRIVATE_HOSTS_FIELD, StringComparison.Ordinal);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user