Moved the background agents to AI operations (#1215)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-21 19:47:10 +01:00
1 parent 8a4a26503b
commit c50a93cd17
139 files changed
+4069 -2340

No files matched your search

@@ -1,4 +1,4 @@
@using AIStudio.Agents.AssistantAudit
@using AIStudio.AIOperations.PluginAudit
@inherits MSGComponentBase
@if (this.Plugin is not null)
@@ -1070,7 +1070,7 @@ public partial class ChatComponent : MSGComponentBase
/// <remarks>
/// As with the tools, a template which carries no options says nothing and leaves the chat
/// defaults in place. A template which carries them answers more than which sources to search:
/// whether data sources are used at all, and whether an agent picks them for each message.
/// whether data sources are used at all, and whether an AI operation picks them for each message.
/// </remarks>
private DataSourceOptions GetAutomaticDataSourceOptions() =>
this.currentChatTemplate.DataSourceOptions?.CreateCopy() ?? this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy();
@@ -2355,7 +2355,7 @@ public partial class ChatComponent : MSGComponentBase
await this.SyncWorkspaceHeaderWithChatThreadAsync();
await this.ChatThreadChanged.InvokeAsync(this.ChatThread);
// The new chat forgot which data sources an agent picked for the last request of the old one:
// The new chat forgot which data sources an AI operation picked for the last request of the old one:
this.dataSourceSelectionComponent?.ChangeOptionWithoutSaving(continuation.DataSourceOptions, continuation.AISelectedDataSources);
this.tokenTracker?.Nudge();
}
@@ -1,5 +1,5 @@
@inherits ConfigurationBaseCore
<MudSwitch T="bool" Disabled="@this.IsDisabled" Value="@this.State()" ValueChanged="@this.OptionChanged" Color="Color.Primary">
<MudSwitch @key="@this.switchKey" T="bool" Disabled="@this.IsDisabled" Value="@this.State()" ValueChanged="@this.OptionChanged" Color="Color.Primary">
@(this.State() ? this.LabelOn : this.LabelOff)
</MudSwitch>
@@ -30,7 +30,25 @@ public partial class ConfigurationOption : ConfigurationBaseCore
/// </summary>
[Parameter]
public Action<bool> StateUpdate { get; set; } = _ => { };
/// <summary>
/// Asks before the option takes the new state, e.g., whether the user really wants to turn off a protection.
/// </summary>
/// <remarks>
/// It gets the new state and returns false to keep the old one.
/// </remarks>
[Parameter]
public Func<bool, Task<bool>> ConfirmChange { get; set; } = _ => Task.FromResult(true);
/// <summary>
/// The key of the switch, which changes whenever a change was rejected.
/// </summary>
/// <remarks>
/// The switch shows the state the user clicked, until its value changes. A rejected change leaves the value
/// as it was, so the switch is built anew to show it.
/// </remarks>
private int switchKey;
#region Overrides of ConfigurationBase
/// <inheritdoc />
@@ -46,6 +64,12 @@ public partial class ConfigurationOption : ConfigurationBaseCore
private async Task OptionChanged(bool updatedState)
{
if (!await this.ConfirmChange(updatedState))
{
this.switchKey++;
return;
}
this.StateUpdate(updatedState);
await this.SettingsManager.StoreSettings();
await this.InformAboutChange();
@@ -49,13 +49,23 @@ public partial class ConfigurationProviderSelection : MSGComponentBase
[Parameter]
public string? NoPreselectionText { get; set; }
/// <summary>
/// The text of the empty entry, which says what happens without a preselected provider, or null for "Use app default".
/// </summary>
/// <remarks>
/// Set it where the empty entry falls back on something else than the provider of the whole app, e.g., on the
/// model of the chat.
/// </remarks>
[Parameter]
public string? EmptySelectionText { get; set; }
private IEnumerable<ConfigurationSelectData<string>> FilteredData()
{
if (this.NoPreselectionText is not null)
yield return new(this.NoPreselectionText, AIStudio.Settings.Provider.NONE.Id);
if(this.Component is not Tools.Components.NONE and not Tools.Components.APP_SETTINGS)
yield return new(T("Use app default"), string.Empty);
yield return new(this.EmptySelectionText ?? T("Use app default"), string.Empty);
//
// Filter the providers based on the minimum confidence level of this component, the enforced
@@ -1,4 +1,4 @@
using AIStudio.Agents;
using AIStudio.AIOperations.DataSourceChoice;
using AIStudio.Settings;
namespace AIStudio.Components;
@@ -75,7 +75,7 @@
<MudTextSwitch Label="@T("AI-based data source selection")" Value="@this.aiBasedSourceSelection" LabelOn="@T("Yes, let the AI decide which data sources are needed.")" LabelOff="@T("No, I manually decide which data source to use.")" ValueChanged="@this.AutoModeChanged" Dense="@true" Disabled="@this.ReadOnly"/>
}
@* With Semantic Search, no agent takes part: nothing would validate the retrieved data. *@
@* With Semantic Search, no AI operation takes part: nothing would validate the retrieved data. *@
@if (this.AllowsAutomaticSelection && this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation && !this.IsSemanticSearchEffective)
{
<MudTextSwitch Label="@T("AI-based data validation")" Value="@this.aiBasedValidation" LabelOn="@T("Yes, let the AI validate & filter the retrieved data.")" LabelOff="@T("No, use all data retrieved from the data sources.")" ValueChanged="@this.ValidationModeChanged" Dense="@true" Disabled="@this.ReadOnly"/>
@@ -130,8 +130,8 @@
</MudList>
</ExpansionPanel>
@*
With Semantic Search, no agent selects: the chat model picks with each search, and its
searches show in the answer. With classic RAG, there is something to show once the agent
With Semantic Search, no AI operation selects: the chat model picks with each search, and its
searches show in the answer. With classic RAG, there is something to show once the AI operation
picked for a message.
*@
@if (!this.IsSemanticSearchEffective && this.DataSourcesAISelected.Count > 0)
@@ -313,7 +313,7 @@ public partial class DataSourceSelection : MSGComponentBase
// that field holds what was usable the last time we looked, so a source filtered out once
// would never come back, while the RAG process keeps reading it from the preselection.
//
// How the chat searches decides whether the agents of the RAG process see the data, and
// How the chat searches decides whether the AI operations of the RAG process see the data, and
// with that which data sources the provider of the chat may use at all. With several
// models, all of them search the same way, and each must be allowed every data source:
//
@@ -3,7 +3,7 @@
<MudTextSwitch Label="@T("Read content from web?")" Disabled="@this.AgentIsRunning" Value="@this.Preselect" ValueChanged="@this.ShowWebContentReaderChanged" LabelOn="@T("Show web content options")" LabelOff="@T("Hide web content options")" />
@if (this.Preselect)
{
<MudTextSwitch Label="@T("Clean up content by using an LLM agent?")" Value="@this.PreselectContentCleanerAgent" ValueChanged="@this.UseContentCleanerAgentChanged" Disabled="@this.AgentIsRunning" LabelOn="@T("The content is cleaned using an LLM agent: the main content is extracted, advertisements and other irrelevant things are attempted to be removed; relative links are attempted to be converted into absolute links so that they can be used.")" LabelOff="@T("No content cleaning")" />
<MudTextSwitch Label="@T("Clean up the content with AI?")" Value="@this.PreselectContentCleanerAgent" ValueChanged="@this.UseContentCleanerAgentChanged" Disabled="@this.AgentIsRunning" LabelOn="@T("The text content cleaner, an AI task, extracts the main content, tries to remove advertisements and other clutter, and tries to turn relative links into absolute ones, so that they work.")" LabelOff="@T("No content cleaning")" />
@if (this.ContentCleanerHint is { } contentCleanerHint)
{
<MudText Typo="Typo.body2" Color="Color.Error" Class="mb-3">
@@ -1,5 +1,7 @@
using AIStudio.Agents;
using AIStudio.Chat;
using AIStudio.AIOperations;
using AIStudio.AIOperations.TextContentCleaning;
using AIStudio.Provider;
using AIStudio.Settings;
using AIStudio.Tools.Security;
using AIStudio.Tools.Web;
@@ -25,7 +27,10 @@ public partial class ReadWebContent : MSGComponentBase
private ILogger<ReadWebContent> Logger { get; init; } = null!;
[Inject]
private AgentTextContentCleaner AgentTextContentCleaner { get; init; } = null!;
private TextContentCleaningOperation TextContentCleaning { get; init; } = null!;
[Inject]
private AIOperationProviderResolver ProviderResolver { get; init; } = null!;
[Inject]
private PromptInjectionGuardService PromptInjectionGuardService { get; init; } = null!;
@@ -74,15 +79,15 @@ public partial class ReadWebContent : MSGComponentBase
private ProcessStepValue processStep;
/// <summary>
/// The model the content cleaner runs with.
/// The model the content cleaner would run with, and why others were not chosen.
/// </summary>
/// <remarks>
/// This is a resolved value, not a chosen one: the reader has no model selection of its own,
/// it takes what the assistant around it uses, unless a dedicated one for the cleaner or an
/// app-wide default takes precedence. Because the assistant's model can change at any moment,
/// this is resolved again on every render instead of being remembered from the first one.
/// it takes what the assistant around it uses, unless a dedicated one for the cleaner takes
/// precedence, or the app-wide default fills in. Because the assistant's model can change at any
/// moment, this is resolved again on every render instead of being remembered from the first one.
/// </remarks>
private AIStudio.Settings.Provider providerSettings = AIStudio.Settings.Provider.NONE;
private AIOperationProviderChoice cleanerChoice = new(AIStudio.Settings.Provider.NONE, AIOperationProviderIssue.NOT_SET, AIOperationProviderIssue.NOT_SET);
#region Overrides of ComponentBase
@@ -130,7 +135,24 @@ public partial class ReadWebContent : MSGComponentBase
/// parameter, and a parameter arrives whenever the parent renders. Resolving only once would
/// leave the cleaner with whatever was set the first time this component was built.
/// </remarks>
private void ResolveProvider() => this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_TEXT_CONTENT_CLEANER, this.ProviderSettings.Id, true);
private void ResolveProvider() => this.cleanerChoice = this.ProviderResolver.Preview(TextContentCleaningOperation.GetProviderSettings(this.SettingsManager), ConfidenceLevel.NONE, GetCleanerProviderOptions(this.SettingsManager, this.ProviderSettings));
/// <summary>
/// What the reader adds to the choice of the provider for the content cleaner.
/// </summary>
/// <remarks>
/// Without a model of its own, the cleaner falls back on the model of the assistant, and then on
/// the app-wide default. Its minimum confidence applies to both of them: a model somebody picked
/// for the assistant has to clear the bar of the cleaner before the cleaner uses it.
/// </remarks>
/// <param name="settingsManager">The settings, for the app-wide default.</param>
/// <param name="assistantProvider">The model of the assistant around the reader.</param>
/// <returns>The options for the provider resolver.</returns>
internal static AIOperationProviderOptions GetCleanerProviderOptions(SettingsManager settingsManager, AIStudio.Settings.Provider assistantProvider) => new()
{
FallbackProviderIds = [assistantProvider.Id, settingsManager.AppDefaultProviderId],
OwnMinimumConfidenceAppliesToFallbacks = true,
};
private async Task LoadFromWeb()
{
@@ -161,46 +183,36 @@ public partial class ReadWebContent : MSGComponentBase
markdown = retrievedPage.ExtractedPage.Markdown;
markdown = await this.PromptInjectionGuardService.SanitizeAsync(markdown, PromptInjectionSource.WebContent(this.URL));
if (this.PreselectContentCleanerAgent && this.providerSettings == AIStudio.Settings.Provider.NONE)
if (this.PreselectContentCleanerAgent)
{
//
// Say that the cleaning did not happen. The user asked for it, the page arrives,
// and without a word they would take the raw markdown -- navigation, cookie banner
// and advertising included -- for the cleaned result.
//
await this.MessageBus.SendError(new(AppIcons.AGENT, T("The content was loaded, but not cleaned: no model is available for the content cleaner.")));
}
var request = new TextContentCleaningRequest(markdown, this.URL);
var choice = this.ProviderResolver.Resolve(this.TextContentCleaning, request, TextContentCleaningOperation.GetProviderSettings(this.SettingsManager), GetCleanerProviderOptions(this.SettingsManager, this.ProviderSettings));
if (!choice.HasProvider)
{
//
// Say that the cleaning did not happen. The user asked for it, the page arrives,
// and without a word they would take the raw markdown -- navigation, cookie banner
// and advertising included -- for the cleaned result.
//
await this.MessageBus.SendError(new(AppIcons.AI_OPERATION, T("The content was loaded, but not cleaned: no model is available for the content cleaner.")));
}
else
{
this.processStep = this.process[ReadWebContentSteps.CLEANING];
this.AgentIsRunning = true;
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
this.StateHasChanged();
if (this.PreselectContentCleanerAgent && this.providerSettings != AIStudio.Settings.Provider.NONE)
{
this.AgentTextContentCleaner.ProviderSettings = this.providerSettings;
var additionalData = new Dictionary<string, string>
{
{ "sourceURL", this.URL },
};
this.processStep = this.process[ReadWebContentSteps.CLEANING];
this.AgentIsRunning = true;
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
this.StateHasChanged();
var contentBlock = await this.AgentTextContentCleaner.ProcessInput(new ContentBlock
{
Time = DateTimeOffset.UtcNow,
ContentType = ContentType.TEXT,
Role = ChatRole.USER,
Content = new ContentText
{
Text = markdown,
},
}, additionalData);
markdown = contentBlock.Content is ContentText text ? text.Text : markdown;
this.processStep = this.process[ReadWebContentSteps.DONE];
this.AgentIsRunning = false;
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
this.StateHasChanged();
var result = await this.TextContentCleaning.RunAsync(request, new(choice.Provider));
markdown = result.Markdown;
if (!result.IsCleaned)
await this.MessageBus.SendWarning(new(AppIcons.AI_OPERATION, T("The content was loaded, but not cleaned: the model of the content cleaner gave no answer.")));
this.processStep = this.process[ReadWebContentSteps.DONE];
this.AgentIsRunning = false;
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
this.StateHasChanged();
}
}
}
catch (Exception exception)
@@ -269,20 +281,24 @@ public partial class ReadWebContent : MSGComponentBase
/// This is a hint, not a validation: the cleaner is an option of the reader, and an option
/// nobody can use yet must not keep the assistant around it from running. It is also stated
/// rather than remembered, so that choosing a model below makes it disappear at once.
/// The two causes lead to different places, which is why they are told apart: either no model
/// was chosen at all, or the chosen one is not trusted enough for this agent.
/// The causes lead to different places, which is why they are told apart: no model was chosen
/// at all, the organization does not allow the chosen one, or it is not trusted enough for the
/// cleaner. The reason comes from the choice itself, where the first named fallback is the model
/// of the assistant, or the app-wide default when the assistant has none.
/// </remarks>
private string? ContentCleanerHint
{
get
{
if(!this.PreselectContentCleanerAgent || this.providerSettings != AIStudio.Settings.Provider.NONE)
if(!this.PreselectContentCleanerAgent || this.cleanerChoice.HasProvider)
return null;
if(this.ProviderSettings == AIStudio.Settings.Provider.NONE)
return TA("The content cleaner uses the model of this assistant. Please select one below.");
return TA("The selected model does not meet the confidence requirements of the content cleaner. Please select another model, or configure an eligible one in the app settings.");
return this.cleanerChoice.FallbackIssue switch
{
AIOperationProviderIssue.NOT_SET => TA("The content cleaner uses the model of this assistant. Please select one below."),
AIOperationProviderIssue.PROHIBITED => TA("Your organization does not allow the selected model. Please select another model, or configure an eligible one in the app settings."),
_ => TA("The selected model does not meet the confidence requirements of the content cleaner. Please select another model, or configure an eligible one in the app settings."),
};
}
}
@@ -1,20 +1,25 @@
@using AIStudio.Settings
@inherits SettingsPanelBase
<ExpansionPanel HeaderIcon="@AppIcons.SECURITY_AUDIT" HeaderText="@T("Agent: Security Audit for external Assistants")">
<ExpansionPanel HeaderIcon="@AppIcons.SECURITY_AUDIT" HeaderText="@T("AI Task: Security Audit for external Assistants")">
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@T("This Agent audits newly installed or updated external Plugin-Assistant for security risks before they are activated and stores the latest audit card until the plugin manifest changes.")
@T("Before external assistants are activated, a model audits newly installed or updated ones for security risks. AI Studio keeps the latest audit card until the plugin manifest changes.")
</MudJustifiedText>
<MudField Label="@T("Require a security audit before activating external Assistants?")" Variant="Variant.Outlined" Underline="false" Class="mb-6" InnerPadding="false">
<MudSwitch T="bool" Value="@this.SettingsManager.ConfigurationData.AssistantPluginAudit.RequireAuditBeforeActivation" ValueChanged="@this.RequireAuditBeforeActivationChanged" Color="Color.Primary">
@(this.SettingsManager.ConfigurationData.AssistantPluginAudit.RequireAuditBeforeActivation ? T("External Assistants must be audited before activation") : T("External Assistant can be activated without an audit"))
</MudSwitch>
</MudField>
<ConfigurationProviderSelection Data="@this.AvailableLLMProvidersFunc()" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AssistantPluginAudit.PreselectedAgentProvider = selectedValue)" HelpText="@(() => TA("Optionally choose a dedicated provider for assistant plugin audits. When left empty, AI Studio falls back to the app-wide default provider."))" />
<ConfigurationSelect OptionDescription="@T("Minimum required audit level")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.MinimumLevel)" Data="@ConfigurationSelectDataFactory.GetAssistantAuditLevelsData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AssistantPluginAudit.MinimumLevel = selectedValue)" OptionHelp="@T("External Assistants rated below this audit level are treated as insufficiently reviewed.")" />
<ConfigurationOption OptionDescription="@T("Require a security audit before activating external Assistants?")" LabelOn="@T("External Assistants must be audited before activation")" LabelOff="@T("External Assistant can be activated without an audit")" State="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.RequireAuditBeforeActivation)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AssistantPluginAudit.RequireAuditBeforeActivation = updatedState)" ConfirmChange="@this.ConfirmRequireAuditBeforeActivationChange" IsLocked="() => ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.RequireAuditBeforeActivation, out var meta) && meta.IsLocked"/>
<ConfigurationMinConfidenceSelection RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AssistantPluginAudit.MinimumProviderConfidence = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.MinimumProviderConfidence, out var meta) && meta.IsLocked"/>
<ConfigurationProviderSelection Component="Components.AGENT_ASSISTANT_PLUGIN_AUDIT" EmptySelectionText="@T("Use the app default, otherwise the model chosen when auditing")" Data="@this.AvailableLLMProvidersFunc()" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AssistantPluginAudit.PreselectedAgentProvider = selectedValue)" HelpText="@(() => TA("Optionally choose a dedicated provider for assistant plugin audits. When left empty, AI Studio uses the app-wide default provider, or else the model you choose when auditing."))" IsLocked="() => ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.PreselectedAgentProvider, out var meta) && meta.IsLocked"/>
<ConfigurationSelect OptionDescription="@T("Minimum required audit level")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.MinimumLevel)" Data="@ConfigurationSelectDataFactory.GetAssistantAuditLevelsData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AssistantPluginAudit.MinimumLevel = selectedValue)" OptionHelp="@T("External Assistants rated below this audit level are treated as insufficiently reviewed.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.MinimumLevel, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@T("Block activation below the minimum Audit-Level?")" LabelOn="@T("Activation is blocked below the minimum Audit-Level")" LabelOff="@T("Users may still activate plugins below the minimum Audit-Level")" State="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.BlockActivationBelowMinimum)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AssistantPluginAudit.BlockActivationBelowMinimum = updatedState)"
OptionHelp="@TA("The audit shows you all security risks and information. If you consider this rating false at your own discretion, you can decide to install it anyway (not recommended).")"/>
<ConfigurationOption OptionDescription="@T("Automatically audit new or updated plugins in the background?")" LabelOn="@T("Security audit is automatically done in the background")" LabelOff="@T("Security audit is done manually by the user")" State="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.AutomaticallyAuditAssistants)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AssistantPluginAudit.AutomaticallyAuditAssistants = updatedState)" />
OptionHelp="@TA("The audit shows you all security risks and information. If you consider this rating false at your own discretion, you can decide to install it anyway (not recommended).")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.BlockActivationBelowMinimum, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@T("Automatically audit new or updated plugins in the background?")" LabelOn="@T("Security audit is automatically done in the background")" LabelOff="@T("Security audit is done manually by the user")" State="@(() => this.SettingsManager.ConfigurationData.AssistantPluginAudit.AutomaticallyAuditAssistants)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AssistantPluginAudit.AutomaticallyAuditAssistants = updatedState)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.AutomaticallyAuditAssistants, out var meta) && meta.IsLocked"/>
@if (this.IsAutomaticAuditWithoutProvider)
{
<MudAlert Severity="Severity.Warning" Dense="@true" Class="mb-3">
<MudJustifiedText Typo="Typo.body2">
@TA("Automatic audits cannot run, because no model is available for security checks. Choose one above, or set an app-wide default provider in the app options.")
</MudJustifiedText>
</MudAlert>
}
</MudPaper>
</ExpansionPanel>
@@ -1,37 +1,48 @@
using AIStudio.Dialogs;
using AIStudio.Tools.PluginSystem.Assistants;
using Microsoft.AspNetCore.Components;
using DialogOptions = AIStudio.Dialogs.DialogOptions;
namespace AIStudio.Components.Settings;
public partial class SettingsPanelAgentAssistantAudit : SettingsPanelBase
{
private async Task RequireAuditBeforeActivationChanged(bool updatedState)
[Inject]
private AssistantPluginAuditService AssistantPluginAuditService { get; init; } = null!;
/// <summary>
/// Whether automatic audits are switched on, although no provider is left for them.
/// </summary>
/// <remarks>
/// Without a provider, the automatic audit skips every plugin. The least any audit requires decides here:
/// should no provider meet it, none meets what a particular plugin requires either.
/// </remarks>
private bool IsAutomaticAuditWithoutProvider => this.SettingsManager.ConfigurationData.AssistantPluginAudit.AutomaticallyAuditAssistants && !this.AssistantPluginAuditService.PreviewProvider().HasProvider;
/// <summary>
/// Asks the user before they turn off the audit before activation; turning it on needs no confirmation.
/// </summary>
/// <param name="updatedState">The state the user chose.</param>
/// <returns>True when the option may take the state.</returns>
private async Task<bool> ConfirmRequireAuditBeforeActivationChange(bool updatedState)
{
if (!updatedState)
if (updatedState)
return true;
var dialogParameters = new DialogParameters<ConfirmDialog>
{
var dialogParameters = new DialogParameters<ConfirmDialog>
{
{
x => x.Message,
this.TA("Disabling this setting turns off assistant plugin security audits. External assistants may then be activated and used even without a valid audit or after plugin changes. Do you really want to disable this protection?")
},
};
x => x.Message,
TA("Disabling this setting turns off assistant plugin security audits. External assistants may then be activated and used even without a valid audit or after plugin changes. Do you really want to disable this protection?")
},
};
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(
this.T("Disable Assistant Audit Protection"),
dialogParameters,
DialogOptions.FULLSCREEN);
var dialogResult = await dialogReference.Result;
if (dialogResult is null || dialogResult.Canceled)
{
await this.InvokeAsync(this.StateHasChanged);
return;
}
}
this.SettingsManager.ConfigurationData.AssistantPluginAudit.RequireAuditBeforeActivation = updatedState;
await this.SettingsManager.StoreSettings();
await this.SendMessage<bool>(Event.CONFIGURATION_CHANGED);
await this.InvokeAsync(this.StateHasChanged);
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(
T("Disable Assistant Audit Protection"),
dialogParameters,
DialogOptions.FULLSCREEN);
var dialogResult = await dialogReference.Result;
return dialogResult is { Canceled: false };
}
}
}
@@ -1,11 +1,13 @@
@using AIStudio.Settings
@inherits SettingsPanelBase
<ExpansionPanel HeaderIcon="@AppIcons.AGENT_CONTENT_CLEANER" HeaderText="@T("Agent: Text Content Cleaner Options")">
<ExpansionPanel HeaderIcon="@AppIcons.TEXT_CONTENT_CLEANER" HeaderText="@T("AI Task: Text Content Cleaner")">
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@T("Use Case: this agent is used to clean up text content. It extracts the main content, removes advertisements and other irrelevant things, and attempts to convert relative links into absolute links so that they can be used.")
@T("When an assistant loads content from the web, a model can clean it up: it extracts the main content, removes advertisements and other irrelevant things, and attempts to convert relative links into absolute links so that they can be used.")
</MudJustifiedText>
<ConfigurationOption OptionDescription="@T("Preselect text content cleaner options?")" LabelOn="@T("Options are preselected")" LabelOff="@T("No options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions = updatedState)" OptionHelp="@TA("When enabled, you can preselect some agent options. This might be useful when you prefer an LLM.")"/>
<ConfigurationProviderSelection Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectedAgentProvider = selectedValue)"/>
<ConfigurationOption OptionDescription="@T("Preselect text content cleaner options?")" LabelOn="@T("Options are preselected")" LabelOff="@T("No options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions = updatedState)" OptionHelp="@TA("When enabled, you can preselect the model for this task and the confidence it needs. Without a preselected model, AI Studio uses the model of the assistant.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.TextContentCleaner, x => x.PreselectAgentOptions, out var meta) && meta.IsLocked"/>
<ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.TextContentCleaner.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.TextContentCleaner.MinimumProviderConfidence = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.TextContentCleaner, x => x.MinimumProviderConfidence, out var meta) && meta.IsLocked"/>
<ConfigurationProviderSelection Component="Components.AGENT_TEXT_CONTENT_CLEANER" EmptySelectionText="@T("Use the model of the assistant")" Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectedAgentProvider = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.TextContentCleaner, x => x.PreselectedAgentProvider, out var meta) && meta.IsLocked"/>
</MudPaper>
</ExpansionPanel>
@@ -1,12 +1,13 @@
@using AIStudio.Settings
@inherits SettingsPanelBase
<ExpansionPanel HeaderIcon="@AppIcons.AGENT_DATA_SOURCE_SELECTION" HeaderText="@T("Agent: Data Source Selection Options")">
<ExpansionPanel HeaderIcon="@AppIcons.DATA_SOURCE_SELECTION" HeaderText="@T("AI Task: Data Source Selection")">
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@T("Use Case: this agent is used to select the appropriate data sources for the current prompt.")
@T("In classic RAG, which searches the data sources with every message, a model first selects the data sources which fit the current prompt.")
</MudJustifiedText>
<ConfigurationOption OptionDescription="@T("Preselect data source selection options?")" LabelOn="@T("Options are preselected")" LabelOff="@T("No options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions = updatedState)" OptionHelp="@TA("When enabled, you can preselect some agent options. This might be useful when you prefer an LLM.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentDataSourceSelection, x => x.PreselectAgentOptions, out var meta) && meta.IsLocked"/>
<ConfigurationProviderSelection Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentDataSourceSelection, x => x.PreselectedAgentProvider, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@T("Preselect data source selection options?")" LabelOn="@T("Options are preselected")" LabelOff="@T("No options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions = updatedState)" OptionHelp="@TA("When enabled, you can preselect the model for this task and the confidence it needs. Without a preselected model, AI Studio uses the model of the chat.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentDataSourceSelection, x => x.PreselectAgentOptions, out var meta) && meta.IsLocked"/>
<ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.MinimumProviderConfidence = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentDataSourceSelection, x => x.MinimumProviderConfidence, out var meta) && meta.IsLocked"/>
<ConfigurationProviderSelection Component="Components.AGENT_DATA_SOURCE_SELECTION" EmptySelectionText="@T("Use the model of the chat")" Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentDataSourceSelection, x => x.PreselectedAgentProvider, out var meta) && meta.IsLocked"/>
</MudPaper>
</ExpansionPanel>
@@ -1,17 +1,18 @@
@using AIStudio.Settings
@inherits SettingsPanelBase
<ExpansionPanel HeaderIcon="@AppIcons.AGENT_RETRIEVAL_CONTEXT_VALIDATION" HeaderText="@T("Agent: Retrieval Context Validation Options")">
<ExpansionPanel HeaderIcon="@AppIcons.RETRIEVAL_CONTEXT_VALIDATION" HeaderText="@T("AI Task: Retrieval Context Validation")">
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@TA("Use Case: this agent is used to validate any retrieval context of any retrieval process. Perhaps there are many of these retrieval contexts and you want to validate them all. Therefore, you might want to use a cheap and fast LLM for this job. When using a local or self-hosted LLM, look for a small (e.g. 3B) and fast model.")
@TA("In classic RAG, a model checks each retrieval context, i.e., each passage found in the data sources, whether it fits the current prompt. There can be many of them, so you might want to use a cheap and fast model for this job. When using a local or self-hosted model, look for a small (e.g., 3B) and fast one.")
</MudJustifiedText>
<ConfigurationOption OptionDescription="@T("Enable the retrieval context validation agent?")" LabelOn="@T("The validation agent is enabled")" LabelOff="@T("No validation is performed")" State="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation = updatedState)" OptionHelp="@T("When enabled, the retrieval context validation agent will check each retrieval context of any retrieval process, whether a context makes sense for the given prompt.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.EnableRetrievalContextValidation, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@T("Validate the retrieval contexts?")" LabelOn="@T("Each retrieval context is validated")" LabelOff="@T("No validation is performed")" State="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation = updatedState)" OptionHelp="@T("When enabled, a model checks each retrieval context of classic RAG, whether it makes sense for the given prompt.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.EnableRetrievalContextValidation, out var meta) && meta.IsLocked"/>
@if (this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation)
{
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
<ConfigurationOption OptionDescription="@T("Preselect retrieval context validation options?")" LabelOn="@T("Options are preselected")" LabelOff="@T("No options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions = updatedState)" OptionHelp="@TA("When enabled, you can preselect some agent options. This might be useful when you prefer an LLM.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.PreselectAgentOptions, out var meta) && meta.IsLocked"/>
<ConfigurationSlider T="int" OptionDescription="@T("How many validation agents should work simultaneously?")" Min="1" Max="100" Step="1" Unit="@T("agents")" Value="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.NumParallelValidations)" ValueUpdate="@(updatedValue => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.NumParallelValidations = updatedValue)" OptionHelp="@TA("More active agents also mean that a corresponding number of requests are made simultaneously. Some providers limit the number of requests per minute. When you are unsure, choose a low setting between 1 to 6 agents.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.NumParallelValidations, out var meta) && meta.IsLocked"/>
<ConfigurationProviderSelection Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.PreselectedAgentProvider, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@T("Preselect retrieval context validation options?")" LabelOn="@T("Options are preselected")" LabelOff="@T("No options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions = updatedState)" OptionHelp="@TA("When enabled, you can preselect the model for this task, the confidence it needs, and how many validations run simultaneously. Without a preselected model, AI Studio uses the model of the chat.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.PreselectAgentOptions, out var meta) && meta.IsLocked"/>
<ConfigurationSlider T="int" OptionDescription="@T("How many validations should run simultaneously?")" Min="1" Max="100" Step="1" Unit="@T("validations")" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" Value="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.NumParallelValidations)" ValueUpdate="@(updatedValue => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.NumParallelValidations = updatedValue)" OptionHelp="@TA("Each validation is a request of its own, so more simultaneous validations mean as many simultaneous requests. Some providers limit the number of requests per minute. When you are unsure, choose a low setting between 1 and 6 validations.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.NumParallelValidations, out var meta) && meta.IsLocked"/>
<ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.MinimumProviderConfidence = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.MinimumProviderConfidence, out var meta) && meta.IsLocked"/>
<ConfigurationProviderSelection Component="Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION" EmptySelectionText="@T("Use the model of the chat")" Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider = selectedValue)" IsLocked="() => ManagedConfiguration.TryGet(x => x.AgentRetrievalContextValidation, x => x.PreselectedAgentProvider, out var meta) && meta.IsLocked"/>
</MudPaper>
}
</ExpansionPanel>
@@ -23,7 +23,7 @@
<ConfigurationOption OptionDescription="@T("Close messages about exported files automatically?")" LabelOn="@T("The message closes after a few seconds")" LabelOff="@TA("The message stays until you close it")" State="@(() => this.SettingsManager.ConfigurationData.App.CloseExportMessagesAutomatically)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.App.CloseExportMessagesAutomatically = updatedState)" OptionHelp="@TA("After you export a file, for example, an answer or a presentation, a message offers to show the file in your file manager or to open it. When enabled, this message closes after a few seconds, like other messages. When disabled, it stays until you close it.")"/>
<ConfigurationOption OptionDescription="@T("Show details when suspicious content was removed?")" LabelOn="@T("A dialog lists what was removed and explains the attack pattern")" LabelOff="@T("Only a short notification is shown")" State="@(() => this.SettingsManager.ConfigurationData.App.ShowPromptInjectionAlert)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.App.ShowPromptInjectionAlert = updatedState)" OptionHelp="@T("Shows a dialog listing the removed passages, together with an explanation and an external reference.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.ShowPromptInjectionAlert, out var meta) && meta.IsLocked"/>
<ConfigurationSlider T="int" OptionDescription="@T("Request timeout")" Min="@ExternalHttpClientTimeout.MIN_HTTP_CLIENT_TIMEOUT_SECONDS" Max="@ExternalHttpClientTimeout.MAX_HTTP_CLIENT_TIMEOUT_SECONDS" Step="60" Unit="@T("seconds")" Value="@(() => this.SettingsManager.ConfigurationData.App.HttpClientTimeoutSeconds)" ValueUpdate="@(updatedValue => this.SettingsManager.ConfigurationData.App.HttpClientTimeoutSeconds = updatedValue)" OptionHelp="@T("How long AI Studio waits for external HTTP requests, such as AI providers, embeddings, transcription, ERI data sources, and enterprise configuration downloads.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.HttpClientTimeoutSeconds, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@TA("Share feature usage with operators of self-hosted servers?")" LabelOn="@T("Operators of self-hosted servers learn which feature sent a request")" LabelOff="@T("No usage details are sent")" State="@(() => this.SettingsManager.ConfigurationData.App.ShareFeatureUsageWithSelfHostedServerOperators)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.App.ShareFeatureUsageWithSelfHostedServerOperators = updatedState)" OptionHelp="@TA("When enabled, requests to self-hosted providers and LiteLLM name the feature that sent them, e.g., the chat, an assistant, or an agent, together with the version of AI Studio and your operating system. This lets the operators of these servers, usually your organization, see which features are used. Cloud providers never receive these details, and AI Studio never sends anything to its developers.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.ShareFeatureUsageWithSelfHostedServerOperators, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@TA("Share feature usage with operators of self-hosted servers?")" LabelOn="@T("Operators of self-hosted servers learn which feature sent a request")" LabelOff="@T("No usage details are sent")" State="@(() => this.SettingsManager.ConfigurationData.App.ShareFeatureUsageWithSelfHostedServerOperators)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.App.ShareFeatureUsageWithSelfHostedServerOperators = updatedState)" OptionHelp="@TA("When enabled, requests to self-hosted providers and LiteLLM name the feature that sent them, e.g., the chat, an assistant, or an AI task, together with the version of AI Studio and your operating system. This lets the operators of these servers, usually your organization, see which features are used. Cloud providers never receive these details, and AI Studio never sends anything to its developers.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.ShareFeatureUsageWithSelfHostedServerOperators, out var meta) && meta.IsLocked"/>
<ConfigurationSelect OptionDescription="@T("Check for updates")" SelectedValue="@(() => this.DisplayedUpdateInterval)" Data="@ConfigurationSelectDataFactory.GetManagedUpdateIntervalData(this.DisplayedUpdateInterval)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.UpdateInterval = selectedValue)" OptionHelp="@this.UpdateIntervalHelp" IsLocked="@this.IsUpdateIntervalLocked"/>
<ConfigurationSelect OptionDescription="@T("Update installation method")" SelectedValue="@(() => this.DisplayedUpdateInstallation)" Data="@ConfigurationSelectDataFactory.GetUpdateBehaviourData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.UpdateInstallation = selectedValue)" OptionHelp="@this.UpdateInstallationHelp" IsLocked="@this.IsUpdateInstallationLocked"/>
<ConfigurationSelect OptionDescription="@T("Navigation bar behavior")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.App.NavigationBehavior)" Data="@ConfigurationSelectDataFactory.GetNavBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.NavigationBehavior = selectedValue)" OptionHelp="@TA("Select the desired behavior for the navigation bar.")"/>