mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 20:32:11 +00:00
Merge branch 'main' into pr/823
This commit is contained in:
commit
c88f26f343
47
app/Build/Commands/AssistantPluginHashCommand.cs
Normal file
47
app/Build/Commands/AssistantPluginHashCommand.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using SharedTools;
|
||||
|
||||
namespace Build.Commands;
|
||||
|
||||
public sealed class AssistantPluginHashCommand
|
||||
{
|
||||
[Command("assistant-plugin-hash", Description = "Compute the canonical assistant-plugin hash for a plugin directory")]
|
||||
public void ComputeAssistantPluginHash(
|
||||
[Argument(Description = "Path to the assistant plugin directory")] string pluginDir,
|
||||
[Option("lua-snippet", Description = "Also print a Lua snippet for CONFIG[\"SETTINGS\"]")] bool luaSnippet = false)
|
||||
{
|
||||
if (!Environment.IsWorkingDirectoryValid())
|
||||
return;
|
||||
|
||||
var resolvedPath = Path.GetFullPath(pluginDir, Directory.GetCurrentDirectory());
|
||||
if (!Directory.Exists(resolvedPath))
|
||||
{
|
||||
Console.WriteLine($"- Error: The plugin directory '{resolvedPath}' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var pluginHash = AssistantPluginHash.Compute(resolvedPath);
|
||||
if (string.IsNullOrWhiteSpace(pluginHash))
|
||||
{
|
||||
Console.WriteLine($"- Error: No Lua files were found in '{resolvedPath}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine(pluginHash);
|
||||
|
||||
if (!luaSnippet)
|
||||
return;
|
||||
|
||||
var displayName = Path.GetFileName(resolvedPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
|
||||
var approvedAtUtc = DateTimeOffset.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("""CONFIG["SETTINGS"]["DataAssistantPluginAudit.EnterpriseApprovedPlugins"] = {""");
|
||||
Console.WriteLine(" {");
|
||||
Console.WriteLine($""" ["PluginHash"] = "{pluginHash}",""");
|
||||
Console.WriteLine($""" ["DisplayName"] = "{displayName}",""");
|
||||
Console.WriteLine(""" ["Comment"] = "<optional comment>",""");
|
||||
Console.WriteLine(""" ["ApprovedBy"] = "<optional approver>",""");
|
||||
Console.WriteLine($""" ["ApprovedAtUtc"] = "{approvedAtUtc}",""");
|
||||
Console.WriteLine(" }");
|
||||
Console.WriteLine("}");
|
||||
}
|
||||
}
|
||||
@ -6,4 +6,5 @@ app.AddCommands<CheckRidsCommand>();
|
||||
app.AddCommands<UpdateMetadataCommands>();
|
||||
app.AddCommands<UpdateWebAssetsCommand>();
|
||||
app.AddCommands<CollectI18NKeysCommand>();
|
||||
app.Run();
|
||||
app.AddCommands<AssistantPluginHashCommand>();
|
||||
app.Run();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.Agenda;
|
||||
|
||||
@ -185,6 +186,85 @@ public partial class AssistantAgenda : AssistantBaseCore<SettingsDialogAgenda>
|
||||
private string inputWhoIsPresenting = string.Empty;
|
||||
|
||||
private readonly List<string> contentLines = [];
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TOPIC_STATE_KEY = new(nameof(inputTopic));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_NAME_STATE_KEY = new(nameof(inputName));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_CONTENT_STATE_KEY = new(nameof(inputContent));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_DURATION_STATE_KEY = new(nameof(inputDuration));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_START_TIME_STATE_KEY = new(nameof(inputStartTime));
|
||||
private static readonly AssistantSessionStateKey<HashSet<string>> SELECTED_FOCI_STATE_KEY = new(nameof(selectedFoci));
|
||||
private static readonly AssistantSessionStateKey<HashSet<string>> JUST_BRIEFLY_STATE_KEY = new(nameof(justBriefly));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_OBJECTIVE_STATE_KEY = new(nameof(inputObjective));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_MODERATOR_STATE_KEY = new(nameof(inputModerator));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<bool> INTRODUCE_PARTICIPANTS_STATE_KEY = new(nameof(introduceParticipants));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_MEETING_VIRTUAL_STATE_KEY = new(nameof(isMeetingVirtual));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_LOCATION_STATE_KEY = new(nameof(inputLocation));
|
||||
private static readonly AssistantSessionStateKey<bool> GOING_TO_DINNER_STATE_KEY = new(nameof(goingToDinner));
|
||||
private static readonly AssistantSessionStateKey<bool> DOING_SOCIAL_ACTIVITY_STATE_KEY = new(nameof(doingSocialActivity));
|
||||
private static readonly AssistantSessionStateKey<bool> NEED_TO_ARRIVE_AND_DEPART_STATE_KEY = new(nameof(needToArriveAndDepart));
|
||||
private static readonly AssistantSessionStateKey<int> DURATION_LUNCH_BREAK_STATE_KEY = new(nameof(durationLunchBreak));
|
||||
private static readonly AssistantSessionStateKey<int> DURATION_BREAKS_STATE_KEY = new(nameof(durationBreaks));
|
||||
private static readonly AssistantSessionStateKey<bool> ACTIVE_PARTICIPATION_STATE_KEY = new(nameof(activeParticipation));
|
||||
private static readonly AssistantSessionStateKey<NumberParticipants> NUMBER_PARTICIPANTS_STATE_KEY = new(nameof(numberParticipants));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_WHO_IS_PRESENTING_STATE_KEY = new(nameof(inputWhoIsPresenting));
|
||||
private static readonly AssistantSessionStateKey<List<string>> CONTENT_LINES_STATE_KEY = new(nameof(contentLines));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_TOPIC_STATE_KEY, this.inputTopic);
|
||||
state.Set(INPUT_NAME_STATE_KEY, this.inputName);
|
||||
state.Set(INPUT_CONTENT_STATE_KEY, this.inputContent);
|
||||
state.Set(INPUT_DURATION_STATE_KEY, this.inputDuration);
|
||||
state.Set(INPUT_START_TIME_STATE_KEY, this.inputStartTime);
|
||||
state.SetHashSet(SELECTED_FOCI_STATE_KEY, this.selectedFoci);
|
||||
state.SetHashSet(JUST_BRIEFLY_STATE_KEY, this.justBriefly);
|
||||
state.Set(INPUT_OBJECTIVE_STATE_KEY, this.inputObjective);
|
||||
state.Set(INPUT_MODERATOR_STATE_KEY, this.inputModerator);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(INTRODUCE_PARTICIPANTS_STATE_KEY, this.introduceParticipants);
|
||||
state.Set(IS_MEETING_VIRTUAL_STATE_KEY, this.isMeetingVirtual);
|
||||
state.Set(INPUT_LOCATION_STATE_KEY, this.inputLocation);
|
||||
state.Set(GOING_TO_DINNER_STATE_KEY, this.goingToDinner);
|
||||
state.Set(DOING_SOCIAL_ACTIVITY_STATE_KEY, this.doingSocialActivity);
|
||||
state.Set(NEED_TO_ARRIVE_AND_DEPART_STATE_KEY, this.needToArriveAndDepart);
|
||||
state.Set(DURATION_LUNCH_BREAK_STATE_KEY, this.durationLunchBreak);
|
||||
state.Set(DURATION_BREAKS_STATE_KEY, this.durationBreaks);
|
||||
state.Set(ACTIVE_PARTICIPATION_STATE_KEY, this.activeParticipation);
|
||||
state.Set(NUMBER_PARTICIPANTS_STATE_KEY, this.numberParticipants);
|
||||
state.Set(INPUT_WHO_IS_PRESENTING_STATE_KEY, this.inputWhoIsPresenting);
|
||||
state.SetList(CONTENT_LINES_STATE_KEY, this.contentLines);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_TOPIC_STATE_KEY, value => this.inputTopic = value);
|
||||
state.Restore(INPUT_NAME_STATE_KEY, value => this.inputName = value);
|
||||
state.Restore(INPUT_CONTENT_STATE_KEY, value => this.inputContent = value);
|
||||
state.Restore(INPUT_DURATION_STATE_KEY, value => this.inputDuration = value);
|
||||
state.Restore(INPUT_START_TIME_STATE_KEY, value => this.inputStartTime = value);
|
||||
state.Restore(SELECTED_FOCI_STATE_KEY, value => this.selectedFoci = value);
|
||||
state.Restore(JUST_BRIEFLY_STATE_KEY, value => this.justBriefly = value);
|
||||
state.Restore(INPUT_OBJECTIVE_STATE_KEY, value => this.inputObjective = value);
|
||||
state.Restore(INPUT_MODERATOR_STATE_KEY, value => this.inputModerator = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(INTRODUCE_PARTICIPANTS_STATE_KEY, value => this.introduceParticipants = value);
|
||||
state.Restore(IS_MEETING_VIRTUAL_STATE_KEY, value => this.isMeetingVirtual = value);
|
||||
state.Restore(INPUT_LOCATION_STATE_KEY, value => this.inputLocation = value);
|
||||
state.Restore(GOING_TO_DINNER_STATE_KEY, value => this.goingToDinner = value);
|
||||
state.Restore(DOING_SOCIAL_ACTIVITY_STATE_KEY, value => this.doingSocialActivity = value);
|
||||
state.Restore(NEED_TO_ARRIVE_AND_DEPART_STATE_KEY, value => this.needToArriveAndDepart = value);
|
||||
state.Restore(DURATION_LUNCH_BREAK_STATE_KEY, value => this.durationLunchBreak = value);
|
||||
state.Restore(DURATION_BREAKS_STATE_KEY, value => this.durationBreaks = value);
|
||||
state.Restore(ACTIVE_PARTICIPATION_STATE_KEY, value => this.activeParticipation = value);
|
||||
state.Restore(NUMBER_PARTICIPANTS_STATE_KEY, value => this.numberParticipants = value);
|
||||
state.Restore(INPUT_WHO_IS_PRESENTING_STATE_KEY, value => this.inputWhoIsPresenting = value);
|
||||
state.RestoreList(CONTENT_LINES_STATE_KEY, this.contentLines);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
<InnerScrolling>
|
||||
<ChildContent>
|
||||
<MudForm @ref="@(this.Form)" @bind-IsValid="@(this.InputIsValid)" @bind-Errors="@(this.inputIssues)" FieldChanged="@this.TriggerFormChange" Class="pr-2">
|
||||
<MudForm @ref="@(this.Form)" @bind-IsValid="@(this.InputIsValid)" @bind-Errors="@(this.InputIssues)" FieldChanged="@this.TriggerFormChange" Class="pr-2">
|
||||
<MudText Typo="Typo.body1" Align="Align.Justify" Class="mb-2">
|
||||
@this.Description
|
||||
</MudText>
|
||||
@ -38,10 +38,10 @@
|
||||
</CascadingValue>
|
||||
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" StretchItems="StretchItems.Start" Class="mb-3">
|
||||
<MudButton Disabled="@(this.SubmitDisabled || this.isProcessing)" Variant="Variant.Filled" OnClick="@(async () => await this.Start())" Style="@this.SubmitButtonStyle">
|
||||
<MudButton Disabled="@(this.SubmitDisabled || this.IsProcessing)" Variant="Variant.Filled" OnClick="@(async () => await this.Start())" Style="@this.SubmitButtonStyle">
|
||||
@this.SubmitText
|
||||
</MudButton>
|
||||
@if (this.isProcessing && this.CancellationTokenSource is not null)
|
||||
@if (this.IsProcessing)
|
||||
{
|
||||
<MudTooltip Text="@TB("Stop generation")">
|
||||
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Filled.Stop" Color="Color.Error" OnClick="@(async () => await this.CancelStreaming())"/>
|
||||
@ -60,9 +60,9 @@
|
||||
}
|
||||
}
|
||||
</MudForm>
|
||||
<Issues IssuesData="@(this.inputIssues)"/>
|
||||
<Issues IssuesData="@(this.InputIssues)"/>
|
||||
|
||||
@if (this.ShowDedicatedProgress && this.isProcessing)
|
||||
@if (this.ShowDedicatedProgress && this.IsProcessing)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="mb-6" />
|
||||
}
|
||||
@ -73,9 +73,9 @@
|
||||
<div id="@BEFORE_RESULT_DIV_ID" class="mt-3">
|
||||
</div>
|
||||
|
||||
@if (this.ShowResult && !this.ShowEntireChatThread && this.resultingContentBlock is not null && this.resultingContentBlock.Content is not null)
|
||||
@if (this.ShowResult && !this.ShowEntireChatThread && this.ResultingContentBlock is not null && this.ResultingContentBlock.Content is not null)
|
||||
{
|
||||
<ContentBlockComponent Role="@(this.resultingContentBlock.Role)" Type="@(this.resultingContentBlock.ContentType)" Time="@(this.resultingContentBlock.Time)" Content="@this.resultingContentBlock.Content"/>
|
||||
<ContentBlockComponent Role="@(this.ResultingContentBlock.Role)" Type="@(this.ResultingContentBlock.ContentType)" Time="@(this.ResultingContentBlock.Time)" Content="@this.ResultingContentBlock.Content"/>
|
||||
}
|
||||
|
||||
@if(this.ShowResult && this.ShowEntireChatThread && this.ChatThread is not null)
|
||||
|
||||
@ -2,6 +2,8 @@ using AIStudio.Chat;
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AIJobs;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@ -36,6 +38,15 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
[Inject]
|
||||
private MudTheme ColorTheme { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected AssistantSessionService AssistantSessionService { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the job service used to run assistant-created chats independently from the assistant UI.
|
||||
/// </summary>
|
||||
[Inject]
|
||||
protected AIJobService AIJobService { get; init; } = null!;
|
||||
|
||||
protected abstract string Title { get; }
|
||||
|
||||
@ -45,7 +56,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
protected abstract Tools.Components Component { get; }
|
||||
|
||||
protected virtual Func<string> Result2Copy => () => this.resultingContentBlock is null ? string.Empty : this.resultingContentBlock.Content switch
|
||||
protected virtual Func<string> Result2Copy => () => this.ResultingContentBlock is null ? string.Empty : this.ResultingContentBlock.Content switch
|
||||
{
|
||||
ContentText textBlock => textBlock.Text,
|
||||
_ => string.Empty,
|
||||
@ -115,20 +126,29 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
protected virtual bool HasSettingsPanel => typeof(TSettings) != typeof(NoSettingsPanel);
|
||||
|
||||
protected AIStudio.Settings.Provider ProviderSettings = Settings.Provider.NONE;
|
||||
protected MudForm? Form;
|
||||
protected bool InputIsValid;
|
||||
protected Profile CurrentProfile = Profile.NO_PROFILE;
|
||||
protected ChatTemplate CurrentChatTemplate = ChatTemplate.NO_CHAT_TEMPLATE;
|
||||
protected ChatThread? ChatThread;
|
||||
protected IContent? LastUserPrompt;
|
||||
protected CancellationTokenSource? CancellationTokenSource;
|
||||
|
||||
private readonly Timer formChangeTimer = new(TimeSpan.FromSeconds(1.6));
|
||||
|
||||
protected MudForm? Form;
|
||||
protected CancellationTokenSource? CancellationTokenSource;
|
||||
private bool isDisposed;
|
||||
private AssistantSessionKey assistantSessionKey;
|
||||
private Guid? assistantSessionId;
|
||||
private AssistantSessionSnapshot? pendingRenderedAssistantSessionSnapshot;
|
||||
|
||||
private ContentBlock? resultingContentBlock;
|
||||
private string[] inputIssues = [];
|
||||
private bool isProcessing;
|
||||
/// <summary>
|
||||
/// Gets whether the Blazor component instance has already been disposed.
|
||||
/// </summary>
|
||||
protected bool IsAssistantComponentDisposed => this.isDisposed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this component has attached an assistant session snapshot.
|
||||
/// </summary>
|
||||
protected bool HasAssistantSession => this.assistantSessionId is not null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assistant-specific identifier used to distinguish session slots.
|
||||
/// </summary>
|
||||
protected virtual string AssistantSessionInstanceId => this.GetType().FullName ?? this.Component.ToString();
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
@ -154,6 +174,8 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
this.ProviderSettings = this.SettingsManager.GetPreselectedProvider(this.Component);
|
||||
this.CurrentProfile = this.SettingsManager.GetPreselectedProfile(this.Component);
|
||||
this.CurrentChatTemplate = this.SettingsManager.GetPreselectedChatTemplate(this.Component);
|
||||
this.assistantSessionKey = new(this.Component, this.AssistantSessionInstanceId);
|
||||
await this.AttachAssistantSessionIfAvailable();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
@ -170,6 +192,12 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
// We don't want to show validation errors when the user opens the dialog.
|
||||
if(firstRender)
|
||||
this.Form?.ResetValidation();
|
||||
|
||||
if (this.pendingRenderedAssistantSessionSnapshot is { } snapshot)
|
||||
{
|
||||
this.pendingRenderedAssistantSessionSnapshot = null;
|
||||
await this.OnAssistantSessionRenderedAsync(snapshot);
|
||||
}
|
||||
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
@ -195,12 +223,67 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
private async Task Start()
|
||||
{
|
||||
using (this.CancellationTokenSource = new())
|
||||
var activeSession = this.AssistantSessionService.TryGetSnapshot(this.assistantSessionKey);
|
||||
if (activeSession?.IsActive ?? false)
|
||||
{
|
||||
await this.AttachAssistantSession(activeSession, restoreClientOnlyContent: true);
|
||||
return;
|
||||
}
|
||||
|
||||
this.CancellationTokenSource = new();
|
||||
this.IsProcessing = true;
|
||||
var startedSession = await this.AssistantSessionService.TryBeginAsync(this.assistantSessionKey, this.Title, this.CancellationTokenSource, this.ChatThread, this.CaptureAssistantSessionState(), this);
|
||||
if (startedSession.IsActive is not true || startedSession.Key != this.assistantSessionKey)
|
||||
{
|
||||
this.CancellationTokenSource.Dispose();
|
||||
this.CancellationTokenSource = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.assistantSessionId = startedSession.SessionId;
|
||||
await this.RefreshAssistantUIAsync();
|
||||
|
||||
var sessionStatus = AssistantSessionStatus.COMPLETED;
|
||||
var errorMessage = string.Empty;
|
||||
try
|
||||
{
|
||||
await this.SubmitAction();
|
||||
|
||||
if (this.CancellationTokenSource?.IsCancellationRequested ?? false)
|
||||
sessionStatus = AssistantSessionStatus.CANCELED;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
sessionStatus = AssistantSessionStatus.CANCELED;
|
||||
}
|
||||
catch (ProviderRequestException e)
|
||||
{
|
||||
sessionStatus = AssistantSessionStatus.FAILED;
|
||||
errorMessage = e.UserMessage;
|
||||
this.Logger.LogError(e, "The provider request failed for assistant '{AssistantTitle}'. Status={StatusCode}, Reason='{ReasonPhrase}', Body='{ResponseBody}'", this.Title, e.StatusCode, e.ReasonPhrase, e.ResponseBody);
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.CloudOff, e.UserMessage));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
sessionStatus = AssistantSessionStatus.FAILED;
|
||||
errorMessage = e.Message;
|
||||
this.Logger.LogError(e, "The assistant session '{AssistantTitle}' failed.", this.Title);
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Stream, string.Format(this.TB("The assistant failed. The message is: '{0}'"), e.Message)));
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.IsProcessing = false;
|
||||
var sessionCancellationTokenSource = this.CancellationTokenSource;
|
||||
this.CancellationTokenSource = null;
|
||||
if (this.assistantSessionId is { } sessionId)
|
||||
{
|
||||
await this.AssistantSessionService.CompleteAsync(this.assistantSessionKey, sessionId, sessionStatus, errorMessage, this.ChatThread, this.CaptureAssistantSessionState(), this);
|
||||
if (!this.isDisposed)
|
||||
_ = this.AssistantSessionService.TryTakeInactiveSnapshot(this.assistantSessionKey);
|
||||
}
|
||||
sessionCancellationTokenSource?.Dispose();
|
||||
await this.RefreshAssistantUIAsync();
|
||||
}
|
||||
|
||||
this.CancellationTokenSource = null;
|
||||
}
|
||||
|
||||
private void TriggerFormChange(FormFieldChangedEventArgs _)
|
||||
@ -225,10 +308,10 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
/// <param name="issue">The issue to add.</param>
|
||||
protected void AddInputIssue(string issue)
|
||||
{
|
||||
Array.Resize(ref this.inputIssues, this.inputIssues.Length + 1);
|
||||
this.inputIssues[^1] = issue;
|
||||
Array.Resize(ref this.InputIssues, this.InputIssues.Length + 1);
|
||||
this.InputIssues[^1] = issue;
|
||||
this.InputIsValid = false;
|
||||
this.StateHasChanged();
|
||||
_ = this.RefreshAssistantUIAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -236,9 +319,9 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
/// </summary>
|
||||
protected void ClearInputIssues()
|
||||
{
|
||||
this.inputIssues = [];
|
||||
this.InputIssues = [];
|
||||
this.InputIsValid = true;
|
||||
this.StateHasChanged();
|
||||
_ = this.RefreshAssistantUIAsync();
|
||||
}
|
||||
|
||||
protected void CreateChatThread()
|
||||
@ -314,7 +397,19 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
InitialRemoteWait = true,
|
||||
};
|
||||
|
||||
this.resultingContentBlock = new ContentBlock
|
||||
aiText.StreamingEvent = async () =>
|
||||
{
|
||||
await this.CheckpointAssistantSession();
|
||||
await this.RefreshAssistantUIAsync();
|
||||
};
|
||||
|
||||
aiText.StreamingDone = async () =>
|
||||
{
|
||||
await this.CheckpointAssistantSession();
|
||||
await this.RefreshAssistantUIAsync();
|
||||
};
|
||||
|
||||
this.ResultingContentBlock = new ContentBlock
|
||||
{
|
||||
Time = time,
|
||||
ContentType = ContentType.TEXT,
|
||||
@ -325,12 +420,13 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
if (this.ChatThread is not null)
|
||||
{
|
||||
this.ChatThread.Blocks.Add(this.resultingContentBlock);
|
||||
this.ChatThread.Blocks.Add(this.ResultingContentBlock);
|
||||
this.ChatThread.SelectedProvider = this.ProviderSettings.Id;
|
||||
}
|
||||
|
||||
this.isProcessing = true;
|
||||
this.StateHasChanged();
|
||||
this.IsProcessing = true;
|
||||
await this.CheckpointAssistantSession();
|
||||
await this.RefreshAssistantUIAsync();
|
||||
|
||||
try
|
||||
{
|
||||
@ -347,18 +443,19 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
this.Logger.LogError(e, "The provider request failed for assistant '{AssistantTitle}'. Status={StatusCode}, Reason='{ReasonPhrase}', Body='{ResponseBody}'", this.Title, e.StatusCode, e.ReasonPhrase, e.ResponseBody);
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.CloudOff, e.UserMessage));
|
||||
|
||||
if (this.resultingContentBlock is not null && string.IsNullOrWhiteSpace(aiText.Text))
|
||||
if (this.ResultingContentBlock is not null && string.IsNullOrWhiteSpace(aiText.Text))
|
||||
{
|
||||
this.ChatThread?.Blocks.Remove(this.resultingContentBlock);
|
||||
this.resultingContentBlock = null;
|
||||
this.ChatThread?.Blocks.Remove(this.ResultingContentBlock);
|
||||
this.ResultingContentBlock = null;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.isProcessing = false;
|
||||
this.StateHasChanged();
|
||||
this.IsProcessing = this.assistantSessionId is not null && (this.AssistantSessionService.TryGetSnapshot(this.assistantSessionKey)?.IsActive ?? false);
|
||||
await this.CheckpointAssistantSession();
|
||||
await this.RefreshAssistantUIAsync();
|
||||
|
||||
if(manageCancellationLocally)
|
||||
{
|
||||
@ -367,12 +464,54 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the current assistant chat thread as a regular background-capable chat generation job.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use this when an assistant creates a chat and hands it over to the chat page instead of
|
||||
/// rendering the answer inside the assistant UI.
|
||||
/// </remarks>
|
||||
/// <param name="time">The timestamp to use for the AI response block.</param>
|
||||
/// <param name="hideContentFromUser">Whether the AI response block should be hidden from the user.</param>
|
||||
/// <param name="isForeground">Whether the chat job should start as the current foreground job.</param>
|
||||
/// <returns>A task that completes after the chat job was registered.</returns>
|
||||
protected async Task StartChatGenerationJobAsync(DateTimeOffset time, bool hideContentFromUser = false, bool isForeground = true)
|
||||
{
|
||||
if (this.ChatThread is null)
|
||||
return;
|
||||
|
||||
var aiText = new ContentText
|
||||
{
|
||||
InitialRemoteWait = true,
|
||||
};
|
||||
|
||||
this.ResultingContentBlock = new ContentBlock
|
||||
{
|
||||
Time = time,
|
||||
ContentType = ContentType.TEXT,
|
||||
Role = ChatRole.AI,
|
||||
Content = aiText,
|
||||
HideFromUser = hideContentFromUser,
|
||||
};
|
||||
|
||||
this.ChatThread.Blocks.Add(this.ResultingContentBlock);
|
||||
this.ChatThread.SelectedProvider = this.ProviderSettings.Id;
|
||||
|
||||
await this.CheckpointAssistantSession();
|
||||
await this.AIJobService.TryStartChatGenerationAsync(new ChatGenerationRequest
|
||||
{
|
||||
ChatThread = this.ChatThread,
|
||||
AIText = aiText,
|
||||
LastUserPrompt = this.LastUserPrompt,
|
||||
ProviderSettings = this.ProviderSettings,
|
||||
IsForeground = isForeground,
|
||||
});
|
||||
}
|
||||
|
||||
private async Task CancelStreaming()
|
||||
{
|
||||
if (this.CancellationTokenSource is not null)
|
||||
if(!this.CancellationTokenSource.IsCancellationRequested)
|
||||
await this.CancellationTokenSource.CancelAsync();
|
||||
await this.AssistantSessionService.CancelAsync(this.assistantSessionKey, this);
|
||||
}
|
||||
|
||||
protected async Task CopyToClipboard()
|
||||
@ -438,15 +577,15 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
await this.DialogService.ShowAsync<TSettings>(null, dialogParameters, DialogOptions.FULLSCREEN);
|
||||
}
|
||||
|
||||
protected Task SendToAssistant(Tools.Components destination, SendToButton sendToButton)
|
||||
protected async Task SendToAssistant(Tools.Components destination, SendToButton sendToButton)
|
||||
{
|
||||
if (!this.CanSendToAssistant(destination))
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
|
||||
var contentToSend = sendToButton == default ? string.Empty : sendToButton.UseResultingContentBlockData switch
|
||||
{
|
||||
false => sendToButton.GetText(),
|
||||
true => this.resultingContentBlock?.Content switch
|
||||
true => this.ResultingContentBlock?.Content switch
|
||||
{
|
||||
ContentText textBlock => textBlock.Text,
|
||||
_ => string.Empty,
|
||||
@ -454,6 +593,16 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
};
|
||||
|
||||
var sendToData = destination.GetData();
|
||||
if (destination is not Tools.Components.CHAT && this.AssistantSessionService.GetSnapshots().Any(snapshot => snapshot.IsActive && snapshot.Key.Component == destination))
|
||||
{
|
||||
await this.MessageBus.SendWarning(new(Icons.Material.Filled.Apps, this.TB("This assistant is already running. AI Studio opens the running session instead.")));
|
||||
this.NavigationManager.NavigateTo(sendToData.Route);
|
||||
return;
|
||||
}
|
||||
|
||||
if (destination is not Tools.Components.CHAT)
|
||||
await this.AssistantSessionService.ClearInactiveSessionsForComponentAsync(destination);
|
||||
|
||||
switch (destination)
|
||||
{
|
||||
case Tools.Components.CHAT:
|
||||
@ -473,7 +622,6 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
}
|
||||
|
||||
this.NavigationManager.NavigateTo(sendToData.Route);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private bool CanSendToAssistant(Tools.Components component)
|
||||
@ -486,7 +634,12 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
private async Task InnerResetForm()
|
||||
{
|
||||
this.resultingContentBlock = null;
|
||||
if (this.AssistantSessionService.TryGetSnapshot(this.assistantSessionKey)?.IsActive ?? false)
|
||||
return;
|
||||
|
||||
await this.AssistantSessionService.ClearAsync(this.assistantSessionKey);
|
||||
this.assistantSessionId = null;
|
||||
this.ResultingContentBlock = null;
|
||||
this.ProviderSettings = Settings.Provider.NONE;
|
||||
|
||||
await this.JsRuntime.ClearDiv(RESULT_DIV_ID);
|
||||
@ -496,10 +649,10 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
this.ResetProviderAndProfileSelection();
|
||||
|
||||
this.InputIsValid = false;
|
||||
this.inputIssues = [];
|
||||
this.InputIssues = [];
|
||||
|
||||
this.Form?.ResetValidation();
|
||||
this.StateHasChanged();
|
||||
await this.RefreshAssistantUIAsync();
|
||||
this.Form?.ResetValidation();
|
||||
}
|
||||
|
||||
@ -519,6 +672,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
this.isDisposed = true;
|
||||
try
|
||||
{
|
||||
this.formChangeTimer.Stop();
|
||||
@ -533,4 +687,177 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Assistant sessions
|
||||
|
||||
/// <summary>
|
||||
/// Stores the current assistant UI and chat state in the active assistant session.
|
||||
/// </summary>
|
||||
/// <returns>A task that completes after the checkpoint was stored and published.</returns>
|
||||
private Task CheckpointAssistantSession()
|
||||
{
|
||||
if (this.assistantSessionId is null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return this.AssistantSessionService.CheckpointAsync(this.assistantSessionKey, this.assistantSessionId.Value, this.Title, this.ChatThread, this.CaptureAssistantSessionState(), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows derived assistants to restore client-only UI after a session was attached.
|
||||
/// </summary>
|
||||
/// <param name="snapshot">The assistant session snapshot that was attached.</param>
|
||||
/// <returns>A task that completes after derived UI restore work has finished.</returns>
|
||||
protected virtual Task OnAssistantSessionAttachedAsync(AssistantSessionSnapshot snapshot) => Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Allows derived assistants to restore DOM-dependent client-only UI after an attached session was rendered.
|
||||
/// </summary>
|
||||
/// <param name="snapshot">The assistant session snapshot that was rendered.</param>
|
||||
/// <returns>A task that completes after derived UI restore work has finished.</returns>
|
||||
protected virtual Task OnAssistantSessionRenderedAsync(AssistantSessionSnapshot snapshot) => Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Handles assistant session change events for the current assistant instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The message payload type.</typeparam>
|
||||
/// <param name="sendingComponent">The component that sent the message, if any.</param>
|
||||
/// <param name="triggeredEvent">The event that was triggered.</param>
|
||||
/// <param name="data">The message payload.</param>
|
||||
/// <returns>A task that completes after the message was processed.</returns>
|
||||
protected override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
||||
{
|
||||
if (ReferenceEquals(sendingComponent, this))
|
||||
return;
|
||||
|
||||
switch (triggeredEvent)
|
||||
{
|
||||
case Event.ASSISTANT_SESSION_CHANGED:
|
||||
case Event.ASSISTANT_SESSION_FINISHED:
|
||||
if (data is AssistantSessionSnapshot snapshot && snapshot.Key == this.assistantSessionKey)
|
||||
{
|
||||
await this.AttachAssistantSession(snapshot, restoreClientOnlyContent: triggeredEvent is Event.ASSISTANT_SESSION_FINISHED);
|
||||
if (triggeredEvent is Event.ASSISTANT_SESSION_FINISHED)
|
||||
_ = this.AssistantSessionService.TryTakeInactiveSnapshot(this.assistantSessionKey);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the component to an existing assistant session if one is available.
|
||||
/// </summary>
|
||||
/// <returns>A task that completes after the session was attached.</returns>
|
||||
private async Task AttachAssistantSessionIfAvailable()
|
||||
{
|
||||
var snapshot = this.AssistantSessionService.TryGetSnapshot(this.assistantSessionKey);
|
||||
if (snapshot?.IsActive ?? false)
|
||||
{
|
||||
await this.AttachAssistantSession(snapshot, restoreClientOnlyContent: true);
|
||||
return;
|
||||
}
|
||||
|
||||
snapshot = this.AssistantSessionService.TryTakeInactiveSnapshot(this.assistantSessionKey);
|
||||
if (snapshot is null)
|
||||
return;
|
||||
|
||||
await this.AttachAssistantSession(snapshot, restoreClientOnlyContent: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies an assistant session snapshot to this component instance.
|
||||
/// </summary>
|
||||
/// <param name="snapshot">The snapshot to attach.</param>
|
||||
/// <param name="restoreClientOnlyContent">Whether derived assistants should restore client-only UI state.</param>
|
||||
/// <returns>A task that completes after the component was refreshed.</returns>
|
||||
private async Task AttachAssistantSession(AssistantSessionSnapshot snapshot, bool restoreClientOnlyContent)
|
||||
{
|
||||
this.assistantSessionId = snapshot.SessionId;
|
||||
this.ImportAssistantSessionState(snapshot.State);
|
||||
this.ChatThread = snapshot.ChatThread ?? this.ChatThread;
|
||||
this.IsProcessing = snapshot.IsActive;
|
||||
|
||||
if (!snapshot.IsActive)
|
||||
this.CancellationTokenSource = null;
|
||||
|
||||
if (restoreClientOnlyContent)
|
||||
await this.OnAssistantSessionAttachedAsync(snapshot);
|
||||
|
||||
if (restoreClientOnlyContent)
|
||||
this.pendingRenderedAssistantSessionSnapshot = snapshot;
|
||||
|
||||
await this.RefreshAssistantUIAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the component when it is still mounted.
|
||||
/// </summary>
|
||||
/// <returns>A task that completes after the renderer was notified.</returns>
|
||||
private async Task RefreshAssistantUIAsync()
|
||||
{
|
||||
if (this.isDisposed)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await this.InvokeAsync(this.StateHasChanged);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// The component may already have left the renderer while a background session is finishing.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Captures the base assistant state and assistant-specific typed state values for session restore.
|
||||
/// </summary>
|
||||
/// <returns>A dictionary containing the current assistant state.</returns>
|
||||
private Dictionary<string, IAssistantSessionSnapshotField> CaptureAssistantSessionState()
|
||||
{
|
||||
var state = new AssistantSessionStateWriter();
|
||||
state.Set(PROVIDER_SETTINGS_STATE_KEY, this.ProviderSettings);
|
||||
state.Set(INPUT_IS_VALID_STATE_KEY, this.InputIsValid);
|
||||
state.Set(CURRENT_PROFILE_STATE_KEY, this.CurrentProfile);
|
||||
state.Set(CURRENT_CHAT_TEMPLATE_STATE_KEY, this.CurrentChatTemplate);
|
||||
state.Set(CHAT_THREAD_STATE_KEY, this.ChatThread);
|
||||
state.Set(LAST_USER_PROMPT_STATE_KEY, this.LastUserPrompt);
|
||||
state.Set(RESULTING_CONTENT_BLOCK_STATE_KEY, this.ResultingContentBlock);
|
||||
state.Set(INPUT_ISSUES_STATE_KEY, this.InputIssues);
|
||||
state.Set(IS_PROCESSING_STATE_KEY, this.IsProcessing);
|
||||
this.CaptureCustomAssistantSessionState(state);
|
||||
|
||||
return state.ToDictionary();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Captures assistant-specific state values.
|
||||
/// </summary>
|
||||
/// <param name="state">The typed state writer to update.</param>
|
||||
protected virtual void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state) { }
|
||||
|
||||
/// <summary>
|
||||
/// Restores the base assistant state and assistant-specific typed state values from a session snapshot.
|
||||
/// </summary>
|
||||
/// <param name="state">The captured assistant state to import.</param>
|
||||
private void ImportAssistantSessionState(IReadOnlyDictionary<string, IAssistantSessionSnapshotField> state)
|
||||
{
|
||||
var reader = new AssistantSessionStateReader(state, this.Title);
|
||||
reader.Restore(PROVIDER_SETTINGS_STATE_KEY, value => this.ProviderSettings = value);
|
||||
reader.Restore(INPUT_IS_VALID_STATE_KEY, value => this.InputIsValid = value);
|
||||
reader.Restore(CURRENT_PROFILE_STATE_KEY, value => this.CurrentProfile = value);
|
||||
reader.Restore(CURRENT_CHAT_TEMPLATE_STATE_KEY, value => this.CurrentChatTemplate = value);
|
||||
reader.Restore(CHAT_THREAD_STATE_KEY, value => this.ChatThread = value);
|
||||
reader.Restore(LAST_USER_PROMPT_STATE_KEY, value => this.LastUserPrompt = value);
|
||||
reader.Restore(RESULTING_CONTENT_BLOCK_STATE_KEY, value => this.ResultingContentBlock = value);
|
||||
reader.Restore(INPUT_ISSUES_STATE_KEY, value => this.InputIssues = value);
|
||||
reader.Restore(IS_PROCESSING_STATE_KEY, value => this.IsProcessing = value);
|
||||
this.RestoreCustomAssistantSessionState(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores assistant-specific state values.
|
||||
/// </summary>
|
||||
/// <param name="state">The typed state reader to read from.</param>
|
||||
protected virtual void RestoreCustomAssistantSessionState(AssistantSessionStateReader state) { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants;
|
||||
|
||||
@ -9,4 +12,25 @@ public abstract class AssistantLowerBase : MSGComponentBase
|
||||
internal const string RESULT_DIV_ID = "assistantResult";
|
||||
internal const string BEFORE_RESULT_DIV_ID = "beforeAssistantResult";
|
||||
internal const string AFTER_RESULT_DIV_ID = "afterAssistantResult";
|
||||
|
||||
protected static readonly AssistantSessionStateKey<AIStudio.Settings.Provider> PROVIDER_SETTINGS_STATE_KEY = new(nameof(ProviderSettings));
|
||||
protected static readonly AssistantSessionStateKey<bool> INPUT_IS_VALID_STATE_KEY = new(nameof(InputIsValid));
|
||||
protected static readonly AssistantSessionStateKey<Profile> CURRENT_PROFILE_STATE_KEY = new(nameof(CurrentProfile));
|
||||
protected static readonly AssistantSessionStateKey<ChatTemplate> CURRENT_CHAT_TEMPLATE_STATE_KEY = new(nameof(CurrentChatTemplate));
|
||||
protected static readonly AssistantSessionStateKey<ChatThread?> CHAT_THREAD_STATE_KEY = new(nameof(ChatThread));
|
||||
protected static readonly AssistantSessionStateKey<IContent?> LAST_USER_PROMPT_STATE_KEY = new(nameof(LastUserPrompt));
|
||||
protected static readonly AssistantSessionStateKey<ContentBlock?> RESULTING_CONTENT_BLOCK_STATE_KEY = new(nameof(ResultingContentBlock));
|
||||
protected static readonly AssistantSessionStateKey<string[]> INPUT_ISSUES_STATE_KEY = new(nameof(InputIssues));
|
||||
protected static readonly AssistantSessionStateKey<bool> IS_PROCESSING_STATE_KEY = new(nameof(IsProcessing));
|
||||
|
||||
protected AIStudio.Settings.Provider ProviderSettings = Settings.Provider.NONE;
|
||||
protected bool InputIsValid;
|
||||
protected Profile CurrentProfile = Profile.NO_PROFILE;
|
||||
protected ChatTemplate CurrentChatTemplate = ChatTemplate.NO_CHAT_TEMPLATE;
|
||||
protected ChatThread? ChatThread;
|
||||
protected IContent? LastUserPrompt;
|
||||
|
||||
protected ContentBlock? ResultingContentBlock;
|
||||
protected string[] InputIssues = [];
|
||||
protected bool IsProcessing;
|
||||
}
|
||||
@ -3,6 +3,7 @@ using System.Text;
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.BiasDay;
|
||||
|
||||
@ -66,6 +67,25 @@ public partial class BiasOfTheDayAssistant : AssistantBaseCore<SettingsDialogAss
|
||||
private Bias biasOfTheDay = BiasCatalog.NONE;
|
||||
private CommonLanguages selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<Bias> BIAS_OF_THE_DAY_STATE_KEY = new(nameof(biasOfTheDay));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(BIAS_OF_THE_DAY_STATE_KEY, this.biasOfTheDay);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(BIAS_OF_THE_DAY_STATE_KEY, value => this.biasOfTheDay = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
}
|
||||
|
||||
private string? ValidateTargetLanguage(CommonLanguages language)
|
||||
{
|
||||
@ -149,8 +169,7 @@ public partial class BiasOfTheDayAssistant : AssistantBaseCore<SettingsDialogAss
|
||||
Please tell me about the bias of the day.
|
||||
""", true);
|
||||
|
||||
// Start the AI response without waiting for it to finish:
|
||||
_ = this.AddAIResponseAsync(time);
|
||||
await this.StartChatGenerationJobAsync(time);
|
||||
await this.SendToAssistant(Tools.Components.CHAT, default);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.Coding;
|
||||
|
||||
@ -59,6 +60,28 @@ public partial class AssistantCoding : AssistantBaseCore<SettingsDialogCoding>
|
||||
private bool provideCompilerMessages;
|
||||
private string compilerMessages = string.Empty;
|
||||
private string questions = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<List<CodingContext>> CODING_CONTEXTS_STATE_KEY = new(nameof(codingContexts));
|
||||
private static readonly AssistantSessionStateKey<bool> PROVIDE_COMPILER_MESSAGES_STATE_KEY = new(nameof(provideCompilerMessages));
|
||||
private static readonly AssistantSessionStateKey<string> COMPILER_MESSAGES_STATE_KEY = new(nameof(compilerMessages));
|
||||
private static readonly AssistantSessionStateKey<string> QUESTIONS_STATE_KEY = new(nameof(questions));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.SetList(CODING_CONTEXTS_STATE_KEY, this.codingContexts);
|
||||
state.Set(PROVIDE_COMPILER_MESSAGES_STATE_KEY, this.provideCompilerMessages);
|
||||
state.Set(COMPILER_MESSAGES_STATE_KEY, this.compilerMessages);
|
||||
state.Set(QUESTIONS_STATE_KEY, this.questions);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.RestoreList(CODING_CONTEXTS_STATE_KEY, this.codingContexts);
|
||||
state.Restore(PROVIDE_COMPILER_MESSAGES_STATE_KEY, value => this.provideCompilerMessages = value);
|
||||
state.Restore(COMPILER_MESSAGES_STATE_KEY, value => this.compilerMessages = value);
|
||||
state.Restore(QUESTIONS_STATE_KEY, value => this.questions = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@ -279,6 +280,55 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
private ProfilePreselection policyPreselectedProfile = ProfilePreselection.NoProfile;
|
||||
private HashSet<FileAttachment> loadedDocumentPaths = [];
|
||||
private readonly List<ConfigurationSelectData<string>> availableLLMProviders = new();
|
||||
private static readonly AssistantSessionStateKey<DataDocumentAnalysisPolicy?> SELECTED_POLICY_STATE_KEY = new(nameof(selectedPolicy));
|
||||
private static readonly AssistantSessionStateKey<bool> POLICY_IS_PROTECTED_STATE_KEY = new(nameof(policyIsProtected));
|
||||
private static readonly AssistantSessionStateKey<bool> POLICY_HIDE_POLICY_DEFINITION_STATE_KEY = new(nameof(policyHidePolicyDefinition));
|
||||
private static readonly AssistantSessionStateKey<bool> POLICY_DEFINITION_EXPANDED_STATE_KEY = new(nameof(policyDefinitionExpanded));
|
||||
private static readonly AssistantSessionStateKey<string> POLICY_NAME_STATE_KEY = new(nameof(policyName));
|
||||
private static readonly AssistantSessionStateKey<string> POLICY_DESCRIPTION_STATE_KEY = new(nameof(policyDescription));
|
||||
private static readonly AssistantSessionStateKey<string> POLICY_ANALYSIS_RULES_STATE_KEY = new(nameof(policyAnalysisRules));
|
||||
private static readonly AssistantSessionStateKey<string> POLICY_OUTPUT_RULES_STATE_KEY = new(nameof(policyOutputRules));
|
||||
private static readonly AssistantSessionStateKey<ConfidenceLevel> POLICY_MINIMUM_PROVIDER_CONFIDENCE_STATE_KEY = new(nameof(policyMinimumProviderConfidence));
|
||||
private static readonly AssistantSessionStateKey<string> POLICY_PRESELECTED_PROVIDER_ID_STATE_KEY = new(nameof(policyPreselectedProviderId));
|
||||
private static readonly AssistantSessionStateKey<ProfilePreselection> POLICY_PRESELECTED_PROFILE_STATE_KEY = new(nameof(policyPreselectedProfile));
|
||||
private static readonly AssistantSessionStateKey<HashSet<FileAttachment>> LOADED_DOCUMENT_PATHS_STATE_KEY = new(nameof(loadedDocumentPaths));
|
||||
private static readonly AssistantSessionStateKey<List<ConfigurationSelectData<string>>> AVAILABLE_LLM_PROVIDERS_STATE_KEY = new(nameof(availableLLMProviders));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SELECTED_POLICY_STATE_KEY, this.selectedPolicy);
|
||||
state.Set(POLICY_IS_PROTECTED_STATE_KEY, this.policyIsProtected);
|
||||
state.Set(POLICY_HIDE_POLICY_DEFINITION_STATE_KEY, this.policyHidePolicyDefinition);
|
||||
state.Set(POLICY_DEFINITION_EXPANDED_STATE_KEY, this.policyDefinitionExpanded);
|
||||
state.Set(POLICY_NAME_STATE_KEY, this.policyName);
|
||||
state.Set(POLICY_DESCRIPTION_STATE_KEY, this.policyDescription);
|
||||
state.Set(POLICY_ANALYSIS_RULES_STATE_KEY, this.policyAnalysisRules);
|
||||
state.Set(POLICY_OUTPUT_RULES_STATE_KEY, this.policyOutputRules);
|
||||
state.Set(POLICY_MINIMUM_PROVIDER_CONFIDENCE_STATE_KEY, this.policyMinimumProviderConfidence);
|
||||
state.Set(POLICY_PRESELECTED_PROVIDER_ID_STATE_KEY, this.policyPreselectedProviderId);
|
||||
state.Set(POLICY_PRESELECTED_PROFILE_STATE_KEY, this.policyPreselectedProfile);
|
||||
state.SetHashSet(LOADED_DOCUMENT_PATHS_STATE_KEY, this.loadedDocumentPaths);
|
||||
state.SetList(AVAILABLE_LLM_PROVIDERS_STATE_KEY, this.availableLLMProviders);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SELECTED_POLICY_STATE_KEY, value => this.selectedPolicy = value);
|
||||
state.Restore(POLICY_IS_PROTECTED_STATE_KEY, value => this.policyIsProtected = value);
|
||||
state.Restore(POLICY_HIDE_POLICY_DEFINITION_STATE_KEY, value => this.policyHidePolicyDefinition = value);
|
||||
state.Restore(POLICY_DEFINITION_EXPANDED_STATE_KEY, value => this.policyDefinitionExpanded = value);
|
||||
state.Restore(POLICY_NAME_STATE_KEY, value => this.policyName = value);
|
||||
state.Restore(POLICY_DESCRIPTION_STATE_KEY, value => this.policyDescription = value);
|
||||
state.Restore(POLICY_ANALYSIS_RULES_STATE_KEY, value => this.policyAnalysisRules = value);
|
||||
state.Restore(POLICY_OUTPUT_RULES_STATE_KEY, value => this.policyOutputRules = value);
|
||||
state.Restore(POLICY_MINIMUM_PROVIDER_CONFIDENCE_STATE_KEY, value => this.policyMinimumProviderConfidence = value);
|
||||
state.Restore(POLICY_PRESELECTED_PROVIDER_ID_STATE_KEY, value => this.policyPreselectedProviderId = value);
|
||||
state.Restore(POLICY_PRESELECTED_PROFILE_STATE_KEY, value => this.policyPreselectedProfile = value);
|
||||
state.RestoreHashSet(LOADED_DOCUMENT_PATHS_STATE_KEY, this.loadedDocumentPaths);
|
||||
state.RestoreList(AVAILABLE_LLM_PROVIDERS_STATE_KEY, this.availableLLMProviders);
|
||||
}
|
||||
|
||||
private bool IsNoPolicySelectedOrProtected => this.selectedPolicy is null || this.selectedPolicy.IsProtected;
|
||||
|
||||
@ -515,7 +565,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
break;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
return base.ProcessIncomingMessage(sendingComponent, triggeredEvent, data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.PluginSystem.Assistants;
|
||||
using AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
@ -27,6 +28,11 @@ public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
// Reuse chat-level provider filtering/preselection instead of NONE.
|
||||
protected override Tools.Components Component => Tools.Components.CHAT;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin ID as the assistant session instance ID.
|
||||
/// </summary>
|
||||
protected override string AssistantSessionInstanceId => this.assistantPlugin is null ? base.AssistantSessionInstanceId : this.assistantPlugin.Id.ToString();
|
||||
|
||||
private string title = string.Empty;
|
||||
private string description = string.Empty;
|
||||
private string systemPrompt = string.Empty;
|
||||
@ -44,6 +50,61 @@ public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
private string securityMessage = string.Empty;
|
||||
private bool isSecurityBlocked;
|
||||
private const string ASSISTANT_QUERY_KEY = "assistantId";
|
||||
private static readonly AssistantSessionStateKey<string> TITLE_STATE_KEY = new(nameof(title));
|
||||
private static readonly AssistantSessionStateKey<string> DESCRIPTION_STATE_KEY = new(nameof(description));
|
||||
private static readonly AssistantSessionStateKey<string> SYSTEM_PROMPT_STATE_KEY = new(nameof(systemPrompt));
|
||||
private static readonly AssistantSessionStateKey<bool> ALLOW_PROFILES_STATE_KEY = new(nameof(allowProfiles));
|
||||
private static readonly AssistantSessionStateKey<string> SUBMIT_TEXT_STATE_KEY = new(nameof(submitText));
|
||||
private static readonly AssistantSessionStateKey<bool> SHOW_FOOTER_PROFILE_SELECTION_STATE_KEY = new(nameof(showFooterProfileSelection));
|
||||
private static readonly AssistantSessionStateKey<PluginAssistants?> ASSISTANT_PLUGIN_STATE_KEY = new(nameof(assistantPlugin));
|
||||
private static readonly AssistantSessionStateKey<AssistantState> ASSISTANT_STATE_STATE_KEY = new(nameof(assistantState));
|
||||
private static readonly AssistantSessionStateKey<Dictionary<string, string>> IMAGE_CACHE_STATE_KEY = new(nameof(imageCache));
|
||||
private static readonly AssistantSessionStateKey<HashSet<string>> EXECUTING_BUTTON_ACTIONS_STATE_KEY = new(nameof(executingButtonActions));
|
||||
private static readonly AssistantSessionStateKey<HashSet<string>> EXECUTING_SWITCH_ACTIONS_STATE_KEY = new(nameof(executingSwitchActions));
|
||||
private static readonly AssistantSessionStateKey<string> PLUGIN_PATH_STATE_KEY = new(nameof(pluginPath));
|
||||
private static readonly AssistantSessionStateKey<PluginAssistantAudit?> AUDIT_STATE_KEY = new(nameof(audit));
|
||||
private static readonly AssistantSessionStateKey<string> SECURITY_MESSAGE_STATE_KEY = new(nameof(securityMessage));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_SECURITY_BLOCKED_STATE_KEY = new(nameof(isSecurityBlocked));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(TITLE_STATE_KEY, this.title);
|
||||
state.Set(DESCRIPTION_STATE_KEY, this.description);
|
||||
state.Set(SYSTEM_PROMPT_STATE_KEY, this.systemPrompt);
|
||||
state.Set(ALLOW_PROFILES_STATE_KEY, this.allowProfiles);
|
||||
state.Set(SUBMIT_TEXT_STATE_KEY, this.submitText);
|
||||
state.Set(SHOW_FOOTER_PROFILE_SELECTION_STATE_KEY, this.showFooterProfileSelection);
|
||||
state.Set(ASSISTANT_PLUGIN_STATE_KEY, this.assistantPlugin);
|
||||
state.Set(ASSISTANT_STATE_STATE_KEY, this.assistantState.Clone());
|
||||
state.SetDictionary(IMAGE_CACHE_STATE_KEY, this.imageCache);
|
||||
state.SetHashSet(EXECUTING_BUTTON_ACTIONS_STATE_KEY, this.executingButtonActions);
|
||||
state.SetHashSet(EXECUTING_SWITCH_ACTIONS_STATE_KEY, this.executingSwitchActions);
|
||||
state.Set(PLUGIN_PATH_STATE_KEY, this.pluginPath);
|
||||
state.Set(AUDIT_STATE_KEY, this.audit);
|
||||
state.Set(SECURITY_MESSAGE_STATE_KEY, this.securityMessage);
|
||||
state.Set(IS_SECURITY_BLOCKED_STATE_KEY, this.isSecurityBlocked);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(TITLE_STATE_KEY, value => this.title = value);
|
||||
state.Restore(DESCRIPTION_STATE_KEY, value => this.description = value);
|
||||
state.Restore(SYSTEM_PROMPT_STATE_KEY, value => this.systemPrompt = value);
|
||||
state.Restore(ALLOW_PROFILES_STATE_KEY, value => this.allowProfiles = value);
|
||||
state.Restore(SUBMIT_TEXT_STATE_KEY, value => this.submitText = value);
|
||||
state.Restore(SHOW_FOOTER_PROFILE_SELECTION_STATE_KEY, value => this.showFooterProfileSelection = value);
|
||||
state.Restore(ASSISTANT_PLUGIN_STATE_KEY, value => this.assistantPlugin = value);
|
||||
state.Restore(ASSISTANT_STATE_STATE_KEY, value => this.assistantState.CopyFrom(value));
|
||||
state.RestoreDictionary(IMAGE_CACHE_STATE_KEY, this.imageCache);
|
||||
state.RestoreHashSet(EXECUTING_BUTTON_ACTIONS_STATE_KEY, this.executingButtonActions);
|
||||
state.RestoreHashSet(EXECUTING_SWITCH_ACTIONS_STATE_KEY, this.executingSwitchActions);
|
||||
state.Restore(PLUGIN_PATH_STATE_KEY, value => this.pluginPath = value);
|
||||
state.Restore(AUDIT_STATE_KEY, value => this.audit = value);
|
||||
state.Restore(SECURITY_MESSAGE_STATE_KEY, value => this.securityMessage = value);
|
||||
state.Restore(IS_SECURITY_BLOCKED_STATE_KEY, value => this.isSecurityBlocked = value);
|
||||
}
|
||||
|
||||
#region Implementation of AssistantBase
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.EMail;
|
||||
|
||||
@ -78,6 +79,46 @@ public partial class AssistantEMail : AssistantBaseCore<SettingsDialogWritingEMa
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private bool provideHistory;
|
||||
private string inputHistory = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<WritingStyles> SELECTED_WRITING_STYLE_STATE_KEY = new(nameof(selectedWritingStyle));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_GREETING_STATE_KEY = new(nameof(inputGreeting));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_BULLET_POINTS_STATE_KEY = new(nameof(inputBulletPoints));
|
||||
private static readonly AssistantSessionStateKey<List<string>> BULLET_POINTS_LINES_STATE_KEY = new(nameof(bulletPointsLines));
|
||||
private static readonly AssistantSessionStateKey<HashSet<string>> SELECTED_FOCI_STATE_KEY = new(nameof(selectedFoci));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_NAME_STATE_KEY = new(nameof(inputName));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<bool> PROVIDE_HISTORY_STATE_KEY = new(nameof(provideHistory));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_HISTORY_STATE_KEY = new(nameof(inputHistory));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SELECTED_WRITING_STYLE_STATE_KEY, this.selectedWritingStyle);
|
||||
state.Set(INPUT_GREETING_STATE_KEY, this.inputGreeting);
|
||||
state.Set(INPUT_BULLET_POINTS_STATE_KEY, this.inputBulletPoints);
|
||||
state.SetList(BULLET_POINTS_LINES_STATE_KEY, this.bulletPointsLines);
|
||||
state.SetHashSet(SELECTED_FOCI_STATE_KEY, this.selectedFoci);
|
||||
state.Set(INPUT_NAME_STATE_KEY, this.inputName);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(PROVIDE_HISTORY_STATE_KEY, this.provideHistory);
|
||||
state.Set(INPUT_HISTORY_STATE_KEY, this.inputHistory);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SELECTED_WRITING_STYLE_STATE_KEY, value => this.selectedWritingStyle = value);
|
||||
state.Restore(INPUT_GREETING_STATE_KEY, value => this.inputGreeting = value);
|
||||
state.Restore(INPUT_BULLET_POINTS_STATE_KEY, value => this.inputBulletPoints = value);
|
||||
state.RestoreList(BULLET_POINTS_LINES_STATE_KEY, this.bulletPointsLines);
|
||||
state.Restore(SELECTED_FOCI_STATE_KEY, value => this.selectedFoci = value);
|
||||
state.Restore(INPUT_NAME_STATE_KEY, value => this.inputName = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(PROVIDE_HISTORY_STATE_KEY, value => this.provideHistory = value);
|
||||
state.Restore(INPUT_HISTORY_STATE_KEY, value => this.inputHistory = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudList Disabled="@this.AreServerPresetsBlocked" T="DataERIServer" Class="mb-1" SelectedValue="@this.selectedERIServer" SelectedValueChanged="@this.SelectedERIServerChanged">
|
||||
<MudList Disabled="@this.AreServerPresetControlsDisabled" T="DataERIServer" Class="mb-1" SelectedValue="@this.selectedERIServer" SelectedValueChanged="@this.SelectedERIServerChanged">
|
||||
@foreach (var server in this.SettingsManager.ConfigurationData.ERI.ERIServers)
|
||||
{
|
||||
<MudListItem T="DataERIServer" Icon="@Icons.Material.Filled.Settings" Value="@server">
|
||||
@ -52,10 +52,10 @@ else
|
||||
}
|
||||
|
||||
<MudStack Row="@true" Class="mt-1">
|
||||
<MudButton Disabled="@this.AreServerPresetsBlocked" OnClick="@this.AddERIServer" Variant="Variant.Filled" Color="Color.Primary">
|
||||
<MudButton Disabled="@this.AreServerPresetControlsDisabled" OnClick="@this.AddERIServer" Variant="Variant.Filled" Color="Color.Primary">
|
||||
@T("Add ERI server preset")
|
||||
</MudButton>
|
||||
<MudButton OnClick="@this.RemoveERIServer" Disabled="@(this.AreServerPresetsBlocked || this.IsNoneERIServerSelected)" Variant="Variant.Filled" Color="Color.Error">
|
||||
<MudButton OnClick="@this.RemoveERIServer" Disabled="@(this.AreServerPresetControlsDisabled || this.IsNoneERIServerSelected)" Variant="Variant.Filled" Color="Color.Error">
|
||||
@T("Delete this server preset")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
@ -82,18 +82,18 @@ else
|
||||
</MudJustifiedText>
|
||||
}
|
||||
|
||||
<MudTextSwitch Label="@T("Should we automatically save any input made?")" Disabled="@this.AreServerPresetsBlocked" @bind-Value="@this.autoSave" LabelOn="@T("Yes, please save my inputs")" LabelOff="@T("No, I will enter everything again or configure it manually in the settings")" />
|
||||
<MudTextSwitch Label="@T("Should we automatically save any input made?")" Disabled="@this.AreServerPresetControlsDisabled" @bind-Value="@this.autoSave" LabelOn="@T("Yes, please save my inputs")" LabelOff="@T("No, I will enter everything again or configure it manually in the settings")" />
|
||||
|
||||
<hr style="width: 100%; border-width: 0.25ch;" class="mt-6"/>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mt-6 mb-1">
|
||||
@T("Common ERI server settings")
|
||||
</MudText>
|
||||
<MudTextField T="string" Disabled="@this.IsNoneERIServerSelected" @bind-Text="@this.serverName" Validation="@this.ValidateServerName" Immediate="@true" Label="@T("ERI server name")" HelperText="@T("Please give your ERI server a name that provides information about the data source and/or its intended purpose. The name will be displayed to users in AI Studio.")" Counter="60" MaxLength="60" Variant="Variant.Outlined" Margin="Margin.Normal" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3" OnKeyUp="() => this.ServerNameWasChanged()"/>
|
||||
<MudTextField T="string" Disabled="@this.IsNoneERIServerSelected" @bind-Text="@this.serverDescription" Validation="@this.ValidateServerDescription" Immediate="@true" Label="@T("ERI server description")" HelperText="@T("Please provide a brief description of your ERI server. Describe or explain what your ERI server does and what data it uses for this purpose. This description will be shown to users in AI Studio.")" Counter="512" MaxLength="512" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
<MudTextField T="string" Disabled="@this.IsERIInputDisabled" @bind-Text="@this.serverName" Validation="@this.ValidateServerName" Immediate="@true" Label="@T("ERI server name")" HelperText="@T("Please give your ERI server a name that provides information about the data source and/or its intended purpose. The name will be displayed to users in AI Studio.")" Counter="60" MaxLength="60" Variant="Variant.Outlined" Margin="Margin.Normal" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3" OnKeyUp="() => this.ServerNameWasChanged()"/>
|
||||
<MudTextField T="string" Disabled="@this.IsERIInputDisabled" @bind-Text="@this.serverDescription" Validation="@this.ValidateServerDescription" Immediate="@true" Label="@T("ERI server description")" HelperText="@T("Please provide a brief description of your ERI server. Describe or explain what your ERI server does and what data it uses for this purpose. This description will be shown to users in AI Studio.")" Counter="512" MaxLength="512" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
|
||||
<MudStack Row="@true" Class="mb-3">
|
||||
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="ProgrammingLanguages" @bind-Value="@this.selectedProgrammingLanguage" AdornmentIcon="@Icons.Material.Filled.Code" Adornment="Adornment.Start" Label="@T("Programming language")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateProgrammingLanguage">
|
||||
<MudSelect Disabled="@this.IsERIInputDisabled" T="ProgrammingLanguages" @bind-Value="@this.selectedProgrammingLanguage" AdornmentIcon="@Icons.Material.Filled.Code" Adornment="Adornment.Start" Label="@T("Programming language")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateProgrammingLanguage">
|
||||
@foreach (var language in Enum.GetValues<ProgrammingLanguages>())
|
||||
{
|
||||
<MudSelectItem Value="@language">
|
||||
@ -103,12 +103,12 @@ else
|
||||
</MudSelect>
|
||||
@if (this.selectedProgrammingLanguage is ProgrammingLanguages.OTHER)
|
||||
{
|
||||
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.otherProgrammingLanguage" Validation="@this.ValidateOtherLanguage" Label="@T("Other language")" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
<MudTextField Disabled="@this.IsERIInputDisabled" T="string" @bind-Text="@this.otherProgrammingLanguage" Validation="@this.ValidateOtherLanguage" Label="@T("Other language")" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
}
|
||||
</MudStack>
|
||||
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
|
||||
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="ERIVersion" @bind-Value="@this.selectedERIVersion" Label="@T("ERI specification version")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateERIVersion">
|
||||
<MudSelect Disabled="@this.IsERIInputDisabled" T="ERIVersion" @bind-Value="@this.selectedERIVersion" Label="@T("ERI specification version")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateERIVersion">
|
||||
@foreach (var version in Enum.GetValues<ERIVersion>())
|
||||
{
|
||||
<MudSelectItem Value="@version">
|
||||
@ -116,7 +116,7 @@ else
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Disabled="@(!this.selectedERIVersion.WasSpecificationSelected() || this.IsNoneERIServerSelected)" Href="@this.selectedERIVersion.SpecificationURL()" Target="_blank">
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Disabled="@this.IsSpecificationDownloadDisabled" Href="@this.selectedERIVersion.SpecificationURL()" Target="_blank">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Link" Class="mr-2"/> @T("Download specification")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
@ -126,7 +126,7 @@ else
|
||||
</MudText>
|
||||
|
||||
<MudStack Row="@false" Spacing="1" Class="mb-3">
|
||||
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="DataSources" @bind-Value="@this.selectedDataSource" AdornmentIcon="@Icons.Material.Filled.Dataset" Adornment="Adornment.Start" Label="@T("Data source")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateDataSource" SelectedValuesChanged="@this.DataSourceWasChanged">
|
||||
<MudSelect Disabled="@this.IsERIInputDisabled" T="DataSources" @bind-Value="@this.selectedDataSource" AdornmentIcon="@Icons.Material.Filled.Dataset" Adornment="Adornment.Start" Label="@T("Data source")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateDataSource" SelectedValuesChanged="@this.DataSourceWasChanged">
|
||||
@foreach (var dataSource in Enum.GetValues<DataSources>())
|
||||
{
|
||||
<MudSelectItem Value="@dataSource">
|
||||
@ -136,21 +136,21 @@ else
|
||||
</MudSelect>
|
||||
@if (this.selectedDataSource is DataSources.CUSTOM)
|
||||
{
|
||||
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.otherDataSource" Validation="@this.ValidateOtherDataSource" Label="@T("Describe your data source")" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
<MudTextField Disabled="@this.IsERIInputDisabled" T="string" @bind-Text="@this.otherDataSource" Validation="@this.ValidateOtherDataSource" Label="@T("Describe your data source")" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
}
|
||||
</MudStack>
|
||||
|
||||
@if(this.selectedDataSource > DataSources.FILE_SYSTEM)
|
||||
{
|
||||
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.dataSourceProductName" Label="@T("Data source: product name")" Validation="@this.ValidateDataSourceProductName" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
<MudTextField Disabled="@this.IsERIInputDisabled" T="string" @bind-Text="@this.dataSourceProductName" Label="@T("Data source: product name")" Validation="@this.ValidateDataSourceProductName" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
}
|
||||
|
||||
@if (this.NeedHostnamePort())
|
||||
{
|
||||
<div class="mb-3">
|
||||
<MudStack Row="@true">
|
||||
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.dataSourceHostname" Label="@T("Data source: hostname")" Validation="@this.ValidateHostname" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
<MudNumericField Disabled="@this.IsNoneERIServerSelected" Label="@T("Data source: port")" Immediate="@true" Min="1" Max="65535" Validation="@this.ValidatePort" @bind-Value="@this.dataSourcePort" Variant="Variant.Outlined" Margin="Margin.Dense" OnKeyUp="() => this.DataSourcePortWasTyped()"/>
|
||||
<MudTextField Disabled="@this.IsERIInputDisabled" T="string" @bind-Text="@this.dataSourceHostname" Label="@T("Data source: hostname")" Validation="@this.ValidateHostname" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
<MudNumericField Disabled="@this.IsERIInputDisabled" Label="@T("Data source: port")" Immediate="@true" Min="1" Max="65535" Validation="@this.ValidatePort" @bind-Value="@this.dataSourcePort" Variant="Variant.Outlined" Margin="Margin.Dense" OnKeyUp="() => this.DataSourcePortWasTyped()"/>
|
||||
</MudStack>
|
||||
@if (this.dataSourcePort < 1024)
|
||||
{
|
||||
@ -168,7 +168,7 @@ else
|
||||
<MudStack Row="@false" Spacing="1" Class="mb-1">
|
||||
<MudSelectExtended
|
||||
T="Auth"
|
||||
Disabled="@this.IsNoneERIServerSelected"
|
||||
Disabled="@this.IsERIInputDisabled"
|
||||
ShrinkLabel="@true"
|
||||
MultiSelection="@true"
|
||||
MultiSelectionTextFunc="@this.GetMultiSelectionAuthText"
|
||||
@ -185,12 +185,12 @@ else
|
||||
</MudSelectItemExtended>
|
||||
}
|
||||
</MudSelectExtended>
|
||||
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.authDescription" Label="@this.AuthDescriptionTitle()" Validation="@this.ValidateAuthDescription" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
<MudTextField Disabled="@this.IsERIInputDisabled" T="string" @bind-Text="@this.authDescription" Label="@this.AuthDescriptionTitle()" Validation="@this.ValidateAuthDescription" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
</MudStack>
|
||||
|
||||
@if (this.selectedAuthenticationMethods.Contains(Auth.KERBEROS))
|
||||
{
|
||||
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="OperatingSystem" @bind-Value="@this.selectedOperatingSystem" Label="@T("Operating system on which your ERI will run")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateOperatingSystem" Class="mb-1">
|
||||
<MudSelect Disabled="@this.IsERIInputDisabled" T="OperatingSystem" @bind-Value="@this.selectedOperatingSystem" Label="@T("Operating system on which your ERI will run")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateOperatingSystem" Class="mb-1">
|
||||
@foreach (var os in Enum.GetValues<OperatingSystem>())
|
||||
{
|
||||
<MudSelectItem Value="@os">
|
||||
@ -204,7 +204,7 @@ else
|
||||
@T("Data protection settings")
|
||||
</MudText>
|
||||
|
||||
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="AllowedLLMProviders" @bind-Value="@this.allowedLLMProviders" Label="@T("Allowed LLM providers for this data source")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateAllowedLLMProviders" Class="mb-1">
|
||||
<MudSelect Disabled="@this.IsERIInputDisabled" T="AllowedLLMProviders" @bind-Value="@this.allowedLLMProviders" Label="@T("Allowed LLM providers for this data source")" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateAllowedLLMProviders" Class="mb-1">
|
||||
@foreach (var option in Enum.GetValues<AllowedLLMProviders>())
|
||||
{
|
||||
<MudSelectItem Value="@option">
|
||||
@ -227,7 +227,7 @@ else
|
||||
|
||||
@if (!this.IsNoneERIServerSelected)
|
||||
{
|
||||
<MudTable Items="@this.embeddings" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<MudTable Items="@this.EmbeddingRows" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<ColGroup>
|
||||
<col/>
|
||||
<col style="width: 34em;"/>
|
||||
@ -243,10 +243,10 @@ else
|
||||
<MudTd>@context.EmbeddingType</MudTd>
|
||||
<MudTd>
|
||||
<MudStack Row="true" Class="mb-2 mt-2" Wrap="Wrap.Wrap">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" OnClick="() => this.EditEmbedding(context)">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" OnClick="() => this.EditEmbedding(context)" Disabled="@this.IsProcessing">
|
||||
@T("Edit")
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" OnClick="() => this.DeleteEmbedding(context)">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" OnClick="() => this.DeleteEmbedding(context)" Disabled="@this.IsProcessing">
|
||||
@T("Delete")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
@ -262,7 +262,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
<MudButton Disabled="@this.IsNoneERIServerSelected" Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddEmbedding">
|
||||
<MudButton Disabled="@this.IsERIInputDisabled" Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddEmbedding">
|
||||
@T("Add Embedding Method")
|
||||
</MudButton>
|
||||
|
||||
@ -276,7 +276,7 @@ else
|
||||
|
||||
@if (!this.IsNoneERIServerSelected)
|
||||
{
|
||||
<MudTable Items="@this.retrievalProcesses" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<MudTable Items="@this.RetrievalProcessRows" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<ColGroup>
|
||||
<col/>
|
||||
<col style="width: 34em;"/>
|
||||
@ -289,10 +289,10 @@ else
|
||||
<MudTd>@context.Name</MudTd>
|
||||
<MudTd>
|
||||
<MudStack Row="true" Class="mb-2 mt-2" Wrap="Wrap.Wrap">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" OnClick="() => this.EditRetrievalProcess(context)">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" OnClick="() => this.EditRetrievalProcess(context)" Disabled="@this.IsProcessing">
|
||||
@T("Edit")
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" OnClick="() => this.DeleteRetrievalProcess(context)">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" OnClick="() => this.DeleteRetrievalProcess(context)" Disabled="@this.IsProcessing">
|
||||
@T("Delete")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
@ -308,7 +308,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
<MudButton Disabled="@this.IsNoneERIServerSelected" Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddRetrievalProcess">
|
||||
<MudButton Disabled="@this.IsERIInputDisabled" Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddRetrievalProcess">
|
||||
@T("Add Retrieval Process")
|
||||
</MudButton>
|
||||
|
||||
@ -316,7 +316,7 @@ else
|
||||
@T("You can integrate additional libraries. Perhaps you want to evaluate the prompts in advance using a machine learning method or analyze them with a text mining approach? Or maybe you want to preprocess images in the prompts? For such advanced scenarios, you can specify which libraries you want to use here. It's best to describe which library you want to integrate for which purpose. This way, the LLM that writes the ERI server for you can try to use these libraries effectively. This should result in less rework being necessary. If you don't know the necessary libraries, you can instead attempt to describe the intended use. The LLM can then attempt to choose suitable libraries. However, hallucinations can occur, and fictional libraries might be selected.")
|
||||
</MudJustifiedText>
|
||||
|
||||
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.additionalLibraries" Label="@T("(Optional) Additional libraries")" HelperText="@T("Do you want to include additional libraries? Then name them and briefly describe what you want to achieve with them.")" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="12" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
<MudTextField Disabled="@this.IsERIInputDisabled" T="string" @bind-Text="@this.additionalLibraries" Label="@T("(Optional) Additional libraries")" HelperText="@T("Do you want to include additional libraries? Then name them and briefly describe what you want to achieve with them.")" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="12" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mt-9 mb-1">
|
||||
@T("Provider selection for generation")
|
||||
@ -330,7 +330,7 @@ else
|
||||
<b>@T("Important:")</b> @T("The LLM may need to generate many files. This reaches the request limit of most providers. Typically, only a certain number of requests can be made per minute, and only a maximum number of tokens can be generated per minute. AI Studio automatically considers this.") <b>@T("However, generating all the files takes a certain amount of time.")</b> @T("Local or self-hosted models may work without these limitations and can generate responses faster. AI Studio dynamically adapts its behavior and always tries to achieve the fastest possible data processing.")
|
||||
</MudJustifiedText>
|
||||
|
||||
<ProviderSelection @bind-ProviderSettings="@this.ProviderSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||
<ProviderSelection @bind-ProviderSettings="@this.ProviderSettings" ValidateProvider="@this.ValidatingProvider" Disabled="@this.IsProcessing"/>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mt-9 mb-1">
|
||||
@T("Write code to file system")
|
||||
@ -344,5 +344,5 @@ else
|
||||
@T("When you rebuild / re-generate the ERI server code, AI Studio proceeds as follows: All files generated last time will be deleted. All other files you have created remain. Then, the AI generates the new files.") <b>@T("But beware:")</b> @T("It may happen that the AI generates a file this time that you manually created last time. In this case, your manually created file will then be overwritten. Therefore, you should always create a Git repository and commit or revert all changes before using this assistant. With a diff visualization, you can immediately see where the AI has made changes. It is best to use an IDE suitable for your selected language for this purpose.")
|
||||
</MudJustifiedText>
|
||||
|
||||
<MudTextSwitch Label="@T("Should we write the generated code to the file system?")" Disabled="@this.IsNoneERIServerSelected" @bind-Value="@this.writeToFilesystem" LabelOn="@T("Yes, please write or update all generated code to the file system")" LabelOff="@T("No, just show me the code")" />
|
||||
<SelectDirectory Label="@T("Base directory where to write the code")" @bind-Directory="@this.baseDirectory" Disabled="@(this.IsNoneERIServerSelected || !this.writeToFilesystem)" DirectoryDialogTitle="@T("Select the target directory for the ERI server")" Validation="@this.ValidateDirectory" />
|
||||
<MudTextSwitch Label="@T("Should we write the generated code to the file system?")" Disabled="@this.IsERIInputDisabled" @bind-Value="@this.writeToFilesystem" LabelOn="@T("Yes, please write or update all generated code to the file system")" LabelOff="@T("No, just show me the code")" />
|
||||
<SelectDirectory Label="@T("Base directory where to write the code")" @bind-Directory="@this.baseDirectory" Disabled="@this.IsBaseDirectorySelectionDisabled" DirectoryDialogTitle="@T("Select the target directory for the ERI server")" Validation="@this.ValidateDirectory" />
|
||||
|
||||
@ -5,6 +5,7 @@ using AIStudio.Chat;
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@ -291,7 +292,17 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
}
|
||||
}
|
||||
|
||||
protected override IReadOnlyList<IButtonData> FooterButtons => [];
|
||||
protected override IReadOnlyList<IButtonData> FooterButtons =>
|
||||
[
|
||||
new ButtonData
|
||||
{
|
||||
Text = T("Open in chat"),
|
||||
Icon = Icons.Material.Filled.Chat,
|
||||
Color = Color.Default,
|
||||
AsyncAction = this.OpenInChat,
|
||||
DisabledActionParam = () => !this.CanOpenInChat,
|
||||
},
|
||||
];
|
||||
|
||||
protected override bool ShowEntireChatThread => true;
|
||||
|
||||
@ -307,6 +318,22 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
{
|
||||
SystemPrompt = this.SystemPrompt,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the generated ERI conversation can be opened in the chat view.
|
||||
/// </summary>
|
||||
private bool CanOpenInChat => !this.IsProcessing && this.ChatThread is { Blocks.Count: > 0 };
|
||||
|
||||
/// <summary>
|
||||
/// Opens the generated ERI conversation in the chat view when a finished conversation is available.
|
||||
/// </summary>
|
||||
private async Task OpenInChat()
|
||||
{
|
||||
if (!this.CanOpenInChat)
|
||||
return;
|
||||
|
||||
await this.SendToAssistant(Tools.Components.CHAT, default);
|
||||
}
|
||||
|
||||
protected override void ResetForm()
|
||||
{
|
||||
@ -449,17 +476,110 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
private bool writeToFilesystem;
|
||||
private string baseDirectory = string.Empty;
|
||||
private List<string> previouslyGeneratedFiles = new();
|
||||
private static readonly AssistantSessionStateKey<DataERIServer?> SELECTED_ERI_SERVER_STATE_KEY = new(nameof(selectedERIServer));
|
||||
private static readonly AssistantSessionStateKey<bool> AUTO_SAVE_STATE_KEY = new(nameof(autoSave));
|
||||
private static readonly AssistantSessionStateKey<string> SERVER_NAME_STATE_KEY = new(nameof(serverName));
|
||||
private static readonly AssistantSessionStateKey<string> SERVER_DESCRIPTION_STATE_KEY = new(nameof(serverDescription));
|
||||
private static readonly AssistantSessionStateKey<ERIVersion> SELECTED_ERI_VERSION_STATE_KEY = new(nameof(selectedERIVersion));
|
||||
private static readonly AssistantSessionStateKey<string?> ERI_SPECIFICATION_STATE_KEY = new(nameof(eriSpecification));
|
||||
private static readonly AssistantSessionStateKey<ProgrammingLanguages> SELECTED_PROGRAMMING_LANGUAGE_STATE_KEY = new(nameof(selectedProgrammingLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> OTHER_PROGRAMMING_LANGUAGE_STATE_KEY = new(nameof(otherProgrammingLanguage));
|
||||
private static readonly AssistantSessionStateKey<DataSources> SELECTED_DATA_SOURCE_STATE_KEY = new(nameof(selectedDataSource));
|
||||
private static readonly AssistantSessionStateKey<string> OTHER_DATA_SOURCE_STATE_KEY = new(nameof(otherDataSource));
|
||||
private static readonly AssistantSessionStateKey<string> DATA_SOURCE_PRODUCT_NAME_STATE_KEY = new(nameof(dataSourceProductName));
|
||||
private static readonly AssistantSessionStateKey<string> DATA_SOURCE_HOSTNAME_STATE_KEY = new(nameof(dataSourceHostname));
|
||||
private static readonly AssistantSessionStateKey<int?> DATA_SOURCE_PORT_STATE_KEY = new(nameof(dataSourcePort));
|
||||
private static readonly AssistantSessionStateKey<bool> USER_TYPED_PORT_STATE_KEY = new(nameof(userTypedPort));
|
||||
private static readonly AssistantSessionStateKey<HashSet<Auth>> SELECTED_AUTHENTICATION_METHODS_STATE_KEY = new(nameof(selectedAuthenticationMethods));
|
||||
private static readonly AssistantSessionStateKey<string> AUTH_DESCRIPTION_STATE_KEY = new(nameof(authDescription));
|
||||
private static readonly AssistantSessionStateKey<OperatingSystem> SELECTED_OPERATING_SYSTEM_STATE_KEY = new(nameof(selectedOperatingSystem));
|
||||
private static readonly AssistantSessionStateKey<AllowedLLMProviders> ALLOWED_LLM_PROVIDERS_STATE_KEY = new(nameof(allowedLLMProviders));
|
||||
private static readonly AssistantSessionStateKey<List<EmbeddingInfo>> EMBEDDINGS_STATE_KEY = new(nameof(embeddings));
|
||||
private static readonly AssistantSessionStateKey<List<RetrievalInfo>> RETRIEVAL_PROCESSES_STATE_KEY = new(nameof(retrievalProcesses));
|
||||
private static readonly AssistantSessionStateKey<string> ADDITIONAL_LIBRARIES_STATE_KEY = new(nameof(additionalLibraries));
|
||||
private static readonly AssistantSessionStateKey<bool> WRITE_TO_FILESYSTEM_STATE_KEY = new(nameof(writeToFilesystem));
|
||||
private static readonly AssistantSessionStateKey<string> BASE_DIRECTORY_STATE_KEY = new(nameof(baseDirectory));
|
||||
private static readonly AssistantSessionStateKey<List<string>> PREVIOUSLY_GENERATED_FILES_STATE_KEY = new(nameof(previouslyGeneratedFiles));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SELECTED_ERI_SERVER_STATE_KEY, this.selectedERIServer);
|
||||
state.Set(AUTO_SAVE_STATE_KEY, this.autoSave);
|
||||
state.Set(SERVER_NAME_STATE_KEY, this.serverName);
|
||||
state.Set(SERVER_DESCRIPTION_STATE_KEY, this.serverDescription);
|
||||
state.Set(SELECTED_ERI_VERSION_STATE_KEY, this.selectedERIVersion);
|
||||
state.Set(ERI_SPECIFICATION_STATE_KEY, this.eriSpecification);
|
||||
state.Set(SELECTED_PROGRAMMING_LANGUAGE_STATE_KEY, this.selectedProgrammingLanguage);
|
||||
state.Set(OTHER_PROGRAMMING_LANGUAGE_STATE_KEY, this.otherProgrammingLanguage);
|
||||
state.Set(SELECTED_DATA_SOURCE_STATE_KEY, this.selectedDataSource);
|
||||
state.Set(OTHER_DATA_SOURCE_STATE_KEY, this.otherDataSource);
|
||||
state.Set(DATA_SOURCE_PRODUCT_NAME_STATE_KEY, this.dataSourceProductName);
|
||||
state.Set(DATA_SOURCE_HOSTNAME_STATE_KEY, this.dataSourceHostname);
|
||||
state.Set(DATA_SOURCE_PORT_STATE_KEY, this.dataSourcePort);
|
||||
state.Set(USER_TYPED_PORT_STATE_KEY, this.userTypedPort);
|
||||
state.SetHashSet(SELECTED_AUTHENTICATION_METHODS_STATE_KEY, this.selectedAuthenticationMethods);
|
||||
state.Set(AUTH_DESCRIPTION_STATE_KEY, this.authDescription);
|
||||
state.Set(SELECTED_OPERATING_SYSTEM_STATE_KEY, this.selectedOperatingSystem);
|
||||
state.Set(ALLOWED_LLM_PROVIDERS_STATE_KEY, this.allowedLLMProviders);
|
||||
state.SetList(EMBEDDINGS_STATE_KEY, this.embeddings);
|
||||
state.SetList(RETRIEVAL_PROCESSES_STATE_KEY, this.retrievalProcesses);
|
||||
state.Set(ADDITIONAL_LIBRARIES_STATE_KEY, this.additionalLibraries);
|
||||
state.Set(WRITE_TO_FILESYSTEM_STATE_KEY, this.writeToFilesystem);
|
||||
state.Set(BASE_DIRECTORY_STATE_KEY, this.baseDirectory);
|
||||
state.SetList(PREVIOUSLY_GENERATED_FILES_STATE_KEY, this.previouslyGeneratedFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SELECTED_ERI_SERVER_STATE_KEY, value => this.selectedERIServer = value);
|
||||
state.Restore(AUTO_SAVE_STATE_KEY, value => this.autoSave = value);
|
||||
state.Restore(SERVER_NAME_STATE_KEY, value => this.serverName = value);
|
||||
state.Restore(SERVER_DESCRIPTION_STATE_KEY, value => this.serverDescription = value);
|
||||
state.Restore(SELECTED_ERI_VERSION_STATE_KEY, value => this.selectedERIVersion = value);
|
||||
state.Restore(ERI_SPECIFICATION_STATE_KEY, value => this.eriSpecification = value);
|
||||
state.Restore(SELECTED_PROGRAMMING_LANGUAGE_STATE_KEY, value => this.selectedProgrammingLanguage = value);
|
||||
state.Restore(OTHER_PROGRAMMING_LANGUAGE_STATE_KEY, value => this.otherProgrammingLanguage = value);
|
||||
state.Restore(SELECTED_DATA_SOURCE_STATE_KEY, value => this.selectedDataSource = value);
|
||||
state.Restore(OTHER_DATA_SOURCE_STATE_KEY, value => this.otherDataSource = value);
|
||||
state.Restore(DATA_SOURCE_PRODUCT_NAME_STATE_KEY, value => this.dataSourceProductName = value);
|
||||
state.Restore(DATA_SOURCE_HOSTNAME_STATE_KEY, value => this.dataSourceHostname = value);
|
||||
state.Restore(DATA_SOURCE_PORT_STATE_KEY, value => this.dataSourcePort = value);
|
||||
state.Restore(USER_TYPED_PORT_STATE_KEY, value => this.userTypedPort = value);
|
||||
state.Restore(SELECTED_AUTHENTICATION_METHODS_STATE_KEY, value => this.selectedAuthenticationMethods = value);
|
||||
state.Restore(AUTH_DESCRIPTION_STATE_KEY, value => this.authDescription = value);
|
||||
state.Restore(SELECTED_OPERATING_SYSTEM_STATE_KEY, value => this.selectedOperatingSystem = value);
|
||||
state.Restore(ALLOWED_LLM_PROVIDERS_STATE_KEY, value => this.allowedLLMProviders = value);
|
||||
state.RestoreList(EMBEDDINGS_STATE_KEY, this.embeddings);
|
||||
state.RestoreList(RETRIEVAL_PROCESSES_STATE_KEY, this.retrievalProcesses);
|
||||
state.Restore(ADDITIONAL_LIBRARIES_STATE_KEY, value => this.additionalLibraries = value);
|
||||
state.Restore(WRITE_TO_FILESYSTEM_STATE_KEY, value => this.writeToFilesystem = value);
|
||||
state.Restore(BASE_DIRECTORY_STATE_KEY, value => this.baseDirectory = value);
|
||||
state.RestoreList(PREVIOUSLY_GENERATED_FILES_STATE_KEY, this.previouslyGeneratedFiles);
|
||||
}
|
||||
|
||||
private bool AreServerPresetsBlocked => !this.SettingsManager.ConfigurationData.ERI.PreselectOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether ERI server preset controls should be disabled.
|
||||
/// </summary>
|
||||
private bool AreServerPresetControlsDisabled => this.AreServerPresetsBlocked || this.IsProcessing;
|
||||
|
||||
private void SelectedERIServerChanged(DataERIServer? server)
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
this.selectedERIServer = server;
|
||||
this.ResetForm();
|
||||
}
|
||||
|
||||
private async Task AddERIServer()
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
this.SettingsManager.ConfigurationData.ERI.ERIServers.Add(new ()
|
||||
{
|
||||
ServerName = string.Format(T("ERI Server {0}"), DateTimeOffset.UtcNow),
|
||||
@ -470,6 +590,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task RemoveERIServer()
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
if(this.selectedERIServer is null)
|
||||
return;
|
||||
|
||||
@ -493,6 +616,31 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private bool IsNoneERIServerSelected => this.selectedERIServer is null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether ERI configuration input controls should be disabled.
|
||||
/// </summary>
|
||||
private bool IsERIInputDisabled => this.IsNoneERIServerSelected || this.IsProcessing;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the selected ERI specification cannot be downloaded.
|
||||
/// </summary>
|
||||
private bool IsSpecificationDownloadDisabled => !this.selectedERIVersion.WasSpecificationSelected() || this.IsERIInputDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the generated-code target directory selection should be disabled.
|
||||
/// </summary>
|
||||
private bool IsBaseDirectorySelectionDisabled => this.IsERIInputDisabled || !this.writeToFilesystem;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stable row snapshot for the embedding-method table.
|
||||
/// </summary>
|
||||
private EmbeddingInfo[] EmbeddingRows => this.embeddings.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stable row snapshot for the retrieval-process table.
|
||||
/// </summary>
|
||||
private RetrievalInfo[] RetrievalProcessRows => this.retrievalProcesses.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets called when the server name was changed by typing.
|
||||
/// </summary>
|
||||
@ -780,6 +928,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task AddEmbedding()
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
var dialogParameters = new DialogParameters<EmbeddingMethodDialog>
|
||||
{
|
||||
{ x => x.IsEditing, false },
|
||||
@ -798,6 +949,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task EditEmbedding(EmbeddingInfo embeddingInfo)
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
var dialogParameters = new DialogParameters<EmbeddingMethodDialog>
|
||||
{
|
||||
{ x => x.DataEmbeddingName, embeddingInfo.EmbeddingName },
|
||||
@ -823,6 +977,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task DeleteEmbedding(EmbeddingInfo embeddingInfo)
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
var message = this.retrievalProcesses.Any(n => n.Embeddings?.Contains(embeddingInfo) is true)
|
||||
? string.Format(T("The embedding '{0}' is used in one or more retrieval processes. Are you sure you want to delete it?"), embeddingInfo.EmbeddingName)
|
||||
: string.Format(T("Are you sure you want to delete the embedding '{0}'?"), embeddingInfo.EmbeddingName);
|
||||
@ -845,6 +1002,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task AddRetrievalProcess()
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
var dialogParameters = new DialogParameters<RetrievalProcessDialog>
|
||||
{
|
||||
{ x => x.IsEditing, false },
|
||||
@ -864,6 +1024,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task EditRetrievalProcess(RetrievalInfo retrievalInfo)
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
var dialogParameters = new DialogParameters<RetrievalProcessDialog>
|
||||
{
|
||||
{ x => x.DataName, retrievalInfo.Name },
|
||||
@ -890,6 +1053,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
|
||||
private async Task DeleteRetrievalProcess(RetrievalInfo retrievalInfo)
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
var dialogParameters = new DialogParameters<ConfirmDialog>
|
||||
{
|
||||
{ x => x.Message, string.Format(T("Are you sure you want to delete the retrieval process '{0}'?"), retrievalInfo.Name) },
|
||||
@ -949,6 +1115,10 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
this.AddInputIssue(T("Please describe at least one retrieval process."));
|
||||
return;
|
||||
}
|
||||
|
||||
var writeToFilesystemSnapshot = this.writeToFilesystem;
|
||||
var baseDirectorySnapshot = this.baseDirectory;
|
||||
var previouslyGeneratedFilesSnapshot = this.previouslyGeneratedFiles.ToArray();
|
||||
|
||||
this.eriSpecification = await this.selectedERIVersion.ReadSpecification(this.HttpClient);
|
||||
if (string.IsNullOrWhiteSpace(this.eriSpecification))
|
||||
@ -990,9 +1160,9 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
var fileListAnswer = await this.AddAIResponseAsync(time, true);
|
||||
|
||||
// Is this an update of the ERI server? If so, we need to delete the previously generated files:
|
||||
if (this.writeToFilesystem && this.previouslyGeneratedFiles.Count > 0 && !string.IsNullOrWhiteSpace(fileListAnswer))
|
||||
if (writeToFilesystemSnapshot && previouslyGeneratedFilesSnapshot.Length > 0 && !string.IsNullOrWhiteSpace(fileListAnswer))
|
||||
{
|
||||
foreach (var file in this.previouslyGeneratedFiles)
|
||||
foreach (var file in previouslyGeneratedFilesSnapshot)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -1014,7 +1184,8 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
}
|
||||
|
||||
var generatedFiles = new List<string>();
|
||||
foreach (var file in this.ExtractFiles(fileListAnswer))
|
||||
var filesToGenerate = this.ExtractFiles(fileListAnswer).ToArray();
|
||||
foreach (var file in filesToGenerate)
|
||||
{
|
||||
this.Logger.LogInformation($"The LLM want to create the file: '{file}'");
|
||||
|
||||
@ -1034,15 +1205,15 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
```
|
||||
""", true);
|
||||
var generatedCodeMarkdown = await this.AddAIResponseAsync(time);
|
||||
if (this.writeToFilesystem)
|
||||
if (writeToFilesystemSnapshot)
|
||||
{
|
||||
var desiredFilePath = Path.Join(this.baseDirectory, file);
|
||||
var desiredFilePath = Path.Join(baseDirectorySnapshot, file);
|
||||
|
||||
// Security check: ensure that the desired file path is inside the base directory.
|
||||
// We cannot trust the beginning of the file path because it would be possible
|
||||
// to escape by using `..` in the file path.
|
||||
if (!desiredFilePath.StartsWith(this.baseDirectory, StringComparison.InvariantCultureIgnoreCase) || desiredFilePath.Contains(".."))
|
||||
this.Logger.LogWarning($"The file path '{desiredFilePath}' is may not inside the base directory '{this.baseDirectory}'.");
|
||||
if (!desiredFilePath.StartsWith(baseDirectorySnapshot, StringComparison.InvariantCultureIgnoreCase) || desiredFilePath.Contains(".."))
|
||||
this.Logger.LogWarning($"The file path '{desiredFilePath}' is may not inside the base directory '{baseDirectorySnapshot}'.");
|
||||
|
||||
else
|
||||
{
|
||||
@ -1077,7 +1248,7 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
}
|
||||
}
|
||||
|
||||
if(this.writeToFilesystem)
|
||||
if(writeToFilesystemSnapshot)
|
||||
{
|
||||
this.previouslyGeneratedFiles = generatedFiles;
|
||||
this.selectedERIServer!.PreviouslyGeneratedFiles = generatedFiles;
|
||||
@ -1096,6 +1267,5 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
like Docker.
|
||||
""", true);
|
||||
await this.AddAIResponseAsync(time);
|
||||
await this.SendToAssistant(Tools.Components.CHAT, default);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.GrammarSpelling;
|
||||
|
||||
@ -84,6 +85,28 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore<SettingsDialog
|
||||
private CommonLanguages selectedTargetLanguage;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private string correctedText = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_STATE_KEY = new(nameof(inputText));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CORRECTED_TEXT_STATE_KEY = new(nameof(correctedText));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_TEXT_STATE_KEY, this.inputText);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(CORRECTED_TEXT_STATE_KEY, this.correctedText);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_TEXT_STATE_KEY, value => this.inputText = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(CORRECTED_TEXT_STATE_KEY, value => this.correctedText = value);
|
||||
}
|
||||
|
||||
private string? ValidateText(string text)
|
||||
{
|
||||
@ -127,6 +150,13 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore<SettingsDialog
|
||||
var time = this.AddUserRequest(this.inputText);
|
||||
|
||||
this.correctedText = await this.AddAIResponseAsync(time);
|
||||
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.correctedText);
|
||||
if (!this.IsAssistantComponentDisposed)
|
||||
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.correctedText);
|
||||
}
|
||||
|
||||
protected override async Task OnAssistantSessionRenderedAsync(AssistantSessionSnapshot snapshot)
|
||||
{
|
||||
if (!snapshot.IsActive && !string.IsNullOrWhiteSpace(this.inputText) && !string.IsNullOrWhiteSpace(this.correctedText))
|
||||
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.correctedText);
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,8 @@
|
||||
@using AIStudio.Settings
|
||||
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogI18N>
|
||||
|
||||
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelecting())" @bind-Value="@this.selectedTargetLanguage" ValidateSelection="@this.ValidatingTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="@T("Target language")" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="@T("Custom target language")" SelectionUpdated="_ => this.OnChangedLanguage()" />
|
||||
<ConfigurationSelect OptionDescription="@T("Language plugin used for comparision")" SelectedValue="@(() => this.selectedLanguagePluginId)" Data="@ConfigurationSelectDataFactory.GetLanguagesData()" SelectionUpdate="@(async void (id) => await this.OnLanguagePluginChanged(id))" OptionHelp="@T("Select the language plugin used for comparision.")"/>
|
||||
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelecting())" @bind-Value="@this.selectedTargetLanguage" ValidateSelection="@this.ValidatingTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="@T("Target language")" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="@T("Custom target language")" SelectionUpdated="_ => this.OnChangedLanguage()" Disabled="@this.IsProcessing" />
|
||||
<ConfigurationSelect OptionDescription="@T("Language plugin used for comparision")" SelectedValue="@(() => this.selectedLanguagePluginId)" Data="@ConfigurationSelectDataFactory.GetLanguagesData()" SelectionUpdate="@(async void (id) => await this.OnLanguagePluginChanged(id))" OptionHelp="@T("Select the language plugin used for comparision.")" Disabled="@(() => this.IsProcessing)"/>
|
||||
@if (this.isLoading)
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mb-6">
|
||||
@ -20,7 +20,7 @@ else if (!this.isLoading && string.IsNullOrWhiteSpace(this.loadingIssue))
|
||||
<MudText Typo="Typo.h6">
|
||||
@this.AddedContentText
|
||||
</MudText>
|
||||
<MudTable Items="@this.addedContent" Hover="@true" Filter="@this.FilterFunc" Class="border-dashed border rounded-lg mb-6">
|
||||
<MudTable Items="@this.AddedContentRows" Hover="@true" Filter="@this.FilterFunc" Class="border-dashed border rounded-lg mb-6">
|
||||
<ToolBarContent>
|
||||
<MudTextField @bind-Value="@this.searchString" Immediate="true" Placeholder="@T("Search")" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"/>
|
||||
</ToolBarContent>
|
||||
@ -50,7 +50,7 @@ else if (!this.isLoading && string.IsNullOrWhiteSpace(this.loadingIssue))
|
||||
<MudText Typo="Typo.h6">
|
||||
@this.RemovedContentText
|
||||
</MudText>
|
||||
<MudTable Items="@this.removedContent" Hover="@true" Filter="@this.FilterFunc" Class="border-dashed border rounded-lg mb-6">
|
||||
<MudTable Items="@this.RemovedContentRows" Hover="@true" Filter="@this.FilterFunc" Class="border-dashed border rounded-lg mb-6">
|
||||
<ToolBarContent>
|
||||
<MudTextField @bind-Value="@this.searchString" Immediate="true" Placeholder="@T("Search")" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"/>
|
||||
</ToolBarContent>
|
||||
@ -94,7 +94,7 @@ else if (!this.isLoading && string.IsNullOrWhiteSpace(this.loadingIssue))
|
||||
<MudText Typo="Typo.h6">
|
||||
@this.LocalizedContentText
|
||||
</MudText>
|
||||
<MudTable Items="@this.localizedContent" Hover="@true" Filter="@this.FilterFunc" Class="border-dashed border rounded-lg mb-6">
|
||||
<MudTable Items="@this.LocalizedContentRows" Hover="@true" Filter="@this.FilterFunc" Class="border-dashed border rounded-lg mb-6">
|
||||
<ToolBarContent>
|
||||
<MudTextField @bind-Value="@this.searchString" Immediate="true" Placeholder="@T("Search")" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"/>
|
||||
</ToolBarContent>
|
||||
|
||||
@ -2,6 +2,7 @@ using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
@ -117,32 +118,87 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
private Dictionary<string, string> removedContent = [];
|
||||
private Dictionary<string, string> localizedContent = [];
|
||||
private StringBuilder finalLuaCode = new();
|
||||
private string? activeSystemPromptLanguage;
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_LOADING_STATE_KEY = new(nameof(isLoading));
|
||||
private static readonly AssistantSessionStateKey<string> LOADING_ISSUE_STATE_KEY = new(nameof(loadingIssue));
|
||||
private static readonly AssistantSessionStateKey<bool> LOCALIZATION_POSSIBLE_STATE_KEY = new(nameof(localizationPossible));
|
||||
private static readonly AssistantSessionStateKey<string> SEARCH_STRING_STATE_KEY = new(nameof(searchString));
|
||||
private static readonly AssistantSessionStateKey<Guid> SELECTED_LANGUAGE_PLUGIN_ID_STATE_KEY = new(nameof(selectedLanguagePluginId));
|
||||
private static readonly AssistantSessionStateKey<ILanguagePlugin?> SELECTED_LANGUAGE_PLUGIN_STATE_KEY = new(nameof(selectedLanguagePlugin));
|
||||
private static readonly AssistantSessionStateKey<Dictionary<string, string>> ADDED_CONTENT_STATE_KEY = new(nameof(addedContent));
|
||||
private static readonly AssistantSessionStateKey<Dictionary<string, string>> REMOVED_CONTENT_STATE_KEY = new(nameof(removedContent));
|
||||
private static readonly AssistantSessionStateKey<Dictionary<string, string>> LOCALIZED_CONTENT_STATE_KEY = new(nameof(localizedContent));
|
||||
private static readonly AssistantSessionStateKey<string> FINAL_LUA_CODE_STATE_KEY = new(nameof(finalLuaCode));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(IS_LOADING_STATE_KEY, this.isLoading);
|
||||
state.Set(LOADING_ISSUE_STATE_KEY, this.loadingIssue);
|
||||
state.Set(LOCALIZATION_POSSIBLE_STATE_KEY, this.localizationPossible);
|
||||
state.Set(SEARCH_STRING_STATE_KEY, this.searchString);
|
||||
state.Set(SELECTED_LANGUAGE_PLUGIN_ID_STATE_KEY, this.selectedLanguagePluginId);
|
||||
state.Set(SELECTED_LANGUAGE_PLUGIN_STATE_KEY, this.selectedLanguagePlugin);
|
||||
state.SetDictionary(ADDED_CONTENT_STATE_KEY, this.addedContent);
|
||||
state.SetDictionary(REMOVED_CONTENT_STATE_KEY, this.removedContent);
|
||||
state.SetDictionary(LOCALIZED_CONTENT_STATE_KEY, this.localizedContent);
|
||||
state.SetStringBuilder(FINAL_LUA_CODE_STATE_KEY, this.finalLuaCode);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(IS_LOADING_STATE_KEY, value => this.isLoading = value);
|
||||
state.Restore(LOADING_ISSUE_STATE_KEY, value => this.loadingIssue = value);
|
||||
state.Restore(LOCALIZATION_POSSIBLE_STATE_KEY, value => this.localizationPossible = value);
|
||||
state.Restore(SEARCH_STRING_STATE_KEY, value => this.searchString = value);
|
||||
state.Restore(SELECTED_LANGUAGE_PLUGIN_ID_STATE_KEY, value => this.selectedLanguagePluginId = value);
|
||||
state.Restore(SELECTED_LANGUAGE_PLUGIN_STATE_KEY, value => this.selectedLanguagePlugin = value);
|
||||
state.RestoreDictionary(ADDED_CONTENT_STATE_KEY, this.addedContent);
|
||||
state.RestoreDictionary(REMOVED_CONTENT_STATE_KEY, this.removedContent);
|
||||
state.RestoreDictionary(LOCALIZED_CONTENT_STATE_KEY, this.localizedContent);
|
||||
state.RestoreStringBuilder(FINAL_LUA_CODE_STATE_KEY, this.finalLuaCode);
|
||||
}
|
||||
|
||||
#region Overrides of AssistantBase<SettingsDialogI18N>
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
if (this.HasAssistantSession)
|
||||
return;
|
||||
|
||||
await this.OnLanguagePluginChanged(this.selectedLanguagePluginId);
|
||||
await this.LoadData();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private string SystemPromptLanguage() => this.selectedTargetLanguage switch
|
||||
private string SystemPromptLanguage() => this.activeSystemPromptLanguage ?? (this.selectedTargetLanguage switch
|
||||
{
|
||||
CommonLanguages.OTHER => this.customTargetLanguage,
|
||||
_ => $"{this.selectedTargetLanguage.Name()}",
|
||||
};
|
||||
});
|
||||
|
||||
private async Task OnLanguagePluginChanged(Guid pluginId)
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
this.selectedLanguagePluginId = pluginId;
|
||||
await this.OnChangedLanguage();
|
||||
}
|
||||
|
||||
private async Task OnChangedLanguage()
|
||||
{
|
||||
if (this.IsProcessing)
|
||||
return;
|
||||
|
||||
this.finalLuaCode.Clear();
|
||||
this.localizedContent.Clear();
|
||||
this.localizationPossible = false;
|
||||
@ -261,6 +317,21 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
|
||||
private int NumTotalItems => (this.selectedLanguagePlugin?.Content.Count ?? 0) + this.addedContent.Count - this.removedContent.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stable row snapshot for the added-content table.
|
||||
/// </summary>
|
||||
private KeyValuePair<string, string>[] AddedContentRows => this.addedContent.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stable row snapshot for the removed-content table.
|
||||
/// </summary>
|
||||
private KeyValuePair<string, string>[] RemovedContentRows => this.removedContent.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stable row snapshot for the localized-content table.
|
||||
/// </summary>
|
||||
private KeyValuePair<string, string>[] LocalizedContentRows => this.localizedContent.ToArray();
|
||||
|
||||
private string AddedContentText => string.Format(T("Added Content ({0} entries)"), this.addedContent.Count);
|
||||
|
||||
private string RemovedContentText => string.Format(T("Removed Content ({0} entries)"), this.removedContent.Count);
|
||||
@ -279,68 +350,87 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
if (this.selectedLanguagePlugin.IETFTag != this.selectedTargetLanguage.ToIETFTag())
|
||||
return;
|
||||
|
||||
this.localizedContent.Clear();
|
||||
if (this.selectedTargetLanguage is not CommonLanguages.EN_US)
|
||||
{
|
||||
// Phase 1: Translate added content
|
||||
await this.Phase1TranslateAddedContent();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case: no translation needed
|
||||
this.localizedContent = this.addedContent.ToDictionary();
|
||||
}
|
||||
var addedContentSnapshot = this.addedContent.ToArray();
|
||||
var removedContentSnapshot = this.removedContent.ToArray();
|
||||
var removedContentKeys = removedContentSnapshot.Select(keyValuePair => keyValuePair.Key).ToHashSet(StringComparer.Ordinal);
|
||||
var selectedLanguageContentSnapshot = this.selectedLanguagePlugin.Content.ToArray();
|
||||
var baseLanguageContentSnapshot = PluginFactory.BaseLanguage.Content.ToArray();
|
||||
|
||||
if(this.CancellationTokenSource!.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
//
|
||||
// Now, we have localized the added content. Next, we must merge
|
||||
// the localized content with the existing content. However, we
|
||||
// must skip the removed content. We use the localizedContent
|
||||
// dictionary for the final result:
|
||||
//
|
||||
foreach (var keyValuePair in this.selectedLanguagePlugin.Content)
|
||||
this.localizedContent.Clear();
|
||||
this.activeSystemPromptLanguage = this.SystemPromptLanguage();
|
||||
try
|
||||
{
|
||||
if (this.CancellationTokenSource!.IsCancellationRequested)
|
||||
break;
|
||||
if (this.selectedTargetLanguage is not CommonLanguages.EN_US)
|
||||
{
|
||||
// Phase 1: Translate added content
|
||||
await this.Phase1TranslateAddedContent(addedContentSnapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case: no translation needed
|
||||
this.localizedContent = addedContentSnapshot.ToDictionary(keyValuePair => keyValuePair.Key, keyValuePair => keyValuePair.Value, StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
if(this.CancellationTokenSource!.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
if (this.localizedContent.ContainsKey(keyValuePair.Key))
|
||||
continue;
|
||||
//
|
||||
// Now, we have localized the added content. Next, we must merge
|
||||
// the localized content with the existing content. However, we
|
||||
// must skip the removed content. We use the localizedContent
|
||||
// dictionary for the final result:
|
||||
//
|
||||
foreach (var keyValuePair in selectedLanguageContentSnapshot)
|
||||
{
|
||||
if (this.CancellationTokenSource!.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
if (this.localizedContent.ContainsKey(keyValuePair.Key))
|
||||
continue;
|
||||
|
||||
if (removedContentKeys.Contains(keyValuePair.Key))
|
||||
continue;
|
||||
|
||||
this.localizedContent.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
|
||||
if(this.CancellationTokenSource!.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
if (this.removedContent.ContainsKey(keyValuePair.Key))
|
||||
continue;
|
||||
//
|
||||
// Phase 2: Create the Lua code. We want to use the base language
|
||||
// for the comments, though:
|
||||
//
|
||||
var commentContent = addedContentSnapshot.ToDictionary(keyValuePair => keyValuePair.Key, keyValuePair => keyValuePair.Value, StringComparer.Ordinal);
|
||||
foreach (var keyValuePair in baseLanguageContentSnapshot)
|
||||
{
|
||||
if (this.CancellationTokenSource!.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
if (removedContentKeys.Contains(keyValuePair.Key))
|
||||
continue;
|
||||
|
||||
commentContent.TryAdd(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
|
||||
this.localizedContent.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
this.Phase2CreateLuaCode(commentContent);
|
||||
}
|
||||
|
||||
if(this.CancellationTokenSource!.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
//
|
||||
// Phase 2: Create the Lua code. We want to use the base language
|
||||
// for the comments, though:
|
||||
//
|
||||
var commentContent = new Dictionary<string, string>(this.addedContent);
|
||||
foreach (var keyValuePair in PluginFactory.BaseLanguage.Content)
|
||||
finally
|
||||
{
|
||||
if (this.CancellationTokenSource!.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
if (this.removedContent.ContainsKey(keyValuePair.Key))
|
||||
continue;
|
||||
|
||||
commentContent.TryAdd(keyValuePair.Key, keyValuePair.Value);
|
||||
this.activeSystemPromptLanguage = null;
|
||||
}
|
||||
|
||||
this.Phase2CreateLuaCode(commentContent);
|
||||
}
|
||||
|
||||
private async Task Phase1TranslateAddedContent()
|
||||
/// <summary>
|
||||
/// Translates the added text content from a stable snapshot.
|
||||
/// </summary>
|
||||
/// <param name="addedContentSnapshot">The added text entries captured when the job started.</param>
|
||||
/// <returns>A task that completes when all added text entries were translated or cancellation was requested.</returns>
|
||||
private async Task Phase1TranslateAddedContent(KeyValuePair<string, string>[] addedContentSnapshot)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
var minimumTime = TimeSpan.FromMilliseconds(500);
|
||||
foreach (var keyValuePair in this.addedContent)
|
||||
foreach (var keyValuePair in addedContentSnapshot)
|
||||
{
|
||||
if(this.CancellationTokenSource!.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
@ -310,6 +310,12 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T180921696"] = "Reset"
|
||||
-- Please select a provider.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T1809312323"] = "Please select a provider."
|
||||
|
||||
-- The assistant failed. The message is: '{0}'
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T1833836281"] = "The assistant failed. The message is: '{0}'"
|
||||
|
||||
-- This assistant is already running. AI Studio opens the running session instead.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T2575715765"] = "This assistant is already running. AI Studio opens the running session instead."
|
||||
|
||||
-- Assistant - {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T3043922"] = "Assistant - {0}"
|
||||
|
||||
@ -1054,6 +1060,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1565111217"] = "Relat
|
||||
-- Please select an ERI specification version for the ERI server.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1612890554"] = "Please select an ERI specification version for the ERI server."
|
||||
|
||||
-- Open in chat
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1664804142"] = "Open in chat"
|
||||
|
||||
-- Ports below 1024 are reserved for system services. Your ERI server need to run with elevated permissions (root user).
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T168780641"] = "Ports below 1024 are reserved for system services. Your ERI server need to run with elevated permissions (root user)."
|
||||
|
||||
@ -2287,9 +2296,24 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::IIMAGESOURCEEXTENSIONS::T349928509"] = "The ima
|
||||
-- Open Settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T1172211894"] = "Open Settings"
|
||||
|
||||
-- Assistant is still running.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T2719896610"] = "Assistant is still running."
|
||||
|
||||
-- Assistant was canceled. Open it to review the result.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T3390934621"] = "Assistant was canceled. Open it to review the result."
|
||||
|
||||
-- Assistant failed. Open it to review the result.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T3571008422"] = "Assistant failed. Open it to review the result."
|
||||
|
||||
-- The result is ready.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T661906146"] = "The result is ready."
|
||||
|
||||
-- Show or hide the detailed security information.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1045105126"] = "Show or hide the detailed security information."
|
||||
|
||||
-- This plugin is approved by your organization. A manual security audit is not required.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1213338416"] = "This plugin is approved by your organization. A manual security audit is not required."
|
||||
|
||||
-- Assistant Audit
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1506922856"] = "Assistant Audit"
|
||||
|
||||
@ -2305,6 +2329,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1805629238"
|
||||
-- Assistant Security
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1841954939"] = "Assistant Security"
|
||||
|
||||
-- Company approved
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2036497459"] = "Company approved"
|
||||
|
||||
-- Approved name
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2282386733"] = "Approved name"
|
||||
|
||||
-- Required minimum
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2354026284"] = "Required minimum"
|
||||
|
||||
@ -2314,6 +2344,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2757790517"
|
||||
-- Technical Details
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2769062110"] = "Technical Details"
|
||||
|
||||
-- Approval comment
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2906887599"] = "Approval comment"
|
||||
|
||||
-- No audit yet
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3138877447"] = "No audit yet"
|
||||
|
||||
@ -2329,21 +2362,39 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3448155331"
|
||||
-- No stored audit details are available yet.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3647137899"] = "No stored audit details are available yet."
|
||||
|
||||
-- Enterprise approval is active
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3816183955"] = "Enterprise approval is active"
|
||||
|
||||
-- Current hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3896860082"] = "Current hash"
|
||||
|
||||
-- No user audit required
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3916957031"] = "No user audit required"
|
||||
|
||||
-- Audited at
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4103354206"] = "Audited at"
|
||||
|
||||
-- Approved hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4170340306"] = "Approved hash"
|
||||
|
||||
-- No security findings were stored for this assistant plugin.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4256679240"] = "No security findings were stored for this assistant plugin."
|
||||
|
||||
-- Status source
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4289123040"] = "Status source"
|
||||
|
||||
-- Audit hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T53507304"] = "Audit hash"
|
||||
|
||||
-- {0} Finding(s)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T631393016"] = "{0} Finding(s)"
|
||||
|
||||
-- Approved by
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T894543751"] = "Approved by"
|
||||
|
||||
-- Approved at
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T978873131"] = "Approved at"
|
||||
|
||||
-- Click the paperclip to attach files, or click the number to see your attached files.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1358313858"] = "Click the paperclip to attach files, or click the number to see your attached files."
|
||||
|
||||
@ -2719,6 +2770,24 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T3654011106"] = "Open P
|
||||
-- You can switch between your profiles here
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "You can switch between your profiles here"
|
||||
|
||||
-- Audio input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T1742581112"] = "Audio input possible"
|
||||
|
||||
-- Uses reasoning (thinking)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T2196970948"] = "Uses reasoning (thinking)"
|
||||
|
||||
-- Image input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T2685487365"] = "Image input possible"
|
||||
|
||||
-- Speech input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T3005724142"] = "Speech input possible"
|
||||
|
||||
-- Uses reasoning (thinking) by default
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T3891860124"] = "Uses reasoning (thinking) by default"
|
||||
|
||||
-- Uses reasoning (thinking) configured by settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T4279448758"] = "Uses reasoning (thinking) configured by settings"
|
||||
|
||||
-- Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider"
|
||||
|
||||
@ -3745,6 +3814,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3652671056"] =
|
||||
-- Unavailable
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3662391977"] = "Unavailable"
|
||||
|
||||
-- This assistant plugin is approved by your organization. A manual security audit is not required.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3680374624"] = "This assistant plugin is approved by your organization. A manual security audit is not required."
|
||||
|
||||
-- Plugin Structure
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T371537943"] = "Plugin Structure"
|
||||
|
||||
@ -4666,9 +4738,6 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROMPTINGGUIDELINEDIALOG::T384594633"] = "Th
|
||||
-- Prompting Guideline
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROMPTINGGUIDELINEDIALOG::T4250996615"] = "Prompting Guideline"
|
||||
|
||||
-- Please be aware: This section is for experts only. You are responsible for verifying the correctness of the additional parameters you provide to the API call. By default, AI Studio uses the OpenAI-compatible chat completions API, when that it is supported by the underlying service and model.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1017509792"] = "Please be aware: This section is for experts only. You are responsible for verifying the correctness of the additional parameters you provide to the API call. By default, AI Studio uses the OpenAI-compatible chat completions API, when that it is supported by the underlying service and model."
|
||||
|
||||
-- Hugging Face Inference Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1085481431"] = "Hugging Face Inference Provider"
|
||||
|
||||
@ -4687,30 +4756,57 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1356621346"] = "Create acco
|
||||
-- Load models
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T15352225"] = "Load models"
|
||||
|
||||
-- Automatic
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1634363268"] = "Automatic"
|
||||
|
||||
-- Disabled (Auto)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1671157437"] = "Disabled (Auto)"
|
||||
|
||||
-- Add the parameters in proper JSON formatting, e.g., "temperature": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1689135032"] = "Add the parameters in proper JSON formatting, e.g., \"temperature\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though."
|
||||
|
||||
-- Hostname
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1727440780"] = "Hostname"
|
||||
|
||||
-- Always on
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1761671861"] = "Always on"
|
||||
|
||||
-- Reset
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T180921696"] = "Reset"
|
||||
|
||||
-- Update
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1847791252"] = "Update"
|
||||
|
||||
-- Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1870831108"] = "Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again."
|
||||
|
||||
-- Speech input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1874348907"] = "Speech input"
|
||||
|
||||
-- Please enter a model name.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1936099896"] = "Please enter a model name."
|
||||
|
||||
-- Enabled (Auto)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2001330464"] = "Enabled (Auto)"
|
||||
|
||||
-- The current model uses the {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2029870721"] = "The current model uses the {0}."
|
||||
|
||||
-- Additional API parameters must form a JSON object.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2051143391"] = "Additional API parameters must form a JSON object."
|
||||
|
||||
-- Use detected model behavior: {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2141072961"] = "Use detected model behavior: {0}."
|
||||
|
||||
-- Model
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2189814010"] = "Model"
|
||||
|
||||
-- (Optional) API Key
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2331453405"] = "(Optional) API Key"
|
||||
|
||||
-- Enabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2626085950"] = "Enabled"
|
||||
|
||||
-- Add
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2646845972"] = "Add"
|
||||
|
||||
@ -4723,12 +4819,42 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2810182573"] = "No models l
|
||||
-- Instance Name
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2842060373"] = "Instance Name"
|
||||
|
||||
-- On by default
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2843289040"] = "On by default"
|
||||
|
||||
-- No reasoning (thinking) capability.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T301695429"] = "No reasoning (thinking) capability."
|
||||
|
||||
-- Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3079061205"] = "Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available."
|
||||
|
||||
-- Reasoning (thinking) is available and on unless additional API parameters disable it.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T310420667"] = "Reasoning (thinking) is available and on unless additional API parameters disable it."
|
||||
|
||||
-- Disabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3217987877"] = "Disabled"
|
||||
|
||||
-- The model always uses reasoning (thinking); it cannot be disabled.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3294757333"] = "The model always uses reasoning (thinking); it cannot be disabled."
|
||||
|
||||
-- Can be enabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3299454847"] = "Can be enabled"
|
||||
|
||||
-- Show Expert Settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3361153305"] = "Show Expert Settings"
|
||||
|
||||
-- Audio input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3404621481"] = "Audio input"
|
||||
|
||||
-- Invalid JSON: Add the parameters in proper JSON formatting, e.g., \"temperature\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3502745319"] = "Invalid JSON: Add the parameters in proper JSON formatting, e.g., \\\"temperature\\\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though."
|
||||
|
||||
-- Reasoning (thinking) behavior
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3546126752"] = "Reasoning (thinking) behavior"
|
||||
|
||||
-- Reasoning (thinking) is available, but off unless additional API parameters enable it.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3548835672"] = "Reasoning (thinking) is available, but off unless additional API parameters enable it."
|
||||
|
||||
-- Show available models
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3763891899"] = "Show available models"
|
||||
|
||||
@ -4738,18 +4864,36 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3783329915"] = "This host u
|
||||
-- Duplicate key '{0}' found.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3804472591"] = "Duplicate key '{0}' found."
|
||||
|
||||
-- Override Model Capabilities
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3904244586"] = "Override Model Capabilities"
|
||||
|
||||
-- Currently, we cannot query the models for the selected provider and/or host. Therefore, please enter the model name manually.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4116737656"] = "Currently, we cannot query the models for the selected provider and/or host. Therefore, please enter the model name manually."
|
||||
|
||||
-- Model selection
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T416738168"] = "Model selection"
|
||||
|
||||
-- Stored default model capabilities may not reflect its full range. Override them here if needed.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4217532151"] = "Stored default model capabilities may not reflect its full range. Override them here if needed."
|
||||
|
||||
-- Video input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4289835208"] = "Video input"
|
||||
|
||||
-- We are currently unable to communicate with the provider to load models. Please try again later.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T504465522"] = "We are currently unable to communicate with the provider to load models. Please try again later."
|
||||
|
||||
-- Always reasoning
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T641757736"] = "Always reasoning"
|
||||
|
||||
-- Host
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T808120719"] = "Host"
|
||||
|
||||
-- Multiple image input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T858529900"] = "Multiple image input"
|
||||
|
||||
-- No reasoning (thinking)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T87434533"] = "No reasoning (thinking)"
|
||||
|
||||
-- Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T900237532"] = "Provider"
|
||||
|
||||
@ -7885,6 +8029,12 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANT
|
||||
-- Button
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANTCOMPONENTTYPEEXTENSIONS::T864557713"] = "Button"
|
||||
|
||||
-- The ASSISTANT table contains an invalid LaunchBehavior value.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T109828905"] = "The ASSISTANT table contains an invalid LaunchBehavior value."
|
||||
|
||||
-- The ASSISTANT table contains an unsupported LaunchBehavior value.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1194373781"] = "The ASSISTANT table contains an unsupported LaunchBehavior value."
|
||||
|
||||
-- Failed to parse the UI render tree from the ASSISTANT lua table.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1318499252"] = "Failed to parse the UI render tree from the ASSISTANT lua table."
|
||||
|
||||
@ -7900,12 +8050,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T2
|
||||
-- The ASSISTANT lua table does not exist or is not a valid table.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3017816936"] = "The ASSISTANT lua table does not exist or is not a valid table."
|
||||
|
||||
-- The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3233001282"] = "The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'."
|
||||
|
||||
-- The provided ASSISTANT lua table does not contain a valid system prompt.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3402798667"] = "The provided ASSISTANT lua table does not contain a valid system prompt."
|
||||
|
||||
-- The ASSISTANT table does not contain a valid system prompt.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3723171842"] = "The ASSISTANT table does not contain a valid system prompt."
|
||||
|
||||
-- The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T4215554842"] = "The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName."
|
||||
|
||||
-- ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T683382975"] = "ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax."
|
||||
|
||||
@ -7948,6 +8104,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2774333862"] = "The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used."
|
||||
|
||||
-- The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2824524534"] = "The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage."
|
||||
|
||||
-- Not Audited
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2828154864"] = "Not Audited"
|
||||
|
||||
@ -7957,12 +8116,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- Open Security Check
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T290241209"] = "Open Security Check"
|
||||
|
||||
-- User Audit
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3293963409"] = "User Audit"
|
||||
|
||||
-- Restricted
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3325062668"] = "Restricted"
|
||||
|
||||
-- Unknown
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3424652889"] = "Unknown"
|
||||
|
||||
-- Approved by your organization
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3508214481"] = "Approved by your organization"
|
||||
|
||||
-- Unlocked
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3606159420"] = "Unlocked"
|
||||
|
||||
@ -7978,9 +8143,24 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3899951594"] = "No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used."
|
||||
|
||||
-- No Approval
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T515592229"] = "No Approval"
|
||||
|
||||
-- This assistant was approved by your organization.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T538196816"] = "This assistant was approved by your organization."
|
||||
|
||||
-- Safe
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T760494712"] = "Safe"
|
||||
|
||||
-- Open Security Details
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T803119455"] = "Open Security Details"
|
||||
|
||||
-- Start Security Check
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T811648299"] = "Start Security Check"
|
||||
|
||||
-- This assistant was approved by your organization as '{0}'.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T834246718"] = "This assistant was approved by your organization as '{0}'."
|
||||
|
||||
-- This assistant currently has no stored audit.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T921972844"] = "This assistant currently has no stored audit."
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.IconFinder;
|
||||
|
||||
@ -56,6 +57,22 @@ public partial class AssistantIconFinder : AssistantBaseCore<SettingsDialogIconF
|
||||
|
||||
private string inputContext = string.Empty;
|
||||
private IconSources selectedIconSource;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_CONTEXT_STATE_KEY = new(nameof(inputContext));
|
||||
private static readonly AssistantSessionStateKey<IconSources> SELECTED_ICON_SOURCE_STATE_KEY = new(nameof(selectedIconSource));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_CONTEXT_STATE_KEY, this.inputContext);
|
||||
state.Set(SELECTED_ICON_SOURCE_STATE_KEY, this.selectedIconSource);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_CONTEXT_STATE_KEY, value => this.inputContext = value);
|
||||
state.Restore(SELECTED_ICON_SOURCE_STATE_KEY, value => this.selectedIconSource = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.JobPosting;
|
||||
|
||||
@ -128,6 +129,49 @@ public partial class AssistantJobPostings : AssistantBaseCore<SettingsDialogJobP
|
||||
private string inputCountryLegalFramework = string.Empty;
|
||||
private CommonLanguages selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_MANDATORY_INFORMATION_STATE_KEY = new(nameof(inputMandatoryInformation));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_JOB_DESCRIPTION_STATE_KEY = new(nameof(inputJobDescription));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_QUALIFICATIONS_STATE_KEY = new(nameof(inputQualifications));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_RESPONSIBILITIES_STATE_KEY = new(nameof(inputResponsibilities));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_COMPANY_NAME_STATE_KEY = new(nameof(inputCompanyName));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_ENTRY_DATE_STATE_KEY = new(nameof(inputEntryDate));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_VALID_UNTIL_STATE_KEY = new(nameof(inputValidUntil));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_WORK_LOCATION_STATE_KEY = new(nameof(inputWorkLocation));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_COUNTRY_LEGAL_FRAMEWORK_STATE_KEY = new(nameof(inputCountryLegalFramework));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_MANDATORY_INFORMATION_STATE_KEY, this.inputMandatoryInformation);
|
||||
state.Set(INPUT_JOB_DESCRIPTION_STATE_KEY, this.inputJobDescription);
|
||||
state.Set(INPUT_QUALIFICATIONS_STATE_KEY, this.inputQualifications);
|
||||
state.Set(INPUT_RESPONSIBILITIES_STATE_KEY, this.inputResponsibilities);
|
||||
state.Set(INPUT_COMPANY_NAME_STATE_KEY, this.inputCompanyName);
|
||||
state.Set(INPUT_ENTRY_DATE_STATE_KEY, this.inputEntryDate);
|
||||
state.Set(INPUT_VALID_UNTIL_STATE_KEY, this.inputValidUntil);
|
||||
state.Set(INPUT_WORK_LOCATION_STATE_KEY, this.inputWorkLocation);
|
||||
state.Set(INPUT_COUNTRY_LEGAL_FRAMEWORK_STATE_KEY, this.inputCountryLegalFramework);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_MANDATORY_INFORMATION_STATE_KEY, value => this.inputMandatoryInformation = value);
|
||||
state.Restore(INPUT_JOB_DESCRIPTION_STATE_KEY, value => this.inputJobDescription = value);
|
||||
state.Restore(INPUT_QUALIFICATIONS_STATE_KEY, value => this.inputQualifications = value);
|
||||
state.Restore(INPUT_RESPONSIBILITIES_STATE_KEY, value => this.inputResponsibilities = value);
|
||||
state.Restore(INPUT_COMPANY_NAME_STATE_KEY, value => this.inputCompanyName = value);
|
||||
state.Restore(INPUT_ENTRY_DATE_STATE_KEY, value => this.inputEntryDate = value);
|
||||
state.Restore(INPUT_VALID_UNTIL_STATE_KEY, value => this.inputValidUntil = value);
|
||||
state.Restore(INPUT_WORK_LOCATION_STATE_KEY, value => this.inputWorkLocation = value);
|
||||
state.Restore(INPUT_COUNTRY_LEGAL_FRAMEWORK_STATE_KEY, value => this.inputCountryLegalFramework = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.LegalCheck;
|
||||
|
||||
@ -59,6 +60,31 @@ public partial class AssistantLegalCheck : AssistantBaseCore<SettingsDialogLegal
|
||||
private bool isAgentRunning;
|
||||
private string inputLegalDocument = string.Empty;
|
||||
private string inputQuestions = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<bool> SHOW_WEB_CONTENT_READER_STATE_KEY = new(nameof(showWebContentReader));
|
||||
private static readonly AssistantSessionStateKey<bool> USE_CONTENT_CLEANER_AGENT_STATE_KEY = new(nameof(useContentCleanerAgent));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_AGENT_RUNNING_STATE_KEY = new(nameof(isAgentRunning));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_LEGAL_DOCUMENT_STATE_KEY = new(nameof(inputLegalDocument));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_QUESTIONS_STATE_KEY = new(nameof(inputQuestions));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SHOW_WEB_CONTENT_READER_STATE_KEY, this.showWebContentReader);
|
||||
state.Set(USE_CONTENT_CLEANER_AGENT_STATE_KEY, this.useContentCleanerAgent);
|
||||
state.Set(IS_AGENT_RUNNING_STATE_KEY, this.isAgentRunning);
|
||||
state.Set(INPUT_LEGAL_DOCUMENT_STATE_KEY, this.inputLegalDocument);
|
||||
state.Set(INPUT_QUESTIONS_STATE_KEY, this.inputQuestions);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SHOW_WEB_CONTENT_READER_STATE_KEY, value => this.showWebContentReader = value);
|
||||
state.Restore(USE_CONTENT_CLEANER_AGENT_STATE_KEY, value => this.useContentCleanerAgent = value);
|
||||
state.Restore(IS_AGENT_RUNNING_STATE_KEY, value => this.isAgentRunning = value);
|
||||
state.Restore(INPUT_LEGAL_DOCUMENT_STATE_KEY, value => this.inputLegalDocument = value);
|
||||
state.Restore(INPUT_QUESTIONS_STATE_KEY, value => this.inputQuestions = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.MyTasks;
|
||||
|
||||
@ -59,6 +60,25 @@ public partial class AssistantMyTasks : AssistantBaseCore<SettingsDialogMyTasks>
|
||||
private string inputText = string.Empty;
|
||||
private CommonLanguages selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_STATE_KEY = new(nameof(inputText));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_TEXT_STATE_KEY, this.inputText);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_TEXT_STATE_KEY, value => this.inputText = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
#if !DEBUG
|
||||
@ -176,6 +177,67 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialog
|
||||
private string recStructureMarkers = string.Empty;
|
||||
private string recRoleDefinition = string.Empty;
|
||||
private string recLanguageChoice = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_PROMPT_STATE_KEY = new(nameof(inputPrompt));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> IMPORTANT_ASPECTS_STATE_KEY = new(nameof(importantAspects));
|
||||
private static readonly AssistantSessionStateKey<bool> USE_CUSTOM_PROMPT_GUIDE_STATE_KEY = new(nameof(useCustomPromptGuide));
|
||||
private static readonly AssistantSessionStateKey<HashSet<FileAttachment>> CUSTOM_PROMPT_GUIDE_FILES_STATE_KEY = new(nameof(customPromptGuideFiles));
|
||||
private static readonly AssistantSessionStateKey<string> CURRENT_CUSTOM_PROMPT_GUIDE_PATH_STATE_KEY = new(nameof(currentCustomPromptGuidePath));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_PROMPTING_GUIDELINE_CONTENT_STATE_KEY = new(nameof(customPromptingGuidelineContent));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_LOADING_CUSTOM_PROMPT_GUIDE_STATE_KEY = new(nameof(isLoadingCustomPromptGuide));
|
||||
private static readonly AssistantSessionStateKey<bool> HAS_UPDATED_DEFAULT_RECOMMENDATIONS_STATE_KEY = new(nameof(hasUpdatedDefaultRecommendations));
|
||||
private static readonly AssistantSessionStateKey<string> OPTIMIZED_PROMPT_STATE_KEY = new(nameof(optimizedPrompt));
|
||||
private static readonly AssistantSessionStateKey<string> REC_CLARITY_DIRECTNESS_STATE_KEY = new(nameof(recClarityDirectness));
|
||||
private static readonly AssistantSessionStateKey<string> REC_EXAMPLES_CONTEXT_STATE_KEY = new(nameof(recExamplesContext));
|
||||
private static readonly AssistantSessionStateKey<string> REC_SEQUENTIAL_STEPS_STATE_KEY = new(nameof(recSequentialSteps));
|
||||
private static readonly AssistantSessionStateKey<string> REC_STRUCTURE_MARKERS_STATE_KEY = new(nameof(recStructureMarkers));
|
||||
private static readonly AssistantSessionStateKey<string> REC_ROLE_DEFINITION_STATE_KEY = new(nameof(recRoleDefinition));
|
||||
private static readonly AssistantSessionStateKey<string> REC_LANGUAGE_CHOICE_STATE_KEY = new(nameof(recLanguageChoice));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_PROMPT_STATE_KEY, this.inputPrompt);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(IMPORTANT_ASPECTS_STATE_KEY, this.importantAspects);
|
||||
state.Set(USE_CUSTOM_PROMPT_GUIDE_STATE_KEY, this.useCustomPromptGuide);
|
||||
state.SetHashSet(CUSTOM_PROMPT_GUIDE_FILES_STATE_KEY, this.customPromptGuideFiles);
|
||||
state.Set(CURRENT_CUSTOM_PROMPT_GUIDE_PATH_STATE_KEY, this.currentCustomPromptGuidePath);
|
||||
state.Set(CUSTOM_PROMPTING_GUIDELINE_CONTENT_STATE_KEY, this.customPromptingGuidelineContent);
|
||||
state.Set(IS_LOADING_CUSTOM_PROMPT_GUIDE_STATE_KEY, this.isLoadingCustomPromptGuide);
|
||||
state.Set(HAS_UPDATED_DEFAULT_RECOMMENDATIONS_STATE_KEY, this.hasUpdatedDefaultRecommendations);
|
||||
state.Set(OPTIMIZED_PROMPT_STATE_KEY, this.optimizedPrompt);
|
||||
state.Set(REC_CLARITY_DIRECTNESS_STATE_KEY, this.recClarityDirectness);
|
||||
state.Set(REC_EXAMPLES_CONTEXT_STATE_KEY, this.recExamplesContext);
|
||||
state.Set(REC_SEQUENTIAL_STEPS_STATE_KEY, this.recSequentialSteps);
|
||||
state.Set(REC_STRUCTURE_MARKERS_STATE_KEY, this.recStructureMarkers);
|
||||
state.Set(REC_ROLE_DEFINITION_STATE_KEY, this.recRoleDefinition);
|
||||
state.Set(REC_LANGUAGE_CHOICE_STATE_KEY, this.recLanguageChoice);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_PROMPT_STATE_KEY, value => this.inputPrompt = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(IMPORTANT_ASPECTS_STATE_KEY, value => this.importantAspects = value);
|
||||
state.Restore(USE_CUSTOM_PROMPT_GUIDE_STATE_KEY, value => this.useCustomPromptGuide = value);
|
||||
state.RestoreHashSet(CUSTOM_PROMPT_GUIDE_FILES_STATE_KEY, this.customPromptGuideFiles);
|
||||
state.Restore(CURRENT_CUSTOM_PROMPT_GUIDE_PATH_STATE_KEY, value => this.currentCustomPromptGuidePath = value);
|
||||
state.Restore(CUSTOM_PROMPTING_GUIDELINE_CONTENT_STATE_KEY, value => this.customPromptingGuidelineContent = value);
|
||||
state.Restore(IS_LOADING_CUSTOM_PROMPT_GUIDE_STATE_KEY, value => this.isLoadingCustomPromptGuide = value);
|
||||
state.Restore(HAS_UPDATED_DEFAULT_RECOMMENDATIONS_STATE_KEY, value => this.hasUpdatedDefaultRecommendations = value);
|
||||
state.Restore(OPTIMIZED_PROMPT_STATE_KEY, value => this.optimizedPrompt = value);
|
||||
state.Restore(REC_CLARITY_DIRECTNESS_STATE_KEY, value => this.recClarityDirectness = value);
|
||||
state.Restore(REC_EXAMPLES_CONTEXT_STATE_KEY, value => this.recExamplesContext = value);
|
||||
state.Restore(REC_SEQUENTIAL_STEPS_STATE_KEY, value => this.recSequentialSteps = value);
|
||||
state.Restore(REC_STRUCTURE_MARKERS_STATE_KEY, value => this.recStructureMarkers = value);
|
||||
state.Restore(REC_ROLE_DEFINITION_STATE_KEY, value => this.recRoleDefinition = value);
|
||||
state.Restore(REC_LANGUAGE_CHOICE_STATE_KEY, value => this.recLanguageChoice = value);
|
||||
}
|
||||
|
||||
private bool ShowUpdatedPromptGuidelinesIndicator => !this.useCustomPromptGuide && this.hasUpdatedDefaultRecommendations;
|
||||
private bool CanPreviewCustomPromptGuide => this.useCustomPromptGuide && this.customPromptGuideFiles.Count > 0;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.RewriteImprove;
|
||||
|
||||
@ -91,6 +92,34 @@ public partial class AssistantRewriteImprove : AssistantBaseCore<SettingsDialogR
|
||||
private string rewrittenText = string.Empty;
|
||||
private WritingStyles selectedWritingStyle;
|
||||
private SentenceStructure selectedSentenceStructure;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_STATE_KEY = new(nameof(inputText));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> REWRITTEN_TEXT_STATE_KEY = new(nameof(rewrittenText));
|
||||
private static readonly AssistantSessionStateKey<WritingStyles> SELECTED_WRITING_STYLE_STATE_KEY = new(nameof(selectedWritingStyle));
|
||||
private static readonly AssistantSessionStateKey<SentenceStructure> SELECTED_SENTENCE_STRUCTURE_STATE_KEY = new(nameof(selectedSentenceStructure));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_TEXT_STATE_KEY, this.inputText);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(REWRITTEN_TEXT_STATE_KEY, this.rewrittenText);
|
||||
state.Set(SELECTED_WRITING_STYLE_STATE_KEY, this.selectedWritingStyle);
|
||||
state.Set(SELECTED_SENTENCE_STRUCTURE_STATE_KEY, this.selectedSentenceStructure);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_TEXT_STATE_KEY, value => this.inputText = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(REWRITTEN_TEXT_STATE_KEY, value => this.rewrittenText = value);
|
||||
state.Restore(SELECTED_WRITING_STYLE_STATE_KEY, value => this.selectedWritingStyle = value);
|
||||
state.Restore(SELECTED_SENTENCE_STRUCTURE_STATE_KEY, value => this.selectedSentenceStructure = value);
|
||||
}
|
||||
|
||||
private string? ValidateText(string text)
|
||||
{
|
||||
@ -134,6 +163,13 @@ public partial class AssistantRewriteImprove : AssistantBaseCore<SettingsDialogR
|
||||
var time = this.AddUserRequest(this.inputText);
|
||||
|
||||
this.rewrittenText = await this.AddAIResponseAsync(time);
|
||||
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.rewrittenText);
|
||||
if (!this.IsAssistantComponentDisposed)
|
||||
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.rewrittenText);
|
||||
}
|
||||
|
||||
protected override async Task OnAssistantSessionRenderedAsync(AssistantSessionSnapshot snapshot)
|
||||
{
|
||||
if (!snapshot.IsActive && !string.IsNullOrWhiteSpace(this.inputText) && !string.IsNullOrWhiteSpace(this.rewrittenText))
|
||||
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.rewrittenText);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
@ -197,6 +198,58 @@ public partial class SlideAssistant : AssistantBaseCore<SettingsDialogSlideBuild
|
||||
private int calculatedNumberOfSlides;
|
||||
private string importantAspects = string.Empty;
|
||||
private HashSet<FileAttachment> loadedDocumentPaths = [];
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TITLE_STATE_KEY = new(nameof(inputTitle));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_CONTENT_STATE_KEY = new(nameof(inputContent));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<AudienceProfile> SELECTED_AUDIENCE_PROFILE_STATE_KEY = new(nameof(selectedAudienceProfile));
|
||||
private static readonly AssistantSessionStateKey<AudienceAgeGroup> SELECTED_AUDIENCE_AGE_GROUP_STATE_KEY = new(nameof(selectedAudienceAgeGroup));
|
||||
private static readonly AssistantSessionStateKey<AudienceOrganizationalLevel> SELECTED_AUDIENCE_ORGANIZATIONAL_LEVEL_STATE_KEY = new(nameof(selectedAudienceOrganizationalLevel));
|
||||
private static readonly AssistantSessionStateKey<AudienceExpertise> SELECTED_AUDIENCE_EXPERTISE_STATE_KEY = new(nameof(selectedAudienceExpertise));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<int> NUMBER_OF_SHEETS_STATE_KEY = new(nameof(numberOfSheets));
|
||||
private static readonly AssistantSessionStateKey<int> NUMBER_OF_BULLET_POINTS_STATE_KEY = new(nameof(numberOfBulletPoints));
|
||||
private static readonly AssistantSessionStateKey<int> TIME_SPECIFICATION_STATE_KEY = new(nameof(timeSpecification));
|
||||
private static readonly AssistantSessionStateKey<int> CALCULATED_NUMBER_OF_SLIDES_STATE_KEY = new(nameof(calculatedNumberOfSlides));
|
||||
private static readonly AssistantSessionStateKey<string> IMPORTANT_ASPECTS_STATE_KEY = new(nameof(importantAspects));
|
||||
private static readonly AssistantSessionStateKey<HashSet<FileAttachment>> LOADED_DOCUMENT_PATHS_STATE_KEY = new(nameof(loadedDocumentPaths));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_TITLE_STATE_KEY, this.inputTitle);
|
||||
state.Set(INPUT_CONTENT_STATE_KEY, this.inputContent);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(SELECTED_AUDIENCE_PROFILE_STATE_KEY, this.selectedAudienceProfile);
|
||||
state.Set(SELECTED_AUDIENCE_AGE_GROUP_STATE_KEY, this.selectedAudienceAgeGroup);
|
||||
state.Set(SELECTED_AUDIENCE_ORGANIZATIONAL_LEVEL_STATE_KEY, this.selectedAudienceOrganizationalLevel);
|
||||
state.Set(SELECTED_AUDIENCE_EXPERTISE_STATE_KEY, this.selectedAudienceExpertise);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(NUMBER_OF_SHEETS_STATE_KEY, this.numberOfSheets);
|
||||
state.Set(NUMBER_OF_BULLET_POINTS_STATE_KEY, this.numberOfBulletPoints);
|
||||
state.Set(TIME_SPECIFICATION_STATE_KEY, this.timeSpecification);
|
||||
state.Set(CALCULATED_NUMBER_OF_SLIDES_STATE_KEY, this.calculatedNumberOfSlides);
|
||||
state.Set(IMPORTANT_ASPECTS_STATE_KEY, this.importantAspects);
|
||||
state.SetHashSet(LOADED_DOCUMENT_PATHS_STATE_KEY, this.loadedDocumentPaths);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_TITLE_STATE_KEY, value => this.inputTitle = value);
|
||||
state.Restore(INPUT_CONTENT_STATE_KEY, value => this.inputContent = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(SELECTED_AUDIENCE_PROFILE_STATE_KEY, value => this.selectedAudienceProfile = value);
|
||||
state.Restore(SELECTED_AUDIENCE_AGE_GROUP_STATE_KEY, value => this.selectedAudienceAgeGroup = value);
|
||||
state.Restore(SELECTED_AUDIENCE_ORGANIZATIONAL_LEVEL_STATE_KEY, value => this.selectedAudienceOrganizationalLevel = value);
|
||||
state.Restore(SELECTED_AUDIENCE_EXPERTISE_STATE_KEY, value => this.selectedAudienceExpertise = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(NUMBER_OF_SHEETS_STATE_KEY, value => this.numberOfSheets = value);
|
||||
state.Restore(NUMBER_OF_BULLET_POINTS_STATE_KEY, value => this.numberOfBulletPoints = value);
|
||||
state.Restore(TIME_SPECIFICATION_STATE_KEY, value => this.timeSpecification = value);
|
||||
state.Restore(CALCULATED_NUMBER_OF_SLIDES_STATE_KEY, value => this.calculatedNumberOfSlides = value);
|
||||
state.Restore(IMPORTANT_ASPECTS_STATE_KEY, value => this.importantAspects = value);
|
||||
state.RestoreHashSet(LOADED_DOCUMENT_PATHS_STATE_KEY, this.loadedDocumentPaths);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.Synonym;
|
||||
|
||||
@ -103,6 +104,28 @@ public partial class AssistantSynonyms : AssistantBaseCore<SettingsDialogSynonym
|
||||
private string inputContext = string.Empty;
|
||||
private CommonLanguages selectedLanguage;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_STATE_KEY = new(nameof(inputText));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_CONTEXT_STATE_KEY = new(nameof(inputContext));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_LANGUAGE_STATE_KEY = new(nameof(selectedLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(INPUT_TEXT_STATE_KEY, this.inputText);
|
||||
state.Set(INPUT_CONTEXT_STATE_KEY, this.inputContext);
|
||||
state.Set(SELECTED_LANGUAGE_STATE_KEY, this.selectedLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(INPUT_TEXT_STATE_KEY, value => this.inputText = value);
|
||||
state.Restore(INPUT_CONTEXT_STATE_KEY, value => this.inputContext = value);
|
||||
state.Restore(SELECTED_LANGUAGE_STATE_KEY, value => this.selectedLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.TextSummarizer;
|
||||
|
||||
@ -72,6 +73,43 @@ public partial class AssistantTextSummarizer : AssistantBaseCore<SettingsDialogT
|
||||
private Complexity selectedComplexity;
|
||||
private string expertInField = string.Empty;
|
||||
private string importantAspects = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<bool> SHOW_WEB_CONTENT_READER_STATE_KEY = new(nameof(showWebContentReader));
|
||||
private static readonly AssistantSessionStateKey<bool> USE_CONTENT_CLEANER_AGENT_STATE_KEY = new(nameof(useContentCleanerAgent));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_STATE_KEY = new(nameof(inputText));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_AGENT_RUNNING_STATE_KEY = new(nameof(isAgentRunning));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<Complexity> SELECTED_COMPLEXITY_STATE_KEY = new(nameof(selectedComplexity));
|
||||
private static readonly AssistantSessionStateKey<string> EXPERT_IN_FIELD_STATE_KEY = new(nameof(expertInField));
|
||||
private static readonly AssistantSessionStateKey<string> IMPORTANT_ASPECTS_STATE_KEY = new(nameof(importantAspects));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SHOW_WEB_CONTENT_READER_STATE_KEY, this.showWebContentReader);
|
||||
state.Set(USE_CONTENT_CLEANER_AGENT_STATE_KEY, this.useContentCleanerAgent);
|
||||
state.Set(INPUT_TEXT_STATE_KEY, this.inputText);
|
||||
state.Set(IS_AGENT_RUNNING_STATE_KEY, this.isAgentRunning);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
state.Set(SELECTED_COMPLEXITY_STATE_KEY, this.selectedComplexity);
|
||||
state.Set(EXPERT_IN_FIELD_STATE_KEY, this.expertInField);
|
||||
state.Set(IMPORTANT_ASPECTS_STATE_KEY, this.importantAspects);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SHOW_WEB_CONTENT_READER_STATE_KEY, value => this.showWebContentReader = value);
|
||||
state.Restore(USE_CONTENT_CLEANER_AGENT_STATE_KEY, value => this.useContentCleanerAgent = value);
|
||||
state.Restore(INPUT_TEXT_STATE_KEY, value => this.inputText = value);
|
||||
state.Restore(IS_AGENT_RUNNING_STATE_KEY, value => this.isAgentRunning = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
state.Restore(SELECTED_COMPLEXITY_STATE_KEY, value => this.selectedComplexity = value);
|
||||
state.Restore(EXPERT_IN_FIELD_STATE_KEY, value => this.expertInField = value);
|
||||
state.Restore(IMPORTANT_ASPECTS_STATE_KEY, value => this.importantAspects = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
|
||||
namespace AIStudio.Assistants.Translation;
|
||||
|
||||
@ -79,6 +80,40 @@ public partial class AssistantTranslation : AssistantBaseCore<SettingsDialogTran
|
||||
private string inputTextLastTranslation = string.Empty;
|
||||
private CommonLanguages selectedTargetLanguage;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private static readonly AssistantSessionStateKey<bool> SHOW_WEB_CONTENT_READER_STATE_KEY = new(nameof(showWebContentReader));
|
||||
private static readonly AssistantSessionStateKey<bool> USE_CONTENT_CLEANER_AGENT_STATE_KEY = new(nameof(useContentCleanerAgent));
|
||||
private static readonly AssistantSessionStateKey<bool> LIVE_TRANSLATION_STATE_KEY = new(nameof(liveTranslation));
|
||||
private static readonly AssistantSessionStateKey<bool> IS_AGENT_RUNNING_STATE_KEY = new(nameof(isAgentRunning));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_STATE_KEY = new(nameof(inputText));
|
||||
private static readonly AssistantSessionStateKey<string> INPUT_TEXT_LAST_TRANSLATION_STATE_KEY = new(nameof(inputTextLastTranslation));
|
||||
private static readonly AssistantSessionStateKey<CommonLanguages> SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage));
|
||||
private static readonly AssistantSessionStateKey<string> CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void CaptureCustomAssistantSessionState(AssistantSessionStateWriter state)
|
||||
{
|
||||
state.Set(SHOW_WEB_CONTENT_READER_STATE_KEY, this.showWebContentReader);
|
||||
state.Set(USE_CONTENT_CLEANER_AGENT_STATE_KEY, this.useContentCleanerAgent);
|
||||
state.Set(LIVE_TRANSLATION_STATE_KEY, this.liveTranslation);
|
||||
state.Set(IS_AGENT_RUNNING_STATE_KEY, this.isAgentRunning);
|
||||
state.Set(INPUT_TEXT_STATE_KEY, this.inputText);
|
||||
state.Set(INPUT_TEXT_LAST_TRANSLATION_STATE_KEY, this.inputTextLastTranslation);
|
||||
state.Set(SELECTED_TARGET_LANGUAGE_STATE_KEY, this.selectedTargetLanguage);
|
||||
state.Set(CUSTOM_TARGET_LANGUAGE_STATE_KEY, this.customTargetLanguage);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
state.Restore(SHOW_WEB_CONTENT_READER_STATE_KEY, value => this.showWebContentReader = value);
|
||||
state.Restore(USE_CONTENT_CLEANER_AGENT_STATE_KEY, value => this.useContentCleanerAgent = value);
|
||||
state.Restore(LIVE_TRANSLATION_STATE_KEY, value => this.liveTranslation = value);
|
||||
state.Restore(IS_AGENT_RUNNING_STATE_KEY, value => this.isAgentRunning = value);
|
||||
state.Restore(INPUT_TEXT_STATE_KEY, value => this.inputText = value);
|
||||
state.Restore(INPUT_TEXT_LAST_TRANSLATION_STATE_KEY, value => this.inputTextLastTranslation = value);
|
||||
state.Restore(SELECTED_TARGET_LANGUAGE_STATE_KEY, value => this.selectedTargetLanguage = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@
|
||||
var segmentContent = segment.GetContent(renderPlan.Source);
|
||||
if (segment.Type is MarkdownRenderSegmentType.MARKDOWN)
|
||||
{
|
||||
<MudMarkdown @key="@segment.RenderKey" Value="@segmentContent" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE" />
|
||||
<MudMarkdown @key="@segment.RenderKey" Value="@segmentContent" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.CHAT_MARKDOWN_PIPELINE" />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -7,7 +7,17 @@
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<MudStack AlignItems="AlignItems.Center" Row="@true">
|
||||
<MudIcon Icon="@this.Icon" Size="Size.Large" Color="Color.Primary"/>
|
||||
<MudElement HtmlTag="span" Style="position: relative; display: inline-flex; line-height: 1;">
|
||||
<MudIcon Icon="@this.Icon" Size="Size.Large" Color="Color.Primary"/>
|
||||
@if (this.AssistantSessionIndicator is { } indicator)
|
||||
{
|
||||
<MudTooltip Text="@indicator.Tooltip">
|
||||
<MudElement HtmlTag="span" Style="position: absolute; right: -0.45rem; bottom: -0.3rem; display: inline-flex; background-color: var(--mud-palette-surface); border-radius: 50%; padding: 1px;">
|
||||
<MudIcon Icon="@indicator.Icon" Size="Size.Small" Color="@indicator.Color"/>
|
||||
</MudElement>
|
||||
</MudTooltip>
|
||||
}
|
||||
</MudElement>
|
||||
<MudText Typo="Typo.h6">
|
||||
@this.Name
|
||||
</MudText>
|
||||
@ -24,9 +34,18 @@
|
||||
<MudCardActions>
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Style="width: 100%;">
|
||||
<MudButtonGroup Variant="Variant.Outlined">
|
||||
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" Href="@this.Link" Disabled="@this.Disabled">
|
||||
@this.ButtonText
|
||||
</MudButton>
|
||||
@if (this.HasStartAction)
|
||||
{
|
||||
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" OnClick="@this.OnClick" Disabled="@this.Disabled">
|
||||
@this.ButtonText
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" Href="@this.Link" Disabled="@this.Disabled">
|
||||
@this.ButtonText
|
||||
</MudButton>
|
||||
}
|
||||
@if (this.HasSettingsPanel)
|
||||
{
|
||||
<MudIconButton Variant="Variant.Text" Icon="@Icons.Material.Filled.Settings" Color="Color.Default" OnClick="@this.OpenSettingsDialog"/>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
||||
|
||||
@ -7,6 +8,14 @@ namespace AIStudio.Components;
|
||||
|
||||
public partial class AssistantBlock<TSettings> : MSGComponentBase where TSettings : IComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the assistant session indicator shown on top of the assistant icon.
|
||||
/// </summary>
|
||||
/// <param name="Icon">The icon that communicates the session status.</param>
|
||||
/// <param name="Color">The color that communicates the session status.</param>
|
||||
/// <param name="Tooltip">The tooltip text that explains the session status.</param>
|
||||
private sealed record AssistantSessionIndicatorData(string Icon, Color Color, string Tooltip);
|
||||
|
||||
[Parameter]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
@ -22,6 +31,9 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase where TSetting
|
||||
[Parameter]
|
||||
public string Link { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback OnClick { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
@ -31,6 +43,12 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase where TSetting
|
||||
[Parameter]
|
||||
public Tools.Components Component { get; set; } = Tools.Components.NONE;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional assistant session instance ID represented by this block.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string AssistantSessionInstanceId { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public PreviewFeatures RequiredPreviewFeature { get; set; } = PreviewFeatures.NONE;
|
||||
|
||||
@ -39,6 +57,9 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase where TSetting
|
||||
|
||||
[Inject]
|
||||
private IDialogService DialogService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private AssistantSessionService AssistantSessionService { get; init; } = null!;
|
||||
|
||||
private async Task OpenSettingsDialog()
|
||||
{
|
||||
@ -50,15 +71,52 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase where TSetting
|
||||
await this.DialogService.ShowAsync<TSettings>(T("Open Settings"), dialogParameters, DialogOptions.FULLSCREEN);
|
||||
}
|
||||
|
||||
private string BorderColor => this.SettingsManager.IsDarkMode switch
|
||||
private string BorderColor => this.AssistantSessionSnapshot?.IsActive is true ? this.ColorTheme.GetActivityIndicatorColor(this.SettingsManager) : this.SettingsManager.IsDarkMode switch
|
||||
{
|
||||
true => this.ColorTheme.GetCurrentPalette(this.SettingsManager).GrayLight,
|
||||
false => this.ColorTheme.GetCurrentPalette(this.SettingsManager).Primary.Value,
|
||||
true => this.ColorTheme.GetCurrentPalette(this.SettingsManager).GrayDefault,
|
||||
false => this.ColorTheme.GetCurrentPalette(this.SettingsManager).GrayDefault,
|
||||
};
|
||||
|
||||
private string BlockStyle => $"border-width: 2px; border-color: {this.BorderColor}; border-radius: 12px; border-style: solid; max-width: 20em;";
|
||||
private string BlockStyle => $"border-width: 3px; border-color: {this.BorderColor}; border-radius: 12px; border-style: solid; max-width: 20em;";
|
||||
|
||||
private bool IsVisible => this.SettingsManager.IsAssistantVisible(this.Component, assistantName: this.Name, requiredPreviewFeature: this.RequiredPreviewFeature);
|
||||
|
||||
private bool HasSettingsPanel => typeof(TSettings) != typeof(NoSettingsPanel);
|
||||
}
|
||||
|
||||
private bool HasStartAction => this.OnClick.HasDelegate;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the newest assistant session snapshot represented by this block.
|
||||
/// </summary>
|
||||
private AssistantSessionSnapshot? AssistantSessionSnapshot => string.IsNullOrWhiteSpace(this.AssistantSessionInstanceId)
|
||||
? this.AssistantSessionService.GetSnapshots().FirstOrDefault(snapshot => snapshot.Key.Component == this.Component)
|
||||
: this.AssistantSessionService.GetSnapshots().FirstOrDefault(snapshot => snapshot.Key.InstanceId == this.AssistantSessionInstanceId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assistant session indicator shown on top of the assistant icon.
|
||||
/// </summary>
|
||||
private AssistantSessionIndicatorData? AssistantSessionIndicator => this.AssistantSessionSnapshot?.Status switch
|
||||
{
|
||||
AssistantSessionStatus.RUNNING or AssistantSessionStatus.CANCELING => new(Icons.Material.Filled.ChangeCircle, Color.Info, this.T("Assistant is still running.")),
|
||||
AssistantSessionStatus.COMPLETED => new(Icons.Material.Filled.TaskAlt, Color.Success, this.T("The result is ready.")),
|
||||
AssistantSessionStatus.FAILED => new(Icons.Material.Filled.Error, Color.Error, this.T("Assistant failed. Open it to review the result.")),
|
||||
AssistantSessionStatus.CANCELED => new(Icons.Material.Filled.Cancel, Color.Warning, this.T("Assistant was canceled. Open it to review the result.")),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the block when assistant session activity changes.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The message payload type.</typeparam>
|
||||
/// <param name="sendingComponent">The component that sent the message, if any.</param>
|
||||
/// <param name="triggeredEvent">The event that was triggered.</param>
|
||||
/// <param name="data">The message payload.</param>
|
||||
/// <returns>A task that completes after the message was processed.</returns>
|
||||
protected override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
||||
{
|
||||
if (triggeredEvent is Event.ASSISTANT_SESSION_CHANGED or Event.ASSISTANT_SESSION_FINISHED)
|
||||
this.StateHasChanged();
|
||||
|
||||
return base.ProcessIncomingMessage(sendingComponent, triggeredEvent, data);
|
||||
}
|
||||
}
|
||||
@ -33,6 +33,12 @@
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Filled" Color="@state.AuditColor">
|
||||
@state.AuditLabel
|
||||
</MudChip>
|
||||
@if (!string.IsNullOrWhiteSpace(state.SourceLabel))
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Filled" Color="@state.SourceColor" Icon="@state.SourceIcon">
|
||||
@state.SourceLabel
|
||||
</MudChip>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(state.AvailabilityLabel))
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="@state.AvailabilityColor" Icon="@state.AvailabilityIcon">
|
||||
@ -53,18 +59,28 @@
|
||||
|
||||
<MudCardContent Class="pt-0 pb-2">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="4" Class="flex-wrap">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Speed" Size="Size.Small" />
|
||||
<MudText Typo="Typo.body2">@T("Confidence"):</MudText>
|
||||
<MudProgressLinear Color="@state.AuditColor"
|
||||
Value="@this.GetConfidencePercentage()"
|
||||
Rounded="@true"
|
||||
Size="Size.Medium"
|
||||
Style="width: 80px; min-width: 80px;" />
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
@this.GetConfidenceLabel()
|
||||
</MudText>
|
||||
</MudStack>
|
||||
@if (state.IsEnterpriseApproved)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Business" Size="Size.Small" Color="@state.SourceColor" />
|
||||
<MudText Typo="Typo.body2">@T("Enterprise approval is active")</MudText>
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Speed" Size="Size.Small" />
|
||||
<MudText Typo="Typo.body2">@T("Confidence"):</MudText>
|
||||
<MudProgressLinear Color="@state.AuditColor"
|
||||
Value="@this.GetConfidencePercentage()"
|
||||
Rounded="@true"
|
||||
Size="Size.Medium"
|
||||
Style="width: 80px; min-width: 80px;" />
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
@this.GetConfidenceLabel()
|
||||
</MudText>
|
||||
</MudStack>
|
||||
}
|
||||
<MudDivider Vertical="@true" FlexItem="@true" />
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.BugReport" Size="Size.Small" Color="@state.AuditColor" />
|
||||
@ -104,12 +120,63 @@
|
||||
</td>
|
||||
<td><code style="font-size: 0.8rem;">@this.Plugin.Id</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Status source")</b></MudText>
|
||||
</td>
|
||||
<td><MudText Typo="Typo.body2">@state.SourceLabel</MudText></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Current hash")</b></MudText>
|
||||
</td>
|
||||
<td><code style="font-size: 0.8rem;">@GetShortHash(state.CurrentHash)</code></td>
|
||||
</tr>
|
||||
@if (state.EnterpriseApproval is not null)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Approved hash")</b></MudText>
|
||||
</td>
|
||||
<td><code style="font-size: 0.8rem;">@GetShortHash(state.EnterpriseApproval.PluginHash)</code></td>
|
||||
</tr>
|
||||
@if (!string.IsNullOrWhiteSpace(state.EnterpriseApproval.DisplayName))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Approved name")</b></MudText>
|
||||
</td>
|
||||
<td><MudText Typo="Typo.body2">@state.EnterpriseApproval.DisplayName</MudText></td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(state.EnterpriseApproval.ApprovedBy))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Approved by")</b></MudText>
|
||||
</td>
|
||||
<td><MudText Typo="Typo.body2">@state.EnterpriseApproval.ApprovedBy</MudText></td>
|
||||
</tr>
|
||||
}
|
||||
@if (state.EnterpriseApproval.ApprovedAtUtc is not null)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Approved at")</b></MudText>
|
||||
</td>
|
||||
<td><MudText Typo="Typo.body2">@this.FormatFileTimestamp(state.EnterpriseApproval.ApprovedAtUtc.Value.ToLocalTime().DateTime)</MudText></td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(state.EnterpriseApproval.Comment))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<MudText Typo="Typo.body2"><b>@T("Approval comment")</b></MudText>
|
||||
</td>
|
||||
<td><MudText Typo="Typo.body2">@state.EnterpriseApproval.Comment</MudText></td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
@if (state.Audit is not null)
|
||||
{
|
||||
<tr>
|
||||
@ -156,9 +223,18 @@
|
||||
|
||||
@if (state.Audit is null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Text" Dense="@true">
|
||||
@T("No stored audit details are available yet.")
|
||||
</MudAlert>
|
||||
@if (state.IsEnterpriseApproved)
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Text" Dense="@true">
|
||||
@T("This plugin is approved by your organization. A manual security audit is not required.")
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Text" Dense="@true">
|
||||
@T("No stored audit details are available yet.")
|
||||
</MudAlert>
|
||||
}
|
||||
}
|
||||
else if (state.Audit.Findings.Count == 0)
|
||||
{
|
||||
|
||||
@ -103,12 +103,23 @@ public partial class AssistantPluginSecurityCard : MSGComponentBase
|
||||
|
||||
private string GetFindingSummary()
|
||||
{
|
||||
if (this.SecurityState.IsEnterpriseApproved)
|
||||
return this.T("No user audit required");
|
||||
|
||||
var count = this.SecurityState.Audit?.Findings.Count ?? 0;
|
||||
return string.Format(this.T("{0} Finding(s)"), count);
|
||||
}
|
||||
|
||||
private string GetAuditTimestampLabel()
|
||||
{
|
||||
if (this.SecurityState.IsEnterpriseApproved)
|
||||
{
|
||||
var approvedAt = this.SecurityState.EnterpriseApproval?.ApprovedAtUtc;
|
||||
return approvedAt is null
|
||||
? this.T("Company approved")
|
||||
: this.FormatFileTimestamp(approvedAt.Value.ToLocalTime().DateTime);
|
||||
}
|
||||
|
||||
var auditedAt = this.SecurityState.Audit?.AuditedAtUtc;
|
||||
return auditedAt is null
|
||||
? this.T("No audit yet")
|
||||
|
||||
@ -59,6 +59,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
||||
|
||||
private DataSourceSelection? dataSourceSelectionComponent;
|
||||
private DataSourceOptions earlyDataSourceOptions = new();
|
||||
private DataSourceOptions lastAppliedStandardDataSourceOptions = new();
|
||||
private Profile currentProfile = Profile.NO_PROFILE;
|
||||
private ChatTemplate currentChatTemplate = ChatTemplate.NO_CHAT_TEMPLATE;
|
||||
private bool hasUnsavedChanges;
|
||||
@ -118,6 +119,8 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
||||
if (!this.ComposerState.HasUserDraft && !this.ComposerState.HasComposerContent)
|
||||
this.ComposerState.ApplyTemplate(this.currentChatTemplate);
|
||||
|
||||
this.lastAppliedStandardDataSourceOptions = this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy();
|
||||
|
||||
var deferredInput = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_CHAT_INPUT).FirstOrDefault();
|
||||
if (!string.IsNullOrWhiteSpace(deferredInput))
|
||||
this.ComposerState.SetUserInput(deferredInput);
|
||||
@ -458,12 +461,42 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
||||
private void ApplyStandardDataSourceOptions()
|
||||
{
|
||||
var chatDefaultOptions = this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy();
|
||||
this.lastAppliedStandardDataSourceOptions = chatDefaultOptions.CreateCopy();
|
||||
this.earlyDataSourceOptions = chatDefaultOptions;
|
||||
if(this.ChatThread is not null)
|
||||
this.ChatThread.DataSourceOptions = chatDefaultOptions;
|
||||
|
||||
this.dataSourceSelectionComponent?.ChangeOptionWithoutSaving(chatDefaultOptions);
|
||||
}
|
||||
|
||||
private async Task ApplyUpdatedStandardDataSourceOptionsAfterConfigurationChange()
|
||||
{
|
||||
var updatedStandardOptions = this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy();
|
||||
var previousStandardOptions = this.lastAppliedStandardDataSourceOptions;
|
||||
this.lastAppliedStandardDataSourceOptions = updatedStandardOptions.CreateCopy();
|
||||
|
||||
if (this.ChatThread is null)
|
||||
{
|
||||
this.earlyDataSourceOptions = updatedStandardOptions;
|
||||
this.dataSourceSelectionComponent?.ChangeOptionWithoutSaving(updatedStandardOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DataSourceOptionsAreEqual(this.ChatThread.DataSourceOptions, previousStandardOptions))
|
||||
return;
|
||||
|
||||
await this.SetCurrentDataSourceOptions(updatedStandardOptions);
|
||||
this.dataSourceSelectionComponent?.ChangeOptionWithoutSaving(updatedStandardOptions, this.ChatThread.AISelectedDataSources);
|
||||
await this.ChatThreadChanged.InvokeAsync(this.ChatThread);
|
||||
}
|
||||
|
||||
private static bool DataSourceOptionsAreEqual(DataSourceOptions left, DataSourceOptions right)
|
||||
{
|
||||
return left.DisableDataSources == right.DisableDataSources
|
||||
&& left.AutomaticDataSourceSelection == right.AutomaticDataSourceSelection
|
||||
&& left.AutomaticValidation == right.AutomaticValidation
|
||||
&& left.PreselectedDataSourceIds.ToHashSet(StringComparer.Ordinal).SetEquals(right.PreselectedDataSourceIds);
|
||||
}
|
||||
|
||||
private string ExtractThreadName(string firstUserInput)
|
||||
{
|
||||
@ -547,6 +580,8 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
||||
|
||||
if (!this.ComposerState.HasUserDraft && previousChatTemplate != this.currentChatTemplate)
|
||||
this.ComposerState.ApplyTemplate(this.currentChatTemplate);
|
||||
|
||||
await this.ApplyUpdatedStandardDataSourceOptionsAfterConfigurationChange();
|
||||
}
|
||||
|
||||
private IReadOnlyList<DataSourceAgentSelected> GetAgentSelectedDataSources()
|
||||
|
||||
@ -160,13 +160,13 @@ else if (this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE)
|
||||
</MudText>
|
||||
}
|
||||
|
||||
<MudTextSwitch Label="@T("Are data sources enabled?")" Value="@this.areDataSourcesEnabled" LabelOn="@T("Yes, I want to use data sources.")" LabelOff="@T("No, I don't want to use data sources.")" ValueChanged="@this.EnabledChanged"/>
|
||||
<MudTextSwitch Label="@T("Are data sources enabled?")" Value="@this.areDataSourcesEnabled" LabelOn="@T("Yes, I want to use data sources.")" LabelOff="@T("No, I don't want to use data sources.")" ValueChanged="@this.EnabledChanged" Disabled="@this.IsPreselectedDataSourcesDisabledLocked()"/>
|
||||
@if (this.areDataSourcesEnabled)
|
||||
{
|
||||
<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"/>
|
||||
<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"/>
|
||||
<MudField Label="@T("Available Data Sources")" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.aiBasedSourceSelection">
|
||||
<MudList T="IDataSource" SelectionMode="@this.GetListSelectionMode()" @bind-SelectedValues:get="@this.selectedDataSources" @bind-SelectedValues:set="@(x => this.SelectionChanged(x))">
|
||||
<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" Disabled="@this.IsPreselectedDataSourcesAutomaticSelectionLocked()"/>
|
||||
<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" Disabled="@this.IsPreselectedDataSourcesAutomaticValidationLocked()"/>
|
||||
<MudField Label="@T("Available Data Sources")" Variant="Variant.Outlined" Class="mb-3" Disabled="@(this.aiBasedSourceSelection || this.IsPreselectedDataSourceIdsLocked())">
|
||||
<MudList T="IDataSource" SelectionMode="@this.GetListSelectionMode()" @bind-SelectedValues:get="@this.selectedDataSources" @bind-SelectedValues:set="@(x => this.SelectionChanged(x))" ReadOnly="@this.IsPreselectedDataSourceIdsLocked()">
|
||||
@foreach (var source in this.availableDataSources)
|
||||
{
|
||||
<MudListItem Value="@source">
|
||||
|
||||
@ -52,6 +52,7 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
private bool aiBasedSourceSelection;
|
||||
private bool aiBasedValidation;
|
||||
private bool areDataSourcesEnabled;
|
||||
private uint loadAndApplyFiltersGeneration;
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
@ -75,15 +76,7 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
// Right before the preselection would be used to kick off the
|
||||
// RAG process, we will filter the data sources as well.
|
||||
//
|
||||
var preselectedSources = new List<IDataSource>(this.DataSourceOptions.PreselectedDataSourceIds.Count);
|
||||
foreach (var preselectedDataSourceId in this.DataSourceOptions.PreselectedDataSourceIds)
|
||||
{
|
||||
var dataSource = this.SettingsManager.ConfigurationData.DataSources.FirstOrDefault(ds => ds.Id == preselectedDataSourceId);
|
||||
if (dataSource is not null)
|
||||
preselectedSources.Add(dataSource);
|
||||
}
|
||||
|
||||
this.selectedDataSources = preselectedSources;
|
||||
this.selectedDataSources = this.GetDataSourcesFromConfiguredIds();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
@ -94,6 +87,7 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
this.aiBasedSourceSelection = this.DataSourceOptions.AutomaticDataSourceSelection;
|
||||
this.aiBasedValidation = this.DataSourceOptions.AutomaticValidation;
|
||||
this.areDataSourcesEnabled = !this.DataSourceOptions.DisableDataSources;
|
||||
this.selectedDataSources = this.GetDataSourcesFromConfiguredIds();
|
||||
}
|
||||
|
||||
switch (this.SelectionMode)
|
||||
@ -119,7 +113,7 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
// In configuration mode, we have to load all data sources:
|
||||
//
|
||||
case DataSourceSelectionMode.CONFIGURATION_MODE:
|
||||
this.availableDataSources = this.SettingsManager.ConfigurationData.DataSources;
|
||||
this.availableDataSources = this.GetConfiguredDataSourcesSnapshot();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -156,7 +150,7 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
this.aiBasedSourceSelection = this.DataSourceOptions.AutomaticDataSourceSelection;
|
||||
this.aiBasedValidation = this.DataSourceOptions.AutomaticValidation;
|
||||
this.areDataSourcesEnabled = !this.DataSourceOptions.DisableDataSources;
|
||||
this.selectedDataSources = this.SettingsManager.ConfigurationData.DataSources.Where(ds => this.DataSourceOptions.PreselectedDataSourceIds.Contains(ds.Id)).ToList();
|
||||
this.selectedDataSources = this.GetDataSourcesFromConfiguredIds();
|
||||
this.waitingForDataSources = false;
|
||||
|
||||
//
|
||||
@ -176,20 +170,38 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
this.showDataSourceSelection = false;
|
||||
this.StateHasChanged();
|
||||
}
|
||||
|
||||
private IReadOnlyList<IDataSource> GetConfiguredDataSourcesSnapshot() => this.SettingsManager.ConfigurationData.DataSources.ToList();
|
||||
|
||||
private IReadOnlyCollection<IDataSource> GetDataSourcesFromConfiguredIds()
|
||||
{
|
||||
var preselectedDataSourceIds = this.DataSourceOptions.PreselectedDataSourceIds.ToHashSet(StringComparer.Ordinal);
|
||||
return this.GetConfiguredDataSourcesSnapshot().Where(ds => preselectedDataSourceIds.Contains(ds.Id)).ToList();
|
||||
}
|
||||
|
||||
private async Task LoadAndApplyFilters()
|
||||
{
|
||||
if(this.DataSourceOptions.DisableDataSources)
|
||||
{
|
||||
this.loadAndApplyFiltersGeneration++;
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE)
|
||||
{
|
||||
this.loadAndApplyFiltersGeneration++;
|
||||
return;
|
||||
}
|
||||
|
||||
var generation = ++this.loadAndApplyFiltersGeneration;
|
||||
this.waitingForDataSources = true;
|
||||
this.StateHasChanged();
|
||||
|
||||
// Load the data sources:
|
||||
var sources = await this.DataSourceService.GetDataSources(this.LLMProvider, this.selectedDataSources);
|
||||
if (generation != this.loadAndApplyFiltersGeneration)
|
||||
return;
|
||||
|
||||
this.availableDataSources = sources.AllowedDataSources;
|
||||
this.selectedDataSources = sources.SelectedDataSources;
|
||||
this.waitingForDataSources = false;
|
||||
@ -230,9 +242,38 @@ public partial class DataSourceSelection : MSGComponentBase
|
||||
await this.OptionsChanged();
|
||||
}
|
||||
|
||||
private bool IsPreselectedDataSourcesDisabledLocked()
|
||||
{
|
||||
return this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE
|
||||
&& ManagedConfiguration.TryGet(x => x.Chat, x => x.PreselectedDataSourcesDisabled, out var meta)
|
||||
&& meta.IsLocked;
|
||||
}
|
||||
|
||||
private bool IsPreselectedDataSourcesAutomaticSelectionLocked()
|
||||
{
|
||||
return this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE
|
||||
&& ManagedConfiguration.TryGet(x => x.Chat, x => x.PreselectedDataSourcesAutomaticSelection, out var meta)
|
||||
&& meta.IsLocked;
|
||||
}
|
||||
|
||||
private bool IsPreselectedDataSourcesAutomaticValidationLocked()
|
||||
{
|
||||
return this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE
|
||||
&& ManagedConfiguration.TryGet(x => x.Chat, x => x.PreselectedDataSourcesAutomaticValidation, out var meta)
|
||||
&& meta.IsLocked;
|
||||
}
|
||||
|
||||
private bool IsPreselectedDataSourceIdsLocked()
|
||||
{
|
||||
return this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE
|
||||
&& ManagedConfiguration.TryGet(x => x.Chat, x => x.PreselectedDataSourceIds, out var meta)
|
||||
&& meta.IsLocked;
|
||||
}
|
||||
|
||||
private async Task OptionsChanged()
|
||||
{
|
||||
this.internalChange = true;
|
||||
this.loadAndApplyFiltersGeneration++;
|
||||
|
||||
await this.DataSourceOptionsChanged.InvokeAsync(this.DataSourceOptions);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
@inherits EnumSelectionBase
|
||||
|
||||
<MudStack Row="@true" Class="mb-3">
|
||||
<MudSelect T="@T" Value="@this.Value" ValueChanged="@this.SelectionChanged" AdornmentIcon="@this.Icon" Adornment="Adornment.Start" IconSize="@this.IconSize" Label="@this.Label" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateSelection">
|
||||
<MudSelect T="@T" Value="@this.Value" ValueChanged="@this.SelectionChanged" AdornmentIcon="@this.Icon" Adornment="Adornment.Start" IconSize="@this.IconSize" Label="@this.Label" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateSelection" Disabled="@this.Disabled">
|
||||
@foreach (var value in Enum.GetValues<T>())
|
||||
{
|
||||
<MudSelectItem Value="@value">
|
||||
@ -12,6 +12,6 @@
|
||||
</MudSelect>
|
||||
@if (this.AllowOther && this.Value.Equals(this.OtherValue))
|
||||
{
|
||||
<MudTextField T="string" Text="@this.OtherInput" TextChanged="this.OtherValueChanged" Validation="@this.ValidateOther" Label="@this.LabelOther" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Immediate="@true"/>
|
||||
<MudTextField T="string" Text="@this.OtherInput" TextChanged="this.OtherValueChanged" Validation="@this.ValidateOther" Label="@this.LabelOther" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Immediate="@true" Disabled="@this.Disabled"/>
|
||||
}
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
|
||||
@ -38,6 +38,12 @@ public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum
|
||||
|
||||
[Parameter]
|
||||
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the selection controls are disabled.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Size IconSize { get; set; } = Size.Medium;
|
||||
|
||||
@ -1,8 +1,23 @@
|
||||
@using AIStudio.Settings
|
||||
@inherits MSGComponentBase
|
||||
<MudSelect T="Provider" Value="@this.ProviderSettings" ValueChanged="@this.SelectionChanged" Validation="@this.ValidateProvider" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Apps" Margin="Margin.Dense" Label="@T("Provider")" Class="mb-3 rounded-lg" OuterClass="flex-grow-0" Variant="Variant.Outlined">
|
||||
@foreach (var provider in this.GetAvailableProviders())
|
||||
<MudSelect T="Provider" Value="@this.ProviderSettings" ValueChanged="@this.SelectionChanged" Validation="@this.ValidateProvider" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Apps" Margin="Margin.Dense" Label="@T("Provider")" Class="mb-3 rounded-lg" OuterClass="flex-grow-0" Variant="Variant.Outlined" Disabled="@this.Disabled">
|
||||
@foreach (var providerItem in this.GetAvailableProviderSelectionItems())
|
||||
{
|
||||
<MudSelectItem Value="@provider"/>
|
||||
<MudSelectItem Value="@providerItem.Provider">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="w-100" Wrap="Wrap.NoWrap">
|
||||
<MudText Class="me-2">@providerItem.Provider</MudText>
|
||||
@if (providerItem.CapabilityIcons.Count > 0)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1" Wrap="Wrap.NoWrap" Class="flex-grow-0">
|
||||
@foreach (var capabilityIcon in providerItem.CapabilityIcons)
|
||||
{
|
||||
<MudTooltip Text="@capabilityIcon.Tooltip">
|
||||
<MudIcon Icon="@capabilityIcon.Icon" Size="Size.Small" Color="Color.Default" />
|
||||
</MudTooltip>
|
||||
}
|
||||
</MudStack>
|
||||
}
|
||||
</MudStack>
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@ -20,6 +21,12 @@ public partial class ProviderSelection : MSGComponentBase
|
||||
[Parameter]
|
||||
public Func<AIStudio.Settings.Provider, string?> ValidateProvider { get; set; } = _ => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether provider selection is disabled.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public ConfidenceLevel ExplicitMinimumConfidence { get; set; } = ConfidenceLevel.UNKNOWN;
|
||||
|
||||
@ -41,6 +48,40 @@ public partial class ProviderSelection : MSGComponentBase
|
||||
this.ProviderSettings = provider;
|
||||
await this.ProviderSettingsChanged.InvokeAsync(provider);
|
||||
}
|
||||
|
||||
private IEnumerable<ProviderSelectionItem> GetAvailableProviderSelectionItems()
|
||||
{
|
||||
foreach (var provider in this.GetAvailableProviders())
|
||||
yield return new(provider, this.GetCapabilityIcons(provider));
|
||||
}
|
||||
|
||||
private IReadOnlyList<CapabilityIcon> GetCapabilityIcons(AIStudio.Settings.Provider provider)
|
||||
{
|
||||
var capabilities = provider.GetModelCapabilities();
|
||||
List<CapabilityIcon> capabilityIcons = [];
|
||||
|
||||
if (capabilities.Contains(Capability.AUDIO_INPUT))
|
||||
capabilityIcons.Add(new(Icons.Material.Filled.GraphicEq, this.T("Audio input possible")));
|
||||
|
||||
if (capabilities.Contains(Capability.SINGLE_IMAGE_INPUT) || capabilities.Contains(Capability.MULTIPLE_IMAGE_INPUT))
|
||||
capabilityIcons.Add(new(Icons.Material.Filled.Image, this.T("Image input possible")));
|
||||
|
||||
if (capabilities.Contains(Capability.SPEECH_INPUT))
|
||||
capabilityIcons.Add(new(Icons.Material.Filled.Mic, this.T("Speech input possible")));
|
||||
|
||||
var reasoningIndicatorState = provider.GetReasoningIndicatorState();
|
||||
if (reasoningIndicatorState is not ReasoningIndicatorState.NONE)
|
||||
capabilityIcons.Add(new(Icons.Material.Filled.Psychology, this.GetReasoningTooltip(reasoningIndicatorState)));
|
||||
|
||||
return capabilityIcons;
|
||||
}
|
||||
|
||||
private string GetReasoningTooltip(ReasoningIndicatorState reasoningIndicatorState) => reasoningIndicatorState switch
|
||||
{
|
||||
ReasoningIndicatorState.DEFAULT_ON => this.T("Uses reasoning (thinking) by default"),
|
||||
ReasoningIndicatorState.CONFIGURED => this.T("Uses reasoning (thinking) configured by settings"),
|
||||
_ => this.T("Uses reasoning (thinking)"),
|
||||
};
|
||||
|
||||
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
|
||||
private IEnumerable<AIStudio.Settings.Provider> GetAvailableProviders()
|
||||
@ -84,4 +125,8 @@ public partial class ProviderSelection : MSGComponentBase
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly record struct CapabilityIcon(string Icon, string Tooltip);
|
||||
|
||||
private readonly record struct ProviderSelectionItem(AIStudio.Settings.Provider Provider, IReadOnlyList<CapabilityIcon> CapabilityIcons);
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
@using AIStudio.Settings
|
||||
@inherits SettingsPanelBase
|
||||
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.SelectAll" HeaderText="@T("Agent: Data Source Selection Options")">
|
||||
@ -5,7 +6,7 @@
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
||||
@T("Use Case: this agent is used to select the appropriate data sources for 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="@T("When enabled, you can preselect some agent options. This is might be useful when you prefer an LLM.")"/>
|
||||
<ConfigurationProviderSelection Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider = selectedValue)"/>
|
||||
<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="@T("When enabled, you can preselect some agent options. This is 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"/>
|
||||
</MudPaper>
|
||||
</ExpansionPanel>
|
||||
@ -1,16 +1,17 @@
|
||||
@using AIStudio.Settings
|
||||
@inherits SettingsPanelBase
|
||||
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Assessment" HeaderText="@T("Agent: Retrieval Context Validation Options")">
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
||||
@T("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.")
|
||||
</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.")"/>
|
||||
<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"/>
|
||||
@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="@T("When enabled, you can preselect some agent options. This is might be useful when you prefer an LLM.")"/>
|
||||
<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="@T("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.")"/>
|
||||
<ConfigurationProviderSelection Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider = selectedValue)"/>
|
||||
<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="@T("When enabled, you can preselect some agent options. This is 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="@T("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"/>
|
||||
</MudPaper>
|
||||
}
|
||||
</ExpansionPanel>
|
||||
@ -72,6 +72,7 @@ public partial class SettingsPanelProviders : SettingsPanelProviderBase
|
||||
{ x => x.DataHost, provider.Host },
|
||||
{ x => x.HFInferenceProviderId, provider.HFInferenceProvider },
|
||||
{ x => x.AdditionalJsonApiParameters, provider.AdditionalJsonApiParameters },
|
||||
{ x => x.DataCapabilityOverrides, provider.CapabilityOverrides },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<ProviderDialog>(T("Edit LLM Provider"), dialogParameters, DialogOptions.FULLSCREEN);
|
||||
|
||||
@ -12,9 +12,18 @@
|
||||
else
|
||||
{
|
||||
<MudStack Spacing="2">
|
||||
<MudAlert Severity="Severity.Info" Dense="true">
|
||||
@T("This security check uses a sample prompt preview. Empty or placeholder values in the preview are expected.")
|
||||
</MudAlert>
|
||||
@if (this.securityState.IsEnterpriseApproved)
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Dense="true">
|
||||
@T("This assistant plugin is approved by your organization. A manual security audit is not required.")
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Dense="true">
|
||||
@T("This security check uses a sample prompt preview. Empty or placeholder values in the preview are expected.")
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudPaper Class="pa-3 border-dashed border rounded-lg">
|
||||
<MudText Typo="Typo.h6">@this.plugin.Name</MudText>
|
||||
@ -298,9 +307,12 @@
|
||||
<MudButton OnClick="@this.CloseWithoutActivation" Variant="Variant.Filled">
|
||||
@(this.audit is null ? T("Cancel") : T("Close"))
|
||||
</MudButton>
|
||||
<MudButton OnClick="@this.RunAudit" Variant="Variant.Filled" Color="Color.Primary" Disabled="@(!this.CanRunAudit || this.justAudited)">
|
||||
@T("Start Security Check")
|
||||
</MudButton>
|
||||
@if (!this.securityState.IsEnterpriseApproved)
|
||||
{
|
||||
<MudButton OnClick="@this.RunAudit" Variant="Variant.Filled" Color="Color.Primary" Disabled="@(!this.CanRunAudit || this.justAudited)">
|
||||
@T("Start Security Check")
|
||||
</MudButton>
|
||||
}
|
||||
@if (this.CanEnablePlugin)
|
||||
{
|
||||
<MudButton OnClick="@this.EnablePlugin" Variant="Variant.Filled" Color="@this.EnableButtonColor">
|
||||
|
||||
@ -37,6 +37,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
private IReadOnlyCollection<TreeItemData<ITreeItem>> fileSystemTreeItems = [];
|
||||
private CultureInfo currentCultureInfo = CultureInfo.InvariantCulture;
|
||||
private bool isAuditing;
|
||||
private PluginAssistantSecurityState securityState = new();
|
||||
|
||||
private AIStudio.Settings.Provider CurrentProvider => this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_ASSISTANT_PLUGIN_AUDIT, null, true);
|
||||
|
||||
@ -50,7 +51,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
|
||||
private string MinimumLevelLabel => this.MinimumLevel.GetName();
|
||||
|
||||
private bool CanRunAudit => this.plugin is not null && this.CurrentProvider != AIStudio.Settings.Provider.NONE && !this.isAuditing;
|
||||
private bool CanRunAudit => this.plugin is not null && this.CurrentProvider != AIStudio.Settings.Provider.NONE && !this.isAuditing && !this.securityState.IsEnterpriseApproved;
|
||||
|
||||
private bool IsAuditBelowMinimum => this.audit is not null && this.audit.Level < this.MinimumLevel;
|
||||
|
||||
@ -74,6 +75,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
.FirstOrDefault(x => x.Id == this.PluginId);
|
||||
if (this.plugin is not null)
|
||||
{
|
||||
this.securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, this.plugin);
|
||||
this.promptPreview = await this.plugin.BuildAuditPromptPreviewAsync();
|
||||
this.promptFallbackPreview = this.plugin.BuildAuditPromptFallbackPreview();
|
||||
this.plugin.CreateAuditComponentSummary();
|
||||
@ -96,6 +98,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
try
|
||||
{
|
||||
this.audit = await this.AssistantPluginAuditService.RunAuditAsync(this.plugin);
|
||||
this.securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, this.plugin);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@ -105,7 +105,9 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudSelect @bind-Value="@this.DataModel"
|
||||
<MudSelect T="Provider.Model"
|
||||
Value="@this.DataModel"
|
||||
ValueChanged="@(async model => await this.OnModelChanged(model))"
|
||||
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural" AdornmentColor="Color.Info"
|
||||
Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingModel">
|
||||
@foreach (var model in this.availableModels)
|
||||
@ -157,8 +159,67 @@
|
||||
</MudButton>
|
||||
<MudDivider />
|
||||
<MudCollapse Expanded="@this.showExpertSettings" Class="@this.GetExpertStyles">
|
||||
<MudJustifiedText Class="mb-5">
|
||||
@T("Please be aware: This section is for experts only. You are responsible for verifying the correctness of the additional parameters you provide to the API call. By default, AI Studio uses the OpenAI-compatible chat completions API, when that it is supported by the underlying service and model.")
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
@T("Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available.")
|
||||
</MudAlert>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">
|
||||
@T("Override Model Capabilities")
|
||||
</MudText>
|
||||
<MudJustifiedText Typo="Typo.body2" Class="mb-4">
|
||||
@T("Stored default model capabilities may not reflect its full range. Override them here if needed.")
|
||||
</MudJustifiedText>
|
||||
<MudStack Class="mb-4" Spacing="2">
|
||||
@foreach (var capability in SWITCH_CAPABILITY_OVERRIDES)
|
||||
{
|
||||
<MudPaper Outlined="@true" Class="pa-3">
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Wrap="Wrap.Wrap">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Typo="Typo.body2">
|
||||
@this.GetCapabilityOverrideLabel(capability)
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@this.GetCapabilityEffectiveLabel(capability)
|
||||
</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudSwitch T="bool"
|
||||
Value="@this.IsCapabilityEnabled(capability)"
|
||||
ValueChanged="@(value => this.OnCapabilitySwitchChanged(capability, value))"
|
||||
Color="Color.Primary" />
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Default"
|
||||
Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.RestartAlt"
|
||||
Disabled="@(!this.HasCapabilityOverride(capability))"
|
||||
OnClick="@(() => this.ResetCapabilityOverride(capability))">
|
||||
@T("Reset")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
<MudPaper Outlined="@true" Class="pa-3">
|
||||
<MudSelect T="ReasoningOverrideMode"
|
||||
Value="@this.GetReasoningOverrideMode()"
|
||||
ValueChanged="@this.SetReasoningOverrideMode"
|
||||
Label="@T("Reasoning (thinking) behavior")"
|
||||
HelperText="@this.GetReasoningOverrideModeDescription(this.GetReasoningOverrideMode())"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
OpenIcon="@Icons.Material.Filled.Psychology"
|
||||
AdornmentColor="Color.Info"
|
||||
Adornment="Adornment.Start">
|
||||
@foreach (var mode in REASONING_OVERRIDE_MODES)
|
||||
{
|
||||
<MudSelectItem Value="@mode">
|
||||
@this.GetReasoningOverrideModeLabel(mode)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
<MudJustifiedText Typo="Typo.body2" Class="mb-4">
|
||||
@string.Format(T("The current model uses the {0}."), this.GetCurrentModelApiLabel())
|
||||
</MudJustifiedText>
|
||||
<MudTextField T="string" Label=@T("Additional API parameters") Variant="Variant.Outlined" Lines="4" AutoGrow="true" MaxLines="10" HelperText=@T("""Add the parameters in proper JSON formatting, e.g., "temperature": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.""") Placeholder="@GetPlaceholderExpertSettings" @bind-Value="@this.AdditionalJsonApiParameters" Immediate="true" Validation="@this.ValidateAdditionalJsonApiParameters" OnBlur="@this.OnInputChangeExpertSettings"/>
|
||||
</MudCollapse>
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Text.Json;
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Provider.HuggingFace;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.Services;
|
||||
using AIStudio.Tools.Validation;
|
||||
|
||||
@ -18,6 +19,15 @@ namespace AIStudio.Dialogs;
|
||||
/// </summary>
|
||||
public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
{
|
||||
private enum ReasoningOverrideMode
|
||||
{
|
||||
AUTOMATIC,
|
||||
NO_REASONING,
|
||||
CAN_BE_ENABLED,
|
||||
ON_BY_DEFAULT,
|
||||
ALWAYS_ON
|
||||
}
|
||||
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
@ -83,6 +93,9 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
|
||||
[Parameter]
|
||||
public string AdditionalJsonApiParameters { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public ProviderCapabilityOverrides? DataCapabilityOverrides { get; set; }
|
||||
|
||||
[Inject]
|
||||
private RustService RustService { get; init; } = null!;
|
||||
@ -91,6 +104,22 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
private ILogger<ProviderDialog> Logger { get; init; } = null!;
|
||||
|
||||
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
|
||||
private static readonly IReadOnlyList<Capability> SWITCH_CAPABILITY_OVERRIDES =
|
||||
[
|
||||
Capability.AUDIO_INPUT,
|
||||
Capability.MULTIPLE_IMAGE_INPUT,
|
||||
Capability.SPEECH_INPUT,
|
||||
Capability.VIDEO_INPUT
|
||||
];
|
||||
|
||||
private static readonly IReadOnlyList<ReasoningOverrideMode> REASONING_OVERRIDE_MODES =
|
||||
[
|
||||
ReasoningOverrideMode.AUTOMATIC,
|
||||
ReasoningOverrideMode.NO_REASONING,
|
||||
ReasoningOverrideMode.CAN_BE_ENABLED,
|
||||
ReasoningOverrideMode.ON_BY_DEFAULT,
|
||||
ReasoningOverrideMode.ALWAYS_ON
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// The list of used instance names. We need this to check for uniqueness.
|
||||
@ -106,6 +135,7 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
private string dataLoadingModelsIssue = string.Empty;
|
||||
private bool usesLegacySystemModelFallback;
|
||||
private bool showExpertSettings;
|
||||
private ProviderCapabilityOverrides capabilityOverrides = new();
|
||||
|
||||
// We get the form reference from Blazor code to validate it manually:
|
||||
private MudForm form = null!;
|
||||
@ -160,6 +190,7 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
Host = this.DataHost,
|
||||
HFInferenceProvider = this.HFInferenceProviderId,
|
||||
AdditionalJsonApiParameters = this.AdditionalJsonApiParameters,
|
||||
CapabilityOverrides = this.capabilityOverrides.HasOverrides ? this.capabilityOverrides : null,
|
||||
};
|
||||
}
|
||||
|
||||
@ -178,7 +209,8 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
this.UsedInstanceNames = this.SettingsManager.ConfigurationData.Providers.Select(x => x.InstanceName.ToLowerInvariant()).ToList();
|
||||
#pragma warning restore MWAIS0001
|
||||
|
||||
this.showExpertSettings = !string.IsNullOrWhiteSpace(this.AdditionalJsonApiParameters);
|
||||
this.capabilityOverrides = this.DataCapabilityOverrides ?? new();
|
||||
this.showExpertSettings = !string.IsNullOrWhiteSpace(this.AdditionalJsonApiParameters) || this.capabilityOverrides.HasOverrides;
|
||||
|
||||
// When editing, we need to load the data:
|
||||
if(this.IsEditing)
|
||||
@ -300,10 +332,18 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
this.DataHost = selectedHost;
|
||||
this.DataModel = default;
|
||||
this.dataManuallyModel = string.Empty;
|
||||
this.capabilityOverrides = new();
|
||||
this.availableModels.Clear();
|
||||
this.dataLoadingModelsIssue = string.Empty;
|
||||
this.usesLegacySystemModelFallback = false;
|
||||
}
|
||||
|
||||
private Task OnModelChanged(Model selectedModel)
|
||||
{
|
||||
this.DataModel = selectedModel;
|
||||
this.capabilityOverrides = new();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task ReloadModels()
|
||||
{
|
||||
@ -369,6 +409,156 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
|
||||
private void ToggleExpertSettings() => this.showExpertSettings = !this.showExpertSettings;
|
||||
|
||||
private void SetCapabilityOverride(Capability capability, bool value)
|
||||
{
|
||||
this.capabilityOverrides = this.capabilityOverrides.SetOverride(capability, value);
|
||||
}
|
||||
|
||||
private Task OnCapabilitySwitchChanged(Capability capability, bool value)
|
||||
{
|
||||
this.SetCapabilityOverride(capability, value);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void ResetCapabilityOverride(Capability capability) =>
|
||||
this.capabilityOverrides = this.capabilityOverrides.SetOverride(capability, null);
|
||||
|
||||
private ReasoningOverrideMode GetReasoningOverrideMode()
|
||||
{
|
||||
var alwaysReasoning = this.capabilityOverrides.GetOverride(Capability.ALWAYS_REASONING);
|
||||
var optionalReasoning = this.capabilityOverrides.GetOverride(Capability.OPTIONAL_REASONING);
|
||||
var reasoningByDefault = this.capabilityOverrides.GetOverride(Capability.REASONING_BY_DEFAULT);
|
||||
if (alwaysReasoning is null && optionalReasoning is null && reasoningByDefault is null)
|
||||
return ReasoningOverrideMode.AUTOMATIC;
|
||||
|
||||
var capabilities = this.GetCurrentModelCapabilities();
|
||||
if (capabilities.Contains(Capability.ALWAYS_REASONING))
|
||||
return ReasoningOverrideMode.ALWAYS_ON;
|
||||
|
||||
if (capabilities.Contains(Capability.REASONING_BY_DEFAULT))
|
||||
return ReasoningOverrideMode.ON_BY_DEFAULT;
|
||||
|
||||
if (capabilities.Contains(Capability.OPTIONAL_REASONING))
|
||||
return ReasoningOverrideMode.CAN_BE_ENABLED;
|
||||
|
||||
return ReasoningOverrideMode.NO_REASONING;
|
||||
}
|
||||
|
||||
private ReasoningOverrideMode GetAutomaticReasoningOverrideMode()
|
||||
{
|
||||
var capabilities = this.GetAutomaticModelCapabilities();
|
||||
if (capabilities.Contains(Capability.ALWAYS_REASONING))
|
||||
return ReasoningOverrideMode.ALWAYS_ON;
|
||||
|
||||
if (capabilities.Contains(Capability.REASONING_BY_DEFAULT))
|
||||
return ReasoningOverrideMode.ON_BY_DEFAULT;
|
||||
|
||||
if (capabilities.Contains(Capability.OPTIONAL_REASONING))
|
||||
return ReasoningOverrideMode.CAN_BE_ENABLED;
|
||||
|
||||
return ReasoningOverrideMode.NO_REASONING;
|
||||
}
|
||||
|
||||
private void SetReasoningOverrideMode(ReasoningOverrideMode mode)
|
||||
{
|
||||
this.capabilityOverrides = mode switch
|
||||
{
|
||||
ReasoningOverrideMode.AUTOMATIC => this.capabilityOverrides
|
||||
.SetOverride(Capability.ALWAYS_REASONING, null)
|
||||
.SetOverride(Capability.OPTIONAL_REASONING, null)
|
||||
.SetOverride(Capability.REASONING_BY_DEFAULT, null),
|
||||
|
||||
ReasoningOverrideMode.NO_REASONING => this.capabilityOverrides
|
||||
.SetOverride(Capability.ALWAYS_REASONING, false)
|
||||
.SetOverride(Capability.OPTIONAL_REASONING, false)
|
||||
.SetOverride(Capability.REASONING_BY_DEFAULT, false),
|
||||
|
||||
ReasoningOverrideMode.CAN_BE_ENABLED => this.capabilityOverrides
|
||||
.SetOverride(Capability.ALWAYS_REASONING, false)
|
||||
.SetOverride(Capability.OPTIONAL_REASONING, true)
|
||||
.SetOverride(Capability.REASONING_BY_DEFAULT, false),
|
||||
|
||||
ReasoningOverrideMode.ON_BY_DEFAULT => this.capabilityOverrides
|
||||
.SetOverride(Capability.ALWAYS_REASONING, false)
|
||||
.SetOverride(Capability.OPTIONAL_REASONING, true)
|
||||
.SetOverride(Capability.REASONING_BY_DEFAULT, true),
|
||||
|
||||
ReasoningOverrideMode.ALWAYS_ON => this.capabilityOverrides
|
||||
.SetOverride(Capability.ALWAYS_REASONING, true)
|
||||
.SetOverride(Capability.OPTIONAL_REASONING, false)
|
||||
.SetOverride(Capability.REASONING_BY_DEFAULT, false),
|
||||
|
||||
_ => this.capabilityOverrides
|
||||
};
|
||||
}
|
||||
|
||||
private string GetReasoningOverrideModeLabel(ReasoningOverrideMode mode) => mode switch
|
||||
{
|
||||
ReasoningOverrideMode.AUTOMATIC => T("Automatic"),
|
||||
ReasoningOverrideMode.NO_REASONING => T("No reasoning (thinking)"),
|
||||
ReasoningOverrideMode.CAN_BE_ENABLED => T("Can be enabled"),
|
||||
ReasoningOverrideMode.ON_BY_DEFAULT => T("On by default"),
|
||||
ReasoningOverrideMode.ALWAYS_ON => T("Always on"),
|
||||
_ => mode.ToString()
|
||||
};
|
||||
|
||||
private string GetReasoningOverrideModeDescription(ReasoningOverrideMode mode) => mode switch
|
||||
{
|
||||
ReasoningOverrideMode.AUTOMATIC => string.Format(T("Use detected model behavior: {0}."), this.GetReasoningOverrideModeLabel(this.GetAutomaticReasoningOverrideMode())),
|
||||
ReasoningOverrideMode.NO_REASONING => T("No reasoning (thinking) capability."),
|
||||
ReasoningOverrideMode.CAN_BE_ENABLED => T("Reasoning (thinking) is available, but off unless additional API parameters enable it."),
|
||||
ReasoningOverrideMode.ON_BY_DEFAULT => T("Reasoning (thinking) is available and on unless additional API parameters disable it."),
|
||||
ReasoningOverrideMode.ALWAYS_ON => T("The model always uses reasoning (thinking); it cannot be disabled."),
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
private bool HasCapabilityOverride(Capability capability) => this.capabilityOverrides.GetOverride(capability) is not null;
|
||||
|
||||
private bool IsCapabilityEnabled(Capability capability)
|
||||
{
|
||||
var capabilities = this.GetCurrentModelCapabilities();
|
||||
return capabilities.Contains(capability);
|
||||
}
|
||||
|
||||
private string GetCapabilityEffectiveLabel(Capability capability)
|
||||
{
|
||||
var isEnabled = this.IsCapabilityEnabled(capability);
|
||||
if (this.HasCapabilityOverride(capability))
|
||||
return isEnabled ? T("Enabled") : T("Disabled");
|
||||
|
||||
return isEnabled ? T("Enabled (Auto)") : T("Disabled (Auto)");
|
||||
}
|
||||
|
||||
private List<Capability> GetCurrentModelCapabilities()
|
||||
{
|
||||
var currentProviderSettings = this.CreateProviderSettings();
|
||||
return currentProviderSettings.GetModelCapabilities();
|
||||
}
|
||||
|
||||
private List<Capability> GetAutomaticModelCapabilities() => this.DataLLMProvider.GetModelCapabilities(this.DataModel);
|
||||
|
||||
private string GetCurrentModelApiLabel()
|
||||
{
|
||||
var capabilities = this.GetCurrentModelCapabilities();
|
||||
if (capabilities.Contains(Capability.RESPONSES_API))
|
||||
return "Responses API";
|
||||
|
||||
if (capabilities.Contains(Capability.CHAT_COMPLETION_API))
|
||||
return "Chat Completions API";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
private string GetCapabilityOverrideLabel(Capability capability) => capability switch
|
||||
{
|
||||
Capability.AUDIO_INPUT => T("Audio input"),
|
||||
Capability.MULTIPLE_IMAGE_INPUT => T("Multiple image input"),
|
||||
Capability.SPEECH_INPUT => T("Speech input"),
|
||||
Capability.VIDEO_INPUT => T("Video input"),
|
||||
Capability.ALWAYS_REASONING => T("Always reasoning"),
|
||||
_ => capability.ToString()
|
||||
};
|
||||
|
||||
private void OnInputChangeExpertSettings()
|
||||
{
|
||||
this.AdditionalJsonApiParameters = NormalizeAdditionalJsonApiParameters(this.AdditionalJsonApiParameters)
|
||||
@ -536,7 +726,7 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
}
|
||||
|
||||
private string GetExpertStyles => this.showExpertSettings ? "border-2 border-dashed rounded pa-2" : string.Empty;
|
||||
|
||||
|
||||
private static string GetPlaceholderExpertSettings =>
|
||||
"""
|
||||
"temperature": 0.5,
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
@if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager))
|
||||
{
|
||||
<DataSourceSelection SelectionMode="DataSourceSelectionMode.CONFIGURATION_MODE" AutoSaveAppSettings="@true" @bind-DataSourceOptions="@this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions" ConfigurationHeaderMessage="@T("You can set default data sources and options for new chats. You can change these settings later for each individual chat.")"/>
|
||||
<ConfigurationSelect OptionDescription="@T("Apply default data source option when sending assistant results to chat")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.Chat.SendToChatDataSourceBehavior)" Data="@ConfigurationSelectDataFactory.GetSendToChatDataSourceBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.Chat.SendToChatDataSourceBehavior = selectedValue)" OptionHelp="@T("Do you want to apply the default data source options when sending assistant results to chat?")"/>
|
||||
<ConfigurationSelect OptionDescription="@T("Apply default data source option when sending assistant results to chat")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.Chat.SendToChatDataSourceBehavior)" Data="@ConfigurationSelectDataFactory.GetSendToChatDataSourceBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.Chat.SendToChatDataSourceBehavior = selectedValue)" OptionHelp="@T("Do you want to apply the default data source options when sending assistant results to chat?")" IsLocked="() => ManagedConfiguration.TryGet(x => x.Chat, x => x.SendToChatDataSourceBehavior, out var meta) && meta.IsLocked"/>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
||||
@ -2,6 +2,7 @@ using AIStudio.Dialogs;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.AIJobs;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Rust;
|
||||
using AIStudio.Tools.Services;
|
||||
@ -30,6 +31,9 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
|
||||
[Inject]
|
||||
private AIJobService AIJobService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private AssistantSessionService AssistantSessionService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private ISnackbar Snackbar { get; init; } = null!;
|
||||
@ -102,7 +106,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
Event.UPDATE_AVAILABLE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR,
|
||||
Event.SHOW_WARNING, Event.SHOW_SUCCESS, Event.STARTUP_PLUGIN_SYSTEM, Event.PLUGINS_RELOADED,
|
||||
Event.INSTALL_UPDATE, Event.STARTUP_COMPLETED, Event.AI_JOB_CHANGED, Event.AI_JOB_FINISHED,
|
||||
Event.CHAT_GENERATION_CHANGED,
|
||||
Event.CHAT_GENERATION_CHANGED, Event.ASSISTANT_SESSION_CHANGED, Event.ASSISTANT_SESSION_FINISHED,
|
||||
]);
|
||||
|
||||
// Set the snackbar for the update service:
|
||||
@ -228,6 +232,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
case Event.AI_JOB_CHANGED:
|
||||
case Event.AI_JOB_FINISHED:
|
||||
case Event.CHAT_GENERATION_CHANGED:
|
||||
case Event.ASSISTANT_SESSION_CHANGED:
|
||||
case Event.ASSISTANT_SESSION_FINISHED:
|
||||
this.LoadNavItems();
|
||||
this.StateHasChanged();
|
||||
break;
|
||||
@ -341,18 +347,26 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
private IEnumerable<NavBarItem> GetNavItems()
|
||||
{
|
||||
var palette = this.ColorTheme.GetCurrentPalette(this.SettingsManager);
|
||||
var activityIndicatorLightColor = this.ColorTheme.GetActivityIndicatorLightColor();
|
||||
var activityIndicatorDarkColor = this.ColorTheme.GetActivityIndicatorDarkColor();
|
||||
var defaultLightColor = palette.DarkLighten;
|
||||
var defaultDarkColor = palette.GrayLight;
|
||||
var chatLightColor = this.AIJobService.HasActiveJobs ? activityIndicatorLightColor : defaultLightColor;
|
||||
var chatDarkColor = this.AIJobService.HasActiveJobs ? activityIndicatorDarkColor : defaultDarkColor;
|
||||
var assistantsLightColor = this.AssistantSessionService.HasActiveSessions ? activityIndicatorLightColor : defaultLightColor;
|
||||
var assistantsDarkColor = this.AssistantSessionService.HasActiveSessions ? activityIndicatorDarkColor : defaultDarkColor;
|
||||
|
||||
yield return new(T("Home"), Icons.Material.Filled.Home, palette.DarkLighten, palette.GrayLight, Routes.HOME, true);
|
||||
yield return new(T("Chat"), this.AIJobService.HasActiveJobs ? Icons.Material.Filled.Chat : Icons.Material.Outlined.Chat, palette.DarkLighten, palette.GrayLight, Routes.CHAT, false);
|
||||
yield return new(T("Assistants"), Icons.Material.Filled.Apps, palette.DarkLighten, palette.GrayLight, Routes.ASSISTANTS, false);
|
||||
yield return new(T("Home"), Icons.Material.Filled.Home, defaultLightColor, defaultDarkColor, Routes.HOME, true);
|
||||
yield return new(T("Chat"), Icons.Material.Filled.Chat, chatLightColor, chatDarkColor, Routes.CHAT, false);
|
||||
yield return new(T("Assistants"), Icons.Material.Filled.Apps, assistantsLightColor, assistantsDarkColor, Routes.ASSISTANTS, false);
|
||||
|
||||
if (PreviewFeatures.PRE_WRITER_MODE_2024.IsEnabled(this.SettingsManager))
|
||||
yield return new(T("Writer"), Icons.Material.Filled.Create, palette.DarkLighten, palette.GrayLight, Routes.WRITER, false);
|
||||
yield return new(T("Writer"), Icons.Material.Filled.Create, defaultLightColor, defaultDarkColor, Routes.WRITER, false);
|
||||
|
||||
yield return new(T("Plugins"), Icons.Material.TwoTone.Extension, palette.DarkLighten, palette.GrayLight, Routes.PLUGINS, false);
|
||||
yield return new(T("Plugins"), Icons.Material.TwoTone.Extension, defaultLightColor, defaultDarkColor, Routes.PLUGINS, false);
|
||||
yield return new(T("Supporters"), Icons.Material.Filled.Favorite, palette.Error.Value, "#801a00", Routes.SUPPORTERS, false);
|
||||
yield return new(T("Information"), Icons.Material.Filled.Info, palette.DarkLighten, palette.GrayLight, Routes.ABOUT, false);
|
||||
yield return new(T("Settings"), Icons.Material.Filled.Settings, palette.DarkLighten, palette.GrayLight, Routes.SETTINGS, false);
|
||||
yield return new(T("Information"), Icons.Material.Filled.Info, defaultLightColor, defaultDarkColor, Routes.ABOUT, false);
|
||||
yield return new(T("Settings"), Icons.Material.Filled.Settings, defaultLightColor, defaultDarkColor, Routes.SETTINGS, false);
|
||||
}
|
||||
|
||||
private async Task ShowUpdateDialog()
|
||||
|
||||
@ -4,5 +4,10 @@ namespace AIStudio.Layout;
|
||||
|
||||
public record NavBarItem(string Name, string Icon, string IconLightColor, string IconDarkColor, string Path, bool MatchAll)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the CSS style that applies the current theme-aware icon color.
|
||||
/// </summary>
|
||||
/// <param name="settingsManager">The settings manager used to read the current theme.</param>
|
||||
/// <returns>The CSS style for the nav item icon color.</returns>
|
||||
public string SetColorStyle(SettingsManager settingsManager) => $"--custom-icon-color: {(settingsManager.IsDarkMode ? this.IconDarkColor : this.IconLightColor)};";
|
||||
}
|
||||
@ -44,12 +44,15 @@
|
||||
@foreach (var assistantPlugin in this.AssistantPlugins)
|
||||
{
|
||||
var securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, assistantPlugin);
|
||||
var launchLink = assistantPlugin.StartsChatDirectly ? string.Empty : $"{Routes.ASSISTANT_DYNAMIC}?assistantId={assistantPlugin.Id}";
|
||||
<AssistantBlock TSettings="NoSettingsPanel"
|
||||
Name="@T(assistantPlugin.AssistantTitle)"
|
||||
Description="@T(assistantPlugin.Description)"
|
||||
Icon="@Icons.Material.Filled.FindInPage"
|
||||
Disabled="@(!securityState.CanStartAssistant)"
|
||||
Link="@($"{Routes.ASSISTANT_DYNAMIC}?assistantId={assistantPlugin.Id}")">
|
||||
AssistantSessionInstanceId="@assistantPlugin.Id.ToString()"
|
||||
Link="@launchLink"
|
||||
OnClick="@(() => this.StartAssistantPluginAsync(assistantPlugin))">
|
||||
<SecurityBadge>
|
||||
<AssistantPluginSecurityCard Plugin="@assistantPlugin" Compact="@true" />
|
||||
</SecurityBadge>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Agents.AssistantAudit;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
@ -12,6 +13,12 @@ public partial class Assistants : MSGComponentBase
|
||||
|
||||
[Inject]
|
||||
private AssistantPluginAuditService AssistantPluginAuditService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavigationManager { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private ILogger<Assistants> Logger { get; init; } = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@ -81,6 +88,50 @@ public partial class Assistants : MSGComponentBase
|
||||
audits.Add(audit);
|
||||
}
|
||||
|
||||
private async Task StartAssistantPluginAsync(PluginAssistants assistantPlugin)
|
||||
{
|
||||
var securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, assistantPlugin);
|
||||
if (!securityState.CanStartAssistant)
|
||||
return;
|
||||
|
||||
if (!assistantPlugin.StartsChatDirectly)
|
||||
{
|
||||
this.NavigationManager.NavigateTo($"{Routes.ASSISTANT_DYNAMIC}?assistantId={assistantPlugin.Id}");
|
||||
return;
|
||||
}
|
||||
|
||||
var chatThread = await this.TryCreateDirectChatThreadAsync(assistantPlugin);
|
||||
if (chatThread is null)
|
||||
return;
|
||||
|
||||
MessageBus.INSTANCE.DeferMessage(this, Event.SEND_TO_CHAT, chatThread);
|
||||
this.NavigationManager.NavigateTo(Routes.CHAT);
|
||||
}
|
||||
|
||||
private async Task<ChatThread?> TryCreateDirectChatThreadAsync(PluginAssistants assistantPlugin)
|
||||
{
|
||||
var workspaceId = await WorkspaceBehaviour.ResolveOrCreateWorkspaceIdByNameAsync(assistantPlugin.LaunchWorkspaceName);
|
||||
if (workspaceId == Guid.Empty)
|
||||
{
|
||||
this.Logger.LogWarning("Assistant plugin '{PluginName}' could not resolve or create workspace '{WorkspaceName}'.", assistantPlugin.Name, assistantPlugin.LaunchWorkspaceName);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ChatThread
|
||||
{
|
||||
IncludeDateTime = true,
|
||||
SelectedProvider = string.Empty,
|
||||
SelectedProfile = string.Empty,
|
||||
SelectedChatTemplate = string.Empty,
|
||||
SystemPrompt = SystemPrompts.DEFAULT,
|
||||
WorkspaceId = workspaceId,
|
||||
ChatId = Guid.NewGuid(),
|
||||
Name = assistantPlugin.AssistantTitle,
|
||||
DataSourceOptions = this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy(),
|
||||
Blocks = [],
|
||||
};
|
||||
}
|
||||
|
||||
protected override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
||||
{
|
||||
if (triggeredEvent is Event.PLUGINS_RELOADED)
|
||||
|
||||
@ -81,6 +81,9 @@ Each assistant plugin lives in its own directory under the assistants plugin roo
|
||||
|
||||
## Structure
|
||||
- `ASSISTANT` is the root table. It must contain `Title`, `Description`, `SystemPrompt`, `SubmitText`, `AllowProfiles`, and the nested `UI` definition.
|
||||
- `ASSISTANT` may optionally define direct-launch metadata for assistant tiles:
|
||||
- `LaunchBehavior = "OPEN_WORKSPACE_CHAT_BY_NAME"`
|
||||
- `WorkspaceName = "<target workspace name>"`
|
||||
- `UI.Type` is always `"FORM"` and `UI.Children` is a list of component tables.
|
||||
- Each component table declares `Type`, an optional `Children` array, and a `Props` table that feeds the component’s parameters.
|
||||
|
||||
@ -92,6 +95,8 @@ ASSISTANT = {
|
||||
["SystemPrompt"] = "",
|
||||
["SubmitText"] = "",
|
||||
["AllowProfiles"] = true,
|
||||
["LaunchBehavior"] = "OPEN_WORKSPACE_CHAT_BY_NAME",
|
||||
["WorkspaceName"] = "",
|
||||
["UI"] = {
|
||||
["Type"] = "FORM",
|
||||
["Children"] = {
|
||||
@ -101,6 +106,29 @@ ASSISTANT = {
|
||||
}
|
||||
```
|
||||
|
||||
## Direct Launch to Workspace Chat
|
||||
Assistant plugins can optionally skip the normal assistant page and open a chat directly from the tile.
|
||||
|
||||
```lua
|
||||
ASSISTANT = {
|
||||
["Title"] = "Open Chat",
|
||||
["Description"] = "Open a new chat in the XXX workspace.",
|
||||
["SystemPrompt"] = "",
|
||||
["SubmitText"] = "Start",
|
||||
["AllowProfiles"] = true,
|
||||
["LaunchBehavior"] = "OPEN_WORKSPACE_CHAT_BY_NAME",
|
||||
["WorkspaceName"] = "XXX",
|
||||
["UI"] = {
|
||||
["Type"] = "FORM",
|
||||
["Children"] = {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `WorkspaceName` is resolved case-insensitively after trimming.
|
||||
- If the workspace does not exist yet, AI Studio creates it automatically.
|
||||
- The opened chat uses the normal default chat settings of AI Studio.
|
||||
|
||||
|
||||
#### Supported types (matching the Blazor UI components):
|
||||
|
||||
|
||||
@ -62,6 +62,8 @@ ASSISTANT = {
|
||||
["SystemPrompt"] = "<prompt that fundamentally changes behaviour, personality and task focus of your assistant. Invisible to the user>", -- required
|
||||
["SubmitText"] = "<label for submit button>", -- required
|
||||
["AllowProfiles"] = true, -- if true, allows AiStudios profiles; required
|
||||
["LaunchBehavior"] = "<NONE|OPEN_WORKSPACE_CHAT_BY_NAME>", -- optional; when set to OPEN_WORKSPACE_CHAT_BY_NAME the tile opens a chat directly
|
||||
["WorkspaceName"] = "<name of the workspace to open or create>", -- optional; required for OPEN_WORKSPACE_CHAT_BY_NAME
|
||||
["UI"] = {
|
||||
["Type"] = "FORM",
|
||||
["Children"] = {
|
||||
|
||||
@ -70,9 +70,22 @@ CONFIG["LLM_PROVIDERS"] = {}
|
||||
-- -- Please refer to the documentation of the selected host for details.
|
||||
-- -- Might be something like ... \"temperature\": 0.5 ... for one parameter.
|
||||
-- -- Could be something like ... \"temperature\": 0.5, \"max_tokens\": 1000 ... for multiple parameters.
|
||||
-- -- Recognized reasoning parameters, such as reasoning_effort, thinking, think, and chat_template_kwargs.enable_thinking, may affect whether AI Studio shows the reasoning icon for this provider.
|
||||
-- -- Please do not add the enclosing curly braces {} here. Also, no trailing comma is allowed.
|
||||
-- ["AdditionalJsonApiParameters"] = "",
|
||||
--
|
||||
-- -- Optional: expert capability overrides.
|
||||
-- -- Allowed keys are exactly:
|
||||
-- -- AUDIO_INPUT, MULTIPLE_IMAGE_INPUT, SPEECH_INPUT, VIDEO_INPUT,
|
||||
-- -- OPTIONAL_REASONING, ALWAYS_REASONING, REASONING_BY_DEFAULT
|
||||
-- -- Allowed values are booleans only.
|
||||
-- -- For default-on reasoning (rhinking), set OPTIONAL_REASONING and REASONING_BY_DEFAULT to true.
|
||||
-- -- ALWAYS_REASONING means the model cannot disable reasoning (thinking).
|
||||
-- -- Missing keys keep the automatic capability detection result.
|
||||
-- -- ["CapabilityOverrides"] = {
|
||||
-- -- ["VIDEO_INPUT"] = false,
|
||||
-- -- },
|
||||
--
|
||||
-- -- Optional: Hugging Face inference provider. Only relevant for UsedLLMProvider = HUGGINGFACE.
|
||||
-- -- Allowed values are: CEREBRAS, NEBIUS_AI_STUDIO, SAMBANOVA, NOVITA, HYPERBOLIC, TOGETHER_AI, FIREWORKS, HF_INFERENCE_API
|
||||
-- -- ["HFInferenceProvider"] = "NOVITA",
|
||||
@ -257,12 +270,38 @@ CONFIG["SETTINGS"] = {}
|
||||
-- Please note: using an empty string ("") or "00000000-0000-0000-0000-000000000000" means chats will use no chat template.
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedChatTemplate"] = "00000000-0000-0000-0000-000000000000"
|
||||
--
|
||||
--
|
||||
-- Configure default data source options for new chats.
|
||||
--
|
||||
-- Controls whether data sources are off by default:
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourcesDisabled"] = false
|
||||
|
||||
-- Controls whether AI Studio asks an agent to choose data sources:
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourcesAutomaticSelection"] = true
|
||||
|
||||
-- Controls whether retrieved data is validated by an agent:
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourcesAutomaticValidation"] = true
|
||||
|
||||
-- Must contain IDs from CONFIG["DATA_SOURCES"] or user-configured data sources.
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourceIds"] = {
|
||||
-- "00000000-0000-0000-0000-000000000000",
|
||||
-- }
|
||||
--
|
||||
-- Configure whether default chat data source options are applied when assistant results are sent to chat.
|
||||
-- Allowed values are: NO_DATA_SOURCES, APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS
|
||||
-- CONFIG["SETTINGS"]["DataChat.SendToChatDataSourceBehavior"] = "APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS"
|
||||
--
|
||||
-- Allow users to change any configured chat default locally.
|
||||
-- Allowed values are: true, false
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectOptions.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedProvider.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedProfile.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedChatTemplate.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourcesDisabled.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourcesAutomaticSelection.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourcesAutomaticValidation.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.PreselectedDataSourceIds.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataChat.SendToChatDataSourceBehavior.AllowUserOverride"] = true
|
||||
|
||||
-- Configure the transcription provider for voice-to-text functionality.
|
||||
-- It must be one of the transcription provider IDs defined in CONFIG["TRANSCRIPTION_PROVIDERS"].
|
||||
@ -280,6 +319,23 @@ CONFIG["SETTINGS"] = {}
|
||||
-- DOCUMENT_ANALYSIS_ASSISTANT, SLIDE_BUILDER_ASSISTANT, I18N_ASSISTANT
|
||||
-- CONFIG["SETTINGS"]["DataApp.HiddenAssistants"] = { "ERI_ASSISTANT", "I18N_ASSISTANT" }
|
||||
|
||||
-- Configure enterprise approvals for assistant plugins.
|
||||
-- Each approval is matched only by the current SHA-256 hash over all Lua files
|
||||
-- in the assistant plugin folder, in canonical sorted order.
|
||||
-- When the hash matches, the assistant plugin is treated as SAFE immediately and
|
||||
-- no user-run security audit is required.
|
||||
-- You can generate the exact hash with the build-script command:
|
||||
-- dotnet run --project app/Build -- assistant-plugin-hash "<plugin-dir>" --lua-snippet
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.EnterpriseApprovedPlugins"] = {
|
||||
-- {
|
||||
-- ["PluginHash"] = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
|
||||
-- ["DisplayName"] = "Name of Plugin",
|
||||
-- ["Comment"] = "Optional comment",
|
||||
-- ["ApprovedBy"] = "Optional Approver",
|
||||
-- ["ApprovedAtUtc"] = "2026-07-02T09:30:00Z",
|
||||
-- }
|
||||
-- }
|
||||
|
||||
-- Configure a global shortcut for starting and stopping dictation.
|
||||
--
|
||||
-- The format follows the Rust and Tauri conventions. Especially,
|
||||
@ -373,6 +429,53 @@ CONFIG["SETTINGS"] = {}
|
||||
-- "00000000-0000-0000-0000-000000000001",
|
||||
-- }
|
||||
|
||||
-- Configure the data source selection agent.
|
||||
-- This agent is used when chat data source options enable AI-based data source selection.
|
||||
-- The provider must be one of the provider IDs defined in CONFIG["LLM_PROVIDERS"].
|
||||
-- CONFIG["SETTINGS"]["DataAgentDataSourceSelection.PreselectAgentOptions"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentDataSourceSelection.PreselectedAgentProvider"] = "00000000-0000-0000-0000-000000000000"
|
||||
-- CONFIG["SETTINGS"]["DataAgentDataSourceSelection.PreselectAgentOptions.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentDataSourceSelection.PreselectedAgentProvider.AllowUserOverride"] = true
|
||||
|
||||
-- Configure the retrieval context validation agent.
|
||||
-- This agent is used when retrieval context validation is enabled globally and chat data source options enable AI-based validation.
|
||||
-- The provider must be one of the provider IDs defined in CONFIG["LLM_PROVIDERS"].
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.EnableRetrievalContextValidation"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.PreselectAgentOptions"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.PreselectedAgentProvider"] = "00000000-0000-0000-0000-000000000000"
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.NumParallelValidations"] = 3
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.EnableRetrievalContextValidation.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.PreselectAgentOptions.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.PreselectedAgentProvider.AllowUserOverride"] = true
|
||||
-- CONFIG["SETTINGS"]["DataAgentRetrievalContextValidation.NumParallelValidations.AllowUserOverride"] = true
|
||||
|
||||
-- Configure assistant plugin security audits.
|
||||
--
|
||||
-- Configure whether assistant plugins must be audited before users can activate them.
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.RequireAuditBeforeActivation"] = true
|
||||
--
|
||||
-- Configure a dedicated provider for assistant plugin audits.
|
||||
-- It must be one of the provider IDs defined in CONFIG["LLM_PROVIDERS"].
|
||||
-- Without a selected audit provider, AI Studio uses the app-wide default provider.
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.PreselectedAgentProvider"] = "00000000-0000-0000-0000-000000000000"
|
||||
--
|
||||
-- Configure the minimum audit level assistant plugins must meet.
|
||||
-- Allowed values are: UNKNOWN, DANGEROUS, CAUTION, SAFE
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.MinimumLevel"] = "CAUTION"
|
||||
--
|
||||
-- Configure whether activation is blocked when the audit result is below the minimum level.
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.BlockActivationBelowMinimum"] = true
|
||||
--
|
||||
-- Configure whether new or changed assistant plugins are audited automatically in the background.
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.AutomaticallyAuditAssistants"] = false
|
||||
--
|
||||
-- Configure whether users can change assistant plugin audit settings locally.
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.RequireAuditBeforeActivation.AllowUserOverride"] = false
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.PreselectedAgentProvider.AllowUserOverride"] = false
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.MinimumLevel.AllowUserOverride"] = false
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.BlockActivationBelowMinimum.AllowUserOverride"] = false
|
||||
-- CONFIG["SETTINGS"]["DataAssistantPluginAudit.AutomaticallyAuditAssistants.AllowUserOverride"] = false
|
||||
|
||||
-- Example chat templates for this configuration:
|
||||
CONFIG["CHAT_TEMPLATES"] = {}
|
||||
|
||||
|
||||
@ -312,6 +312,12 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T180921696"] = "Zurückset
|
||||
-- Please select a provider.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T1809312323"] = "Bitte wählen Sie einen Anbieter aus."
|
||||
|
||||
-- The assistant failed. The message is: '{0}'
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T1833836281"] = "Der Assistent ist fehlgeschlagen. Die Meldung lautet: „{0}“"
|
||||
|
||||
-- This assistant is already running. AI Studio opens the running session instead.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T2575715765"] = "Dieser Assistent läuft bereits. AI Studio öffnet stattdessen die laufende Sitzung."
|
||||
|
||||
-- Assistant - {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T3043922"] = "Assistent – {0}"
|
||||
|
||||
@ -1056,6 +1062,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1565111217"] = "Relev
|
||||
-- Please select an ERI specification version for the ERI server.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1612890554"] = "Bitte wählen Sie eine Version der ERI-Spezifikation für den ERI-Server aus."
|
||||
|
||||
-- Open in chat
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1664804142"] = "Im Chat öffnen"
|
||||
|
||||
-- Ports below 1024 are reserved for system services. Your ERI server need to run with elevated permissions (root user).
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T168780641"] = "Ports unterhalb von 1024 sind für Systemdienste reserviert. Ihr ERI-Server muss mit erhöhten Rechten (als Root-Benutzer) ausgeführt werden."
|
||||
|
||||
@ -2289,9 +2298,24 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::IIMAGESOURCEEXTENSIONS::T349928509"] = "Das Bil
|
||||
-- Open Settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T1172211894"] = "Einstellungen öffnen"
|
||||
|
||||
-- Assistant is still running.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T2719896610"] = "Assistent läuft noch."
|
||||
|
||||
-- Assistant was canceled. Open it to review the result.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T3390934621"] = "Assistent wurde abgebrochen. Öffnen Sie ihn, um das Ergebnis zu überprüfen."
|
||||
|
||||
-- Assistant failed. Open it to review the result.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T3571008422"] = "Assistent fehlgeschlagen. Öffnen Sie ihn, um das Ergebnis zu überprüfen."
|
||||
|
||||
-- The result is ready.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T661906146"] = "Das Ergebnis ist fertig."
|
||||
|
||||
-- Show or hide the detailed security information.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1045105126"] = "Detaillierte Sicherheitsinformationen anzeigen oder ausblenden."
|
||||
|
||||
-- This plugin is approved by your organization. A manual security audit is not required.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1213338416"] = "Dieses Plugin ist von Ihrer Organisation freigegeben. Eine manuelle Sicherheitsprüfung ist nicht erforderlich."
|
||||
|
||||
-- Assistant Audit
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1506922856"] = "Assistentenprüfung"
|
||||
|
||||
@ -2307,6 +2331,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1805629238"
|
||||
-- Assistant Security
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1841954939"] = "Sicherheit des Assistenten"
|
||||
|
||||
-- Company approved
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2036497459"] = "Organisationsfreigabe"
|
||||
|
||||
-- Approved name
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2282386733"] = "Genehmigter Name"
|
||||
|
||||
-- Required minimum
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2354026284"] = "Erforderliches Minimum"
|
||||
|
||||
@ -2316,6 +2346,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2757790517"
|
||||
-- Technical Details
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2769062110"] = "Technische Details"
|
||||
|
||||
-- Approval comment
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2906887599"] = "Genehmigungskommentar"
|
||||
|
||||
-- No audit yet
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3138877447"] = "Noch keine Prüfung vorhanden"
|
||||
|
||||
@ -2331,21 +2364,39 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3448155331"
|
||||
-- No stored audit details are available yet.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3647137899"] = "Es sind noch keine gespeicherten Audit-Details verfügbar."
|
||||
|
||||
-- Enterprise approval is active
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3816183955"] = "Organisationsfreigabe ist aktiv"
|
||||
|
||||
-- Current hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3896860082"] = "Aktueller Hash"
|
||||
|
||||
-- No user audit required
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3916957031"] = "Keine Benutzerprüfung erforderlich"
|
||||
|
||||
-- Audited at
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4103354206"] = "Geprüft am"
|
||||
|
||||
-- Approved hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4170340306"] = "Genehmigter Hash"
|
||||
|
||||
-- No security findings were stored for this assistant plugin.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4256679240"] = "Für dieses Assistenten-Plugin wurden keine Sicherheitsbefunde gespeichert."
|
||||
|
||||
-- Status source
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4289123040"] = "Quellstatus"
|
||||
|
||||
-- Audit hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T53507304"] = "Prüf-Hash"
|
||||
|
||||
-- {0} Finding(s)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T631393016"] = "{0} Fund(e)"
|
||||
|
||||
-- Approved by
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T894543751"] = "Genehmigt von"
|
||||
|
||||
-- Approved at
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T978873131"] = "Genehmigt am"
|
||||
|
||||
-- Click the paperclip to attach files, or click the number to see your attached files.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1358313858"] = "Klicken Sie auf die Büroklammer, um Dateien anzuhängen, oder klicken Sie auf die Zahl, um Ihre angehängten Dateien anzuzeigen."
|
||||
|
||||
@ -2721,6 +2772,24 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T3654011106"] = "Profil
|
||||
-- You can switch between your profiles here
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "Hier können Sie zwischen ihren Profilen wechseln."
|
||||
|
||||
-- Audio input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T1742581112"] = "Audioeingabe möglich"
|
||||
|
||||
-- Uses reasoning (thinking)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T2196970948"] = "Nutzt Schlussfolgerungen (Denken)"
|
||||
|
||||
-- Image input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T2685487365"] = "Bildeingabe möglich"
|
||||
|
||||
-- Speech input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T3005724142"] = "Spracheingabe möglich"
|
||||
|
||||
-- Uses reasoning (thinking) by default
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T3891860124"] = "Nutzt standardmäßig Schlussfolgerungen (Denken)"
|
||||
|
||||
-- Uses reasoning (thinking) configured by settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T4279448758"] = "Nutzt Schlussfolgerungen (Denken) gemäß den Einstellungen"
|
||||
|
||||
-- Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Anbieter"
|
||||
|
||||
@ -3747,6 +3816,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3652671056"] =
|
||||
-- Unavailable
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3662391977"] = "Nicht verfügbar"
|
||||
|
||||
-- This assistant plugin is approved by your organization. A manual security audit is not required.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3680374624"] = "Dieses Assistenten-Plugin ist von Ihrer Organisation freigegeben. Eine manuelle Sicherheitsprüfung ist nicht erforderlich."
|
||||
|
||||
-- Plugin Structure
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T371537943"] = "Plugin-Struktur"
|
||||
|
||||
@ -4668,9 +4740,6 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROMPTINGGUIDELINEDIALOG::T384594633"] = "De
|
||||
-- Prompting Guideline
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROMPTINGGUIDELINEDIALOG::T4250996615"] = "Prompting-Leitfaden"
|
||||
|
||||
-- Please be aware: This section is for experts only. You are responsible for verifying the correctness of the additional parameters you provide to the API call. By default, AI Studio uses the OpenAI-compatible chat completions API, when that it is supported by the underlying service and model.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1017509792"] = "Bitte beachten Sie: Dieser Bereich ist nur für Expertinnen und Experten. Sie sind dafür verantwortlich, die Korrektheit der zusätzlichen Parameter zu überprüfen, die Sie beim API‑Aufruf angeben. Standardmäßig verwendet AI Studio die OpenAI‑kompatible Chat Completions-API, sofern diese vom zugrunde liegenden Dienst und Modell unterstützt wird."
|
||||
|
||||
-- Hugging Face Inference Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1085481431"] = "Hugging Face Inferenz-Anbieter"
|
||||
|
||||
@ -4689,30 +4758,57 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1356621346"] = "Konto erste
|
||||
-- Load models
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T15352225"] = "Modelle laden"
|
||||
|
||||
-- Automatic
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1634363268"] = "Automatisch"
|
||||
|
||||
-- Disabled (Auto)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1671157437"] = "Deaktiviert (automatisch)"
|
||||
|
||||
-- Add the parameters in proper JSON formatting, e.g., "temperature": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1689135032"] = "Fügen Sie die Parameter in korrekter JSON-Formatierung hinzu, z. B. \"temperature\": 0.5. Entfernen Sie abschließende Kommas. Die üblichen äußeren geschweiften Klammern {} dürfen dabei jedoch nicht verwendet werden."
|
||||
|
||||
-- Hostname
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1727440780"] = "Hostname"
|
||||
|
||||
-- Always on
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1761671861"] = "Immer an"
|
||||
|
||||
-- Reset
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T180921696"] = "Zurücksetzen"
|
||||
|
||||
-- Update
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1847791252"] = "Aktualisieren"
|
||||
|
||||
-- Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1870831108"] = "Der API-Schlüssel konnte nicht vom Betriebssystem geladen werden. Die Meldung war: {0}. Sie können diese Meldung ignorieren und den API-Schlüssel erneut eingeben."
|
||||
|
||||
-- Speech input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1874348907"] = "Spracheingabe"
|
||||
|
||||
-- Please enter a model name.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1936099896"] = "Bitte geben Sie einen Modellnamen ein."
|
||||
|
||||
-- Enabled (Auto)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2001330464"] = "Aktiviert (automatisch)"
|
||||
|
||||
-- The current model uses the {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2029870721"] = "Das aktuelle Modell nutzt die {0}."
|
||||
|
||||
-- Additional API parameters must form a JSON object.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2051143391"] = "Zusätzliche API-Parameter müssen ein JSON-Objekt bilden."
|
||||
|
||||
-- Use detected model behavior: {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2141072961"] = "Erkanntes Modellverhalten verwenden: {0}"
|
||||
|
||||
-- Model
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2189814010"] = "Modell"
|
||||
|
||||
-- (Optional) API Key
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2331453405"] = "(Optional) API-Schlüssel"
|
||||
|
||||
-- Enabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2626085950"] = "Aktiviert"
|
||||
|
||||
-- Add
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2646845972"] = "Hinzufügen"
|
||||
|
||||
@ -4725,12 +4821,42 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2810182573"] = "Keine Model
|
||||
-- Instance Name
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2842060373"] = "Instanzname"
|
||||
|
||||
-- On by default
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2843289040"] = "Standardmäßig aktiviert"
|
||||
|
||||
-- No reasoning (thinking) capability.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T301695429"] = "Keine Fähigkeit für Schlussfolgerungen (Denken)."
|
||||
|
||||
-- Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3079061205"] = "Achtung: Fehlerhafte Experteneinstellungen können die Modellnutzung beeinträchtigen, unterstützte Funktionen deaktivieren oder nicht unterstützte Funktionen als verfügbar erscheinen lassen."
|
||||
|
||||
-- Reasoning (thinking) is available and on unless additional API parameters disable it.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T310420667"] = "Schlussfolgerungen (Denken) sind verfügbar und aktiviert, sofern es nicht durch zusätzliche API-Parameter deaktiviert wird."
|
||||
|
||||
-- Disabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3217987877"] = "Deaktiviert"
|
||||
|
||||
-- The model always uses reasoning (thinking); it cannot be disabled.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3294757333"] = "Das Modell verwendet immer Schlussfolgerungen (Denken); es kann nicht deaktiviert werden."
|
||||
|
||||
-- Can be enabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3299454847"] = "Kann aktiviert werden"
|
||||
|
||||
-- Show Expert Settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3361153305"] = "Experten-Einstellungen anzeigen"
|
||||
|
||||
-- Audio input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3404621481"] = "Audioeingabe"
|
||||
|
||||
-- Invalid JSON: Add the parameters in proper JSON formatting, e.g., \"temperature\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3502745319"] = "Ungültiges JSON: Fügen Sie die Parameter in korrektem JSON-Format hinzu, z. B. \"temperature\": 0.5. Entfernen Sie abschließende Kommas. Die üblichen umgebenden geschweiften Klammern {} dürfen jedoch nicht verwendet werden."
|
||||
|
||||
-- Reasoning (thinking) behavior
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3546126752"] = "Verhalten bezüglich Schlussfolgerungen (Denken)"
|
||||
|
||||
-- Reasoning (thinking) is available, but off unless additional API parameters enable it.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3548835672"] = "Schlussfolgerungen (Denken) sind verfügbar, aber ausgeschaltet, sofern sie nicht durch zusätzliche API-Parameter aktiviert werden."
|
||||
|
||||
-- Show available models
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3763891899"] = "Verfügbare Modelle anzeigen"
|
||||
|
||||
@ -4740,18 +4866,36 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3783329915"] = "Dieser Host
|
||||
-- Duplicate key '{0}' found.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3804472591"] = "Doppelter Schlüssel '{0}' gefunden."
|
||||
|
||||
-- Override Model Capabilities
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3904244586"] = "Modellfähigkeiten überschreiben"
|
||||
|
||||
-- Currently, we cannot query the models for the selected provider and/or host. Therefore, please enter the model name manually.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4116737656"] = "Derzeit können wir die Modelle für den ausgewählten Anbieter und/oder Host nicht abfragen. Bitte geben Sie daher den Modellnamen manuell ein."
|
||||
|
||||
-- Model selection
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T416738168"] = "Modellauswahl"
|
||||
|
||||
-- Stored default model capabilities may not reflect its full range. Override them here if needed.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4217532151"] = "Die gespeicherten Standardfähigkeiten des Modells entsprechen möglicherweise nicht dessen vollständigem Funktionsumfang. Überschreiben Sie sie hier bei Bedarf."
|
||||
|
||||
-- Video input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4289835208"] = "Videoeingabe"
|
||||
|
||||
-- We are currently unable to communicate with the provider to load models. Please try again later.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T504465522"] = "Wir können derzeit nicht mit dem Anbieter kommunizieren, um Modelle zu laden. Bitte versuchen Sie es später erneut."
|
||||
|
||||
-- Always reasoning
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T641757736"] = "Immer schlussfolgernd (Denken)"
|
||||
|
||||
-- Host
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T808120719"] = "Host"
|
||||
|
||||
-- Multiple image input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T858529900"] = "Bildeingabe"
|
||||
|
||||
-- No reasoning (thinking)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T87434533"] = "Keine Schlussfolgerungen (Denken)"
|
||||
|
||||
-- Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T900237532"] = "Anbieter"
|
||||
|
||||
@ -7887,6 +8031,12 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANT
|
||||
-- Button
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANTCOMPONENTTYPEEXTENSIONS::T864557713"] = "Schaltfläche"
|
||||
|
||||
-- The ASSISTANT table contains an invalid LaunchBehavior value.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T109828905"] = "Die Tabelle ASSISTANT enthält einen ungültigen Wert für LaunchBehavior."
|
||||
|
||||
-- The ASSISTANT table contains an unsupported LaunchBehavior value.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1194373781"] = "Die ASSISTANT-Tabelle enthält einen nicht unterstützten LaunchBehavior-Wert."
|
||||
|
||||
-- Failed to parse the UI render tree from the ASSISTANT lua table.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1318499252"] = "Der UI-Render-Baum konnte nicht aus der ASSISTANT-Lua-Tabelle geparst werden."
|
||||
|
||||
@ -7902,12 +8052,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T2
|
||||
-- The ASSISTANT lua table does not exist or is not a valid table.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3017816936"] = "Die Lua-Tabelle **ASSISTANT** existiert nicht oder ist keine gültige Tabelle."
|
||||
|
||||
-- The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3233001282"] = "Die ASSISTANT-Tabelle enthält einen leeren Arbeitsbereichsnamen für das LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'."
|
||||
|
||||
-- The provided ASSISTANT lua table does not contain a valid system prompt.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3402798667"] = "Die bereitgestellte ASSISTANT-Lua-Tabelle enthält keine gültige Systemaufforderung."
|
||||
|
||||
-- The ASSISTANT table does not contain a valid system prompt.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3723171842"] = "Die Tabelle **ASSISTANT** enthält keine gültige Systemanweisung."
|
||||
|
||||
-- The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T4215554842"] = "Die ASSISTANT-Tabelle enthält das LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME', aber keinen gültigen WorkspaceNamen."
|
||||
|
||||
-- ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T683382975"] = "`ASSISTANT.BuildPrompt` ist vorhanden, aber keine Lua-Funktion oder hat eine ungültige Syntax."
|
||||
|
||||
@ -7950,6 +8106,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2774333862"] = "Das aktuelle Prüfergebnis ist „{0}“, was unter Ihrem erforderlichen Mindestniveau „{1}“ liegt. Die Prüfungsdurchsetzung ist derzeit deaktiviert, daher kann dieses Assistenten-Plugin trotzdem aktiviert oder verwendet werden."
|
||||
|
||||
-- The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2824524534"] = "Der aktuelle Plugin-Hash entspricht einer organisationsverwalteten Freigabe. Für die Aktivierung oder Nutzung ist keine manuelle Sicherheitsprüfung erforderlich."
|
||||
|
||||
-- Not Audited
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2828154864"] = "Nicht geprüft"
|
||||
|
||||
@ -7959,12 +8118,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- Open Security Check
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T290241209"] = "Sicherheitsprüfung öffnen"
|
||||
|
||||
-- User Audit
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3293963409"] = "Benutzerprüfung"
|
||||
|
||||
-- Restricted
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3325062668"] = "Eingeschränkt"
|
||||
|
||||
-- Unknown
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3424652889"] = "Unbekannt"
|
||||
|
||||
-- Approved by your organization
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3508214481"] = "Von Ihrer Organisation genehmigt"
|
||||
|
||||
-- Unlocked
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3606159420"] = "Entsperrt"
|
||||
|
||||
@ -7980,9 +8145,24 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3899951594"] = "Es gibt noch kein Sicherheitsaudit. Ihre aktuellen Sicherheitseinstellungen verlangen kein Audit, bevor dieses Assistenten-Plugin verwendet werden darf."
|
||||
|
||||
-- No Approval
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T515592229"] = "Keine Freigabe"
|
||||
|
||||
-- This assistant was approved by your organization.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T538196816"] = "Dieser Assistent wurde von Ihrer Organisation freigegeben."
|
||||
|
||||
-- Safe
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T760494712"] = "Sicher"
|
||||
|
||||
-- Open Security Details
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T803119455"] = "Sicherheitsdetails öffnen"
|
||||
|
||||
-- Start Security Check
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T811648299"] = "Sicherheitsprüfung starten"
|
||||
|
||||
-- This assistant was approved by your organization as '{0}'.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T834246718"] = "Dieser Assistent wurde von Ihrer Organisation als '{0}' freigegeben."
|
||||
|
||||
-- This assistant currently has no stored audit.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T921972844"] = "Für diesen Assistenten ist derzeit kein gespeichertes Audit vorhanden."
|
||||
|
||||
|
||||
@ -312,6 +312,12 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T180921696"] = "Reset"
|
||||
-- Please select a provider.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T1809312323"] = "Please select a provider."
|
||||
|
||||
-- The assistant failed. The message is: '{0}'
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T1833836281"] = "The assistant failed. The message is: '{0}'"
|
||||
|
||||
-- This assistant is already running. AI Studio opens the running session instead.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T2575715765"] = "This assistant is already running. AI Studio opens the running session instead."
|
||||
|
||||
-- Assistant - {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ASSISTANTBASE::T3043922"] = "Assistant - {0}"
|
||||
|
||||
@ -1056,6 +1062,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1565111217"] = "Relat
|
||||
-- Please select an ERI specification version for the ERI server.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1612890554"] = "Please select an ERI specification version for the ERI server."
|
||||
|
||||
-- Open in chat
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T1664804142"] = "Open in chat"
|
||||
|
||||
-- Ports below 1024 are reserved for system services. Your ERI server need to run with elevated permissions (root user).
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::ERI::ASSISTANTERI::T168780641"] = "Ports below 1024 are reserved for system services. Your ERI server need to run with elevated permissions (root user)."
|
||||
|
||||
@ -2289,9 +2298,24 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::IIMAGESOURCEEXTENSIONS::T349928509"] = "The ima
|
||||
-- Open Settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T1172211894"] = "Open Settings"
|
||||
|
||||
-- Assistant is still running.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T2719896610"] = "Assistant is still running."
|
||||
|
||||
-- Assistant was canceled. Open it to review the result.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T3390934621"] = "Assistant was canceled. Open it to review the result."
|
||||
|
||||
-- Assistant failed. Open it to review the result.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T3571008422"] = "Assistant failed. Open it to review the result."
|
||||
|
||||
-- The result is ready.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T661906146"] = "The result is ready."
|
||||
|
||||
-- Show or hide the detailed security information.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1045105126"] = "Show or hide the detailed security information."
|
||||
|
||||
-- This plugin is approved by your organization. A manual security audit is not required.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1213338416"] = "This plugin is approved by your organization. A manual security audit is not required."
|
||||
|
||||
-- Assistant Audit
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1506922856"] = "Assistant Audit"
|
||||
|
||||
@ -2307,6 +2331,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1805629238"
|
||||
-- Assistant Security
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1841954939"] = "Assistant Security"
|
||||
|
||||
-- Company approved
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2036497459"] = "Company approved"
|
||||
|
||||
-- Approved name
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2282386733"] = "Approved name"
|
||||
|
||||
-- Required minimum
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2354026284"] = "Required minimum"
|
||||
|
||||
@ -2316,6 +2346,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2757790517"
|
||||
-- Technical Details
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2769062110"] = "Technical Details"
|
||||
|
||||
-- Approval comment
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2906887599"] = "Approval comment"
|
||||
|
||||
-- No audit yet
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3138877447"] = "No audit yet"
|
||||
|
||||
@ -2331,21 +2364,39 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3448155331"
|
||||
-- No stored audit details are available yet.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3647137899"] = "No stored audit details are available yet."
|
||||
|
||||
-- Enterprise approval is active
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3816183955"] = "Enterprise approval is active"
|
||||
|
||||
-- Current hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3896860082"] = "Current hash"
|
||||
|
||||
-- No user audit required
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3916957031"] = "No user audit required"
|
||||
|
||||
-- Audited at
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4103354206"] = "Audited at"
|
||||
|
||||
-- Approved hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4170340306"] = "Approved hash"
|
||||
|
||||
-- No security findings were stored for this assistant plugin.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4256679240"] = "No security findings were stored for this assistant plugin."
|
||||
|
||||
-- Status source
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4289123040"] = "Status source"
|
||||
|
||||
-- Audit hash
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T53507304"] = "Audit hash"
|
||||
|
||||
-- {0} Finding(s)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T631393016"] = "{0} Finding(s)"
|
||||
|
||||
-- Approved by
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T894543751"] = "Approved by"
|
||||
|
||||
-- Approved at
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T978873131"] = "Approved at"
|
||||
|
||||
-- Click the paperclip to attach files, or click the number to see your attached files.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1358313858"] = "Click the paperclip to attach files, or click the number to see your attached files."
|
||||
|
||||
@ -2721,6 +2772,24 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T3654011106"] = "Open P
|
||||
-- You can switch between your profiles here
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "You can switch between your profiles here"
|
||||
|
||||
-- Audio input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T1742581112"] = "Audio input possible"
|
||||
|
||||
-- Uses reasoning (thinking)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T2196970948"] = "Uses reasoning (thinking)"
|
||||
|
||||
-- Image input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T2685487365"] = "Image input possible"
|
||||
|
||||
-- Speech input possible
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T3005724142"] = "Speech input possible"
|
||||
|
||||
-- Uses reasoning (thinking) by default
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T3891860124"] = "Uses reasoning (thinking) by default"
|
||||
|
||||
-- Uses reasoning (thinking) configured by settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T4279448758"] = "Uses reasoning (thinking) configured by settings"
|
||||
|
||||
-- Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider"
|
||||
|
||||
@ -3747,6 +3816,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3652671056"] =
|
||||
-- Unavailable
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3662391977"] = "Unavailable"
|
||||
|
||||
-- This assistant plugin is approved by your organization. A manual security audit is not required.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3680374624"] = "This assistant plugin is approved by your organization. A manual security audit is not required."
|
||||
|
||||
-- Plugin Structure
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T371537943"] = "Plugin Structure"
|
||||
|
||||
@ -4668,9 +4740,6 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROMPTINGGUIDELINEDIALOG::T384594633"] = "Th
|
||||
-- Prompting Guideline
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROMPTINGGUIDELINEDIALOG::T4250996615"] = "Prompting Guideline"
|
||||
|
||||
-- Please be aware: This section is for experts only. You are responsible for verifying the correctness of the additional parameters you provide to the API call. By default, AI Studio uses the OpenAI-compatible chat completions API, when that it is supported by the underlying service and model.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1017509792"] = "Please be aware: This section is for experts only. You are responsible for verifying the correctness of the additional parameters you provide to the API call. By default, AI Studio uses the OpenAI-compatible chat completions API, when that it is supported by the underlying service and model."
|
||||
|
||||
-- Hugging Face Inference Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1085481431"] = "Hugging Face Inference Provider"
|
||||
|
||||
@ -4689,30 +4758,57 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1356621346"] = "Create acco
|
||||
-- Load models
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T15352225"] = "Load models"
|
||||
|
||||
-- Automatic
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1634363268"] = "Automatic"
|
||||
|
||||
-- Disabled (Auto)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1671157437"] = "Disabled (Auto)"
|
||||
|
||||
-- Add the parameters in proper JSON formatting, e.g., "temperature": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1689135032"] = "Add the parameters in proper JSON formatting, e.g., \"temperature\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though."
|
||||
|
||||
-- Hostname
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1727440780"] = "Hostname"
|
||||
|
||||
-- Always on
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1761671861"] = "Always on"
|
||||
|
||||
-- Reset
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T180921696"] = "Reset"
|
||||
|
||||
-- Update
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1847791252"] = "Update"
|
||||
|
||||
-- Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1870831108"] = "Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again."
|
||||
|
||||
-- Speech input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1874348907"] = "Speech input"
|
||||
|
||||
-- Please enter a model name.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1936099896"] = "Please enter a model name."
|
||||
|
||||
-- Enabled (Auto)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2001330464"] = "Enabled (Auto)"
|
||||
|
||||
-- The current model uses the {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2029870721"] = "The current model uses the {0}."
|
||||
|
||||
-- Additional API parameters must form a JSON object.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2051143391"] = "Additional API parameters must form a JSON object."
|
||||
|
||||
-- Use detected model behavior: {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2141072961"] = "Use detected model behavior: {0}."
|
||||
|
||||
-- Model
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2189814010"] = "Model"
|
||||
|
||||
-- (Optional) API Key
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2331453405"] = "(Optional) API Key"
|
||||
|
||||
-- Enabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2626085950"] = "Enabled"
|
||||
|
||||
-- Add
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2646845972"] = "Add"
|
||||
|
||||
@ -4725,12 +4821,42 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2810182573"] = "No models l
|
||||
-- Instance Name
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2842060373"] = "Instance Name"
|
||||
|
||||
-- On by default
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T2843289040"] = "On by default"
|
||||
|
||||
-- No reasoning (thinking) capability.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T301695429"] = "No reasoning (thinking) capability."
|
||||
|
||||
-- Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3079061205"] = "Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available."
|
||||
|
||||
-- Reasoning (thinking) is available and on unless additional API parameters disable it.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T310420667"] = "Reasoning (thinking) is available and on unless additional API parameters disable it."
|
||||
|
||||
-- Disabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3217987877"] = "Disabled"
|
||||
|
||||
-- The model always uses reasoning (thinking); it cannot be disabled.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3294757333"] = "The model always uses reasoning (thinking); it cannot be disabled."
|
||||
|
||||
-- Can be enabled
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3299454847"] = "Can be enabled"
|
||||
|
||||
-- Show Expert Settings
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3361153305"] = "Show Expert Settings"
|
||||
|
||||
-- Audio input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3404621481"] = "Audio input"
|
||||
|
||||
-- Invalid JSON: Add the parameters in proper JSON formatting, e.g., \"temperature\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3502745319"] = "Invalid JSON: Add the parameters in proper JSON formatting, e.g., \\\"temperature\\\": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though."
|
||||
|
||||
-- Reasoning (thinking) behavior
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3546126752"] = "Reasoning (thinking) behavior"
|
||||
|
||||
-- Reasoning (thinking) is available, but off unless additional API parameters enable it.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3548835672"] = "Reasoning (thinking) is available, but off unless additional API parameters enable it."
|
||||
|
||||
-- Show available models
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3763891899"] = "Show available models"
|
||||
|
||||
@ -4740,18 +4866,36 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3783329915"] = "This host u
|
||||
-- Duplicate key '{0}' found.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3804472591"] = "Duplicate key '{0}' found."
|
||||
|
||||
-- Override Model Capabilities
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T3904244586"] = "Override Model Capabilities"
|
||||
|
||||
-- Currently, we cannot query the models for the selected provider and/or host. Therefore, please enter the model name manually.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4116737656"] = "Currently, we cannot query the models for the selected provider and/or host. Therefore, please enter the model name manually."
|
||||
|
||||
-- Model selection
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T416738168"] = "Model selection"
|
||||
|
||||
-- Stored default model capabilities may not reflect its full range. Override them here if needed.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4217532151"] = "Stored default model capabilities may not reflect its full range. Override them here if needed."
|
||||
|
||||
-- Video input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T4289835208"] = "Video input"
|
||||
|
||||
-- We are currently unable to communicate with the provider to load models. Please try again later.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T504465522"] = "We are currently unable to communicate with the provider to load models. Please try again later."
|
||||
|
||||
-- Always reasoning
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T641757736"] = "Always reasoning"
|
||||
|
||||
-- Host
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T808120719"] = "Host"
|
||||
|
||||
-- Multiple image input
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T858529900"] = "Multiple image input"
|
||||
|
||||
-- No reasoning (thinking)
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T87434533"] = "No reasoning (thinking)"
|
||||
|
||||
-- Provider
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T900237532"] = "Provider"
|
||||
|
||||
@ -7887,6 +8031,12 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANT
|
||||
-- Button
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANTCOMPONENTTYPEEXTENSIONS::T864557713"] = "Button"
|
||||
|
||||
-- The ASSISTANT table contains an invalid LaunchBehavior value.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T109828905"] = "The ASSISTANT table contains an invalid LaunchBehavior value."
|
||||
|
||||
-- The ASSISTANT table contains an unsupported LaunchBehavior value.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1194373781"] = "The ASSISTANT table contains an unsupported LaunchBehavior value."
|
||||
|
||||
-- Failed to parse the UI render tree from the ASSISTANT lua table.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1318499252"] = "Failed to parse the UI render tree from the ASSISTANT lua table."
|
||||
|
||||
@ -7902,12 +8052,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T2
|
||||
-- The ASSISTANT lua table does not exist or is not a valid table.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3017816936"] = "The ASSISTANT lua table does not exist or is not a valid table."
|
||||
|
||||
-- The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3233001282"] = "The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'."
|
||||
|
||||
-- The provided ASSISTANT lua table does not contain a valid system prompt.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3402798667"] = "The provided ASSISTANT lua table does not contain a valid system prompt."
|
||||
|
||||
-- The ASSISTANT table does not contain a valid system prompt.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3723171842"] = "The ASSISTANT table does not contain a valid system prompt."
|
||||
|
||||
-- The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T4215554842"] = "The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName."
|
||||
|
||||
-- ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T683382975"] = "ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax."
|
||||
|
||||
@ -7950,6 +8106,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2774333862"] = "The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used."
|
||||
|
||||
-- The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2824524534"] = "The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage."
|
||||
|
||||
-- Not Audited
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2828154864"] = "Not Audited"
|
||||
|
||||
@ -7959,12 +8118,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- Open Security Check
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T290241209"] = "Open Security Check"
|
||||
|
||||
-- User Audit
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3293963409"] = "User Audit"
|
||||
|
||||
-- Restricted
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3325062668"] = "Restricted"
|
||||
|
||||
-- Unknown
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3424652889"] = "Unknown"
|
||||
|
||||
-- Approved by your organization
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3508214481"] = "Approved by your organization"
|
||||
|
||||
-- Unlocked
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3606159420"] = "Unlocked"
|
||||
|
||||
@ -7980,9 +8145,24 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR
|
||||
-- No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3899951594"] = "No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used."
|
||||
|
||||
-- No Approval
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T515592229"] = "No Approval"
|
||||
|
||||
-- This assistant was approved by your organization.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T538196816"] = "This assistant was approved by your organization."
|
||||
|
||||
-- Safe
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T760494712"] = "Safe"
|
||||
|
||||
-- Open Security Details
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T803119455"] = "Open Security Details"
|
||||
|
||||
-- Start Security Check
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T811648299"] = "Start Security Check"
|
||||
|
||||
-- This assistant was approved by your organization as '{0}'.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T834246718"] = "This assistant was approved by your organization as '{0}'."
|
||||
|
||||
-- This assistant currently has no stored audit.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T921972844"] = "This assistant currently has no stored audit."
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ using AIStudio.Agents.AssistantAudit;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.Databases;
|
||||
using AIStudio.Tools.AIJobs;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.PluginSystem.Assistants;
|
||||
using AIStudio.Tools.Services;
|
||||
@ -130,6 +131,7 @@ internal sealed class Program
|
||||
builder.Services.AddSingleton<SettingsManager>();
|
||||
builder.Services.AddSingleton<ThreadSafeRandom>();
|
||||
builder.Services.AddSingleton<AIJobService>();
|
||||
builder.Services.AddSingleton<AssistantSessionService>();
|
||||
builder.Services.AddSingleton<VoiceRecordingAvailabilityService>();
|
||||
builder.Services.AddSingleton<AssistantPluginInstallService>();
|
||||
builder.Services.AddSingleton<DataSourceService>();
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace AIStudio.Provider;
|
||||
|
||||
/// <summary>
|
||||
/// Parses the provider-specific JSON fragment stored in <see cref="IProvider.AdditionalJsonApiParameters"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The provider settings UI stores only the body of a JSON object, such as
|
||||
/// <c>"temperature": 0.5</c>. This parser wraps that fragment in curly braces,
|
||||
/// parses it as JSON, and converts it to regular CLR dictionaries, lists, and
|
||||
/// primitive values so request builders and feature detectors can inspect it.
|
||||
/// </remarks>
|
||||
public static class AdditionalApiParametersParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Try to parse an additional-API-parameters JSON fragment into a dictionary.
|
||||
/// </summary>
|
||||
/// <param name="additionalJsonApiParameters">The JSON object body without the surrounding curly braces.</param>
|
||||
/// <param name="parameters">The parsed parameters if parsing succeeds; otherwise an empty dictionary.</param>
|
||||
/// <param name="errorMessage">The JSON parsing error message if parsing fails; otherwise <see langword="null"/>.</param>
|
||||
/// <returns><see langword="true"/> if the fragment is empty or valid JSON; otherwise <see langword="false"/>.</returns>
|
||||
public static bool TryParse(string additionalJsonApiParameters, out IDictionary<string, object> parameters, out string? errorMessage)
|
||||
{
|
||||
parameters = new Dictionary<string, object>();
|
||||
errorMessage = null;
|
||||
if (string.IsNullOrWhiteSpace(additionalJsonApiParameters))
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
// The UI stores only the object body, so wrap it before parsing.
|
||||
using var jsonDoc = JsonDocument.Parse($"{{{additionalJsonApiParameters}}}");
|
||||
parameters = ConvertToDictionary(jsonDoc.RootElement);
|
||||
return true;
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
errorMessage = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove keys from a parsed parameter dictionary using case-insensitive matching.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed parameter dictionary to mutate.</param>
|
||||
/// <param name="keysToRemove">The parameter names that should be removed.</param>
|
||||
/// <returns>The same dictionary instance after the matching keys were removed.</returns>
|
||||
public static IDictionary<string, object> RemoveKeys(IDictionary<string, object> parameters, IEnumerable<string> keysToRemove)
|
||||
{
|
||||
var removeSet = new HashSet<string>(keysToRemove, StringComparer.OrdinalIgnoreCase);
|
||||
if (removeSet.Count is 0)
|
||||
return parameters;
|
||||
|
||||
foreach (var key in parameters.Keys.ToList())
|
||||
if (removeSet.Contains(key))
|
||||
parameters.Remove(key);
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a JSON object element into a dictionary of recursively converted CLR values.
|
||||
/// </summary>
|
||||
/// <param name="element">The JSON object element to convert.</param>
|
||||
/// <returns>A dictionary containing all JSON object properties.</returns>
|
||||
private static IDictionary<string, object> ConvertToDictionary(JsonElement element)
|
||||
{
|
||||
return element.EnumerateObject()
|
||||
.ToDictionary<JsonProperty, string, object>(
|
||||
p => p.Name,
|
||||
p => ConvertJsonValue(p.Value) ?? string.Empty
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a JSON value to the closest CLR representation used by provider request objects.
|
||||
/// </summary>
|
||||
/// <param name="element">The JSON element to convert.</param>
|
||||
/// <returns>A string, number, boolean, dictionary, list, or empty string for unsupported/null values.</returns>
|
||||
private static object? ConvertJsonValue(JsonElement element) => element.ValueKind switch
|
||||
{
|
||||
JsonValueKind.String => element.GetString(),
|
||||
JsonValueKind.Number => element.TryGetInt32(out var i) ? i :
|
||||
element.TryGetInt64(out var l) ? l :
|
||||
element.TryGetDouble(out var d) ? d :
|
||||
element.GetDecimal(),
|
||||
JsonValueKind.True or JsonValueKind.False => element.GetBoolean(),
|
||||
JsonValueKind.Null => string.Empty,
|
||||
JsonValueKind.Object => ConvertToDictionary(element),
|
||||
JsonValueKind.Array => element.EnumerateArray().Select(ConvertJsonValue).ToList(),
|
||||
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
@ -1191,42 +1191,15 @@ public abstract class BaseProvider : IProvider, ISecretId
|
||||
protected IDictionary<string, object> ParseAdditionalApiParameters(
|
||||
params string[] keysToRemove)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(this.AdditionalJsonApiParameters))
|
||||
return new Dictionary<string, object>();
|
||||
|
||||
try
|
||||
if (!AdditionalApiParametersParser.TryParse(this.AdditionalJsonApiParameters, out var apiParameters, out var errorMessage))
|
||||
{
|
||||
// Wrap the user-provided parameters in curly brackets to form a valid JSON object:
|
||||
var json = $"{{{this.AdditionalJsonApiParameters}}}";
|
||||
var jsonDoc = JsonSerializer.Deserialize<JsonElement>(json, JSON_SERIALIZER_OPTIONS);
|
||||
var dict = ConvertToDictionary(jsonDoc);
|
||||
|
||||
// Some keys are always removed because we set them:
|
||||
var removeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
if (keysToRemove.Length > 0)
|
||||
removeSet.UnionWith(keysToRemove);
|
||||
|
||||
removeSet.Add("stream");
|
||||
removeSet.Add("model");
|
||||
removeSet.Add("messages");
|
||||
|
||||
// Remove the specified keys (case-insensitive):
|
||||
if (removeSet.Count > 0)
|
||||
{
|
||||
foreach (var key in dict.Keys.ToList())
|
||||
{
|
||||
if (removeSet.Contains(key))
|
||||
dict.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
this.logger.LogError("Failed to parse additional API parameters: {ExceptionMessage}", ex.Message);
|
||||
this.logger.LogError("Failed to parse additional API parameters: {ExceptionMessage}", errorMessage);
|
||||
return new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
// Some keys are always removed because AI Studio sets them itself.
|
||||
var reservedKeys = keysToRemove.Concat(["stream", "model", "messages"]);
|
||||
return AdditionalApiParametersParser.RemoveKeys(apiParameters, reservedKeys);
|
||||
}
|
||||
|
||||
protected static bool TryPopIntParameter(IDictionary<string, object> parameters, string key, out int value)
|
||||
@ -1308,27 +1281,4 @@ public abstract class BaseProvider : IProvider, ISecretId
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IDictionary<string, object> ConvertToDictionary(JsonElement element)
|
||||
{
|
||||
return element.EnumerateObject()
|
||||
.ToDictionary<JsonProperty, string, object>(
|
||||
p => p.Name,
|
||||
p => ConvertJsonValue(p.Value) ?? string.Empty
|
||||
);
|
||||
}
|
||||
|
||||
private static object? ConvertJsonValue(JsonElement element) => element.ValueKind switch
|
||||
{
|
||||
JsonValueKind.String => element.GetString(),
|
||||
JsonValueKind.Number => element.TryGetInt32(out var i) ? i :
|
||||
element.TryGetInt64(out var l) ? l :
|
||||
element.TryGetDouble(out var d) ? d :
|
||||
element.GetDecimal(),
|
||||
JsonValueKind.True or JsonValueKind.False => element.GetBoolean(),
|
||||
JsonValueKind.Null => string.Empty,
|
||||
JsonValueKind.Object => ConvertToDictionary(element),
|
||||
JsonValueKind.Array => element.EnumerateArray().Select(ConvertJsonValue).ToList(),
|
||||
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
@ -71,15 +71,20 @@ public enum Capability
|
||||
VIDEO_OUTPUT,
|
||||
|
||||
/// <summary>
|
||||
/// The AI model can perform reasoning tasks.
|
||||
/// The AI model can perform reasoning tasks. You can enable reasoning optionally, but it is disabled by default.
|
||||
/// </summary>
|
||||
OPTIONAL_REASONING,
|
||||
|
||||
/// <summary>
|
||||
/// The AI model always performs reasoning.
|
||||
/// The AI model always performs reasoning. There is no option to disable reasoning.
|
||||
/// </summary>
|
||||
ALWAYS_REASONING,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The AI model performs optional reasoning, but it is enabled by default.
|
||||
/// </summary>
|
||||
REASONING_BY_DEFAULT,
|
||||
|
||||
/// <summary>
|
||||
/// The AI model can embed information or data.
|
||||
/// </summary>
|
||||
|
||||
27
app/MindWork AI Studio/Provider/ReasoningIndicatorState.cs
Normal file
27
app/MindWork AI Studio/Provider/ReasoningIndicatorState.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace AIStudio.Provider;
|
||||
|
||||
/// <summary>
|
||||
/// Describes whether the provider selection should show the reasoning capability icon.
|
||||
/// </summary>
|
||||
public enum ReasoningIndicatorState
|
||||
{
|
||||
/// <summary>
|
||||
/// Do not show a reasoning indicator for the configured provider.
|
||||
/// </summary>
|
||||
NONE,
|
||||
|
||||
/// <summary>
|
||||
/// Show that the selected model always performs reasoning.
|
||||
/// </summary>
|
||||
ALWAYS_ON,
|
||||
|
||||
/// <summary>
|
||||
/// Show that reasoning is enabled by the provider or model default.
|
||||
/// </summary>
|
||||
DEFAULT_ON,
|
||||
|
||||
/// <summary>
|
||||
/// Show that reasoning was explicitly enabled through the provider settings.
|
||||
/// </summary>
|
||||
CONFIGURED,
|
||||
}
|
||||
@ -125,9 +125,9 @@ public sealed class Data
|
||||
|
||||
public DataTextContentCleaner TextContentCleaner { get; init; } = new();
|
||||
|
||||
public DataAgentDataSourceSelection AgentDataSourceSelection { get; init; } = new();
|
||||
public DataAgentDataSourceSelection AgentDataSourceSelection { get; init; } = new(x => x.AgentDataSourceSelection);
|
||||
|
||||
public DataAgentRetrievalContextValidation AgentRetrievalContextValidation { get; init; } = new();
|
||||
public DataAgentRetrievalContextValidation AgentRetrievalContextValidation { get; init; } = new(x => x.AgentRetrievalContextValidation);
|
||||
|
||||
public DataAssistantPluginAudit AssistantPluginAudit { get; init; } = new(x => x.AssistantPluginAudit);
|
||||
|
||||
|
||||
@ -1,14 +1,23 @@
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataAgentDataSourceSelection
|
||||
public sealed class DataAgentDataSourceSelection(Expression<Func<Data, DataAgentDataSourceSelection>>? configSelection = null)
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor for the JSON deserializer.
|
||||
/// </summary>
|
||||
public DataAgentDataSourceSelection() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preselect any data source selection options?
|
||||
/// </summary>
|
||||
public bool PreselectAgentOptions { get; set; }
|
||||
public bool PreselectAgentOptions { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectAgentOptions, false);
|
||||
|
||||
/// <summary>
|
||||
/// Preselect a data source selection provider?
|
||||
/// </summary>
|
||||
public string PreselectedAgentProvider { get; set; } = string.Empty;
|
||||
public string PreselectedAgentProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedAgentProvider, string.Empty);
|
||||
}
|
||||
@ -1,24 +1,33 @@
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataAgentRetrievalContextValidation
|
||||
public sealed class DataAgentRetrievalContextValidation(Expression<Func<Data, DataAgentRetrievalContextValidation>>? configSelection = null)
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor for the JSON deserializer.
|
||||
/// </summary>
|
||||
public DataAgentRetrievalContextValidation() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable the retrieval context validation agent?
|
||||
/// </summary>
|
||||
public bool EnableRetrievalContextValidation { get; set; }
|
||||
public bool EnableRetrievalContextValidation { get; set; } = ManagedConfiguration.Register(configSelection, n => n.EnableRetrievalContextValidation, false);
|
||||
|
||||
/// <summary>
|
||||
/// Preselect any retrieval context validation options?
|
||||
/// </summary>
|
||||
public bool PreselectAgentOptions { get; set; }
|
||||
public bool PreselectAgentOptions { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectAgentOptions, false);
|
||||
|
||||
/// <summary>
|
||||
/// Preselect a retrieval context validation provider?
|
||||
/// </summary>
|
||||
public string PreselectedAgentProvider { get; set; } = string.Empty;
|
||||
public string PreselectedAgentProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedAgentProvider, string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Configure how many parallel validations to run.
|
||||
/// </summary>
|
||||
public int NumParallelValidations { get; set; } = 3;
|
||||
public int NumParallelValidations { get; set; } = ManagedConfiguration.Register(configSelection, n => n.NumParallelValidations, 3);
|
||||
}
|
||||
@ -40,4 +40,9 @@ public sealed class DataAssistantPluginAudit(Expression<Func<Data, DataAssistant
|
||||
/// If true, the security audit will be hidden from the user and done in the background
|
||||
/// </summary>
|
||||
public bool AutomaticallyAuditAssistants { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AutomaticallyAuditAssistants, false);
|
||||
|
||||
/// <summary>
|
||||
/// Enterprise-managed assistant plugin hashes that are approved without requiring a user audit.
|
||||
/// </summary>
|
||||
public IList<DataAssistantPluginEnterpriseApproval> EnterpriseApprovedPlugins { get; set; } = ManagedConfiguration.Register(configSelection, n => n.EnterpriseApprovedPlugins, []);
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
/// <summary>
|
||||
/// Enterprise-managed approval entry for an assistant plugin hash.
|
||||
/// </summary>
|
||||
public sealed class DataAssistantPluginEnterpriseApproval
|
||||
{
|
||||
public string PluginHash { get; init; } = string.Empty;
|
||||
public string DisplayName { get; init; } = string.Empty;
|
||||
public string Comment { get; init; } = string.Empty;
|
||||
public string ApprovedBy { get; init; } = string.Empty;
|
||||
public DateTimeOffset? ApprovedAtUtc { get; init; }
|
||||
}
|
||||
@ -29,7 +29,7 @@ public sealed class DataChat(Expression<Func<Data, DataChat>>? configSelection =
|
||||
/// <summary>
|
||||
/// Defines the data source behavior when sending assistant results to a chat.
|
||||
/// </summary>
|
||||
public SendToChatDataSourceBehavior SendToChatDataSourceBehavior { get; set; } = SendToChatDataSourceBehavior.NO_DATA_SOURCES;
|
||||
public SendToChatDataSourceBehavior SendToChatDataSourceBehavior { get; set; } = ManagedConfiguration.Register(configSelection, n => n.SendToChatDataSourceBehavior, SendToChatDataSourceBehavior.NO_DATA_SOURCES);
|
||||
|
||||
/// <summary>
|
||||
/// Preselect any chat options?
|
||||
@ -51,10 +51,47 @@ public sealed class DataChat(Expression<Func<Data, DataChat>>? configSelection =
|
||||
/// </summary>
|
||||
public string PreselectedChatTemplate { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedChatTemplate, string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Whether data sources are disabled by default for new chats.
|
||||
/// </summary>
|
||||
public bool PreselectedDataSourcesDisabled { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedDataSourcesDisabled, true);
|
||||
|
||||
/// <summary>
|
||||
/// Whether data sources should be selected automatically by default for new chats.
|
||||
/// </summary>
|
||||
public bool PreselectedDataSourcesAutomaticSelection { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedDataSourcesAutomaticSelection, false);
|
||||
|
||||
/// <summary>
|
||||
/// Whether retrieved data should be validated automatically by default for new chats.
|
||||
/// </summary>
|
||||
public bool PreselectedDataSourcesAutomaticValidation { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedDataSourcesAutomaticValidation, false);
|
||||
|
||||
/// <summary>
|
||||
/// The data source IDs that should be preselected by default for new chats.
|
||||
/// </summary>
|
||||
public List<string> PreselectedDataSourceIds { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedDataSourceIds, []);
|
||||
|
||||
/// <summary>
|
||||
/// Should we preselect data sources options for a created chat?
|
||||
/// </summary>
|
||||
public DataSourceOptions PreselectedDataSourceOptions { get; set; } = new();
|
||||
// Compatibility shim: legacy settings used this nested object. See documentation/compatibility-shims/2026-07-chat-data-source-options.md; remove after 2027-01-05.
|
||||
public DataSourceOptions PreselectedDataSourceOptions
|
||||
{
|
||||
get => new()
|
||||
{
|
||||
DisableDataSources = this.PreselectedDataSourcesDisabled,
|
||||
AutomaticDataSourceSelection = this.PreselectedDataSourcesAutomaticSelection,
|
||||
AutomaticValidation = this.PreselectedDataSourcesAutomaticValidation,
|
||||
PreselectedDataSourceIds = [..this.PreselectedDataSourceIds],
|
||||
};
|
||||
set
|
||||
{
|
||||
this.PreselectedDataSourcesDisabled = value.DisableDataSources;
|
||||
this.PreselectedDataSourcesAutomaticSelection = value.AutomaticDataSourceSelection;
|
||||
this.PreselectedDataSourcesAutomaticValidation = value.AutomaticValidation;
|
||||
this.PreselectedDataSourceIds = [..value.PreselectedDataSourceIds];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should we show the latest message after loading? When false, we show the first (aka oldest) message.
|
||||
|
||||
@ -435,7 +435,9 @@ public static partial class ManagedConfiguration
|
||||
if(dryRun)
|
||||
return successful;
|
||||
|
||||
return HandleParsedValue(configPluginId, dryRun, successful, configMeta, configuredValue);
|
||||
var settingName = SettingName(propertyExpression);
|
||||
var managedMode = ReadManagedConfigurationMode(propertyExpression, settings);
|
||||
return HandleParsedScalarValue(configPluginId, dryRun, successful, configMeta, configuredValue, managedMode, settingName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1026,6 +1028,10 @@ public static partial class ManagedConfiguration
|
||||
.Cast<object>()
|
||||
.OrderBy(key => key.ToString(), StringComparer.Ordinal)
|
||||
.Select(key => $"{key}:{dictionary[key]}")),
|
||||
System.Collections.IEnumerable enumerable => string.Join(";", enumerable
|
||||
.Cast<object>()
|
||||
.Select(item => item.ToString() ?? string.Empty)
|
||||
.Order(StringComparer.Ordinal)),
|
||||
IFormattable formattable => formattable.ToString(null, CultureInfo.InvariantCulture),
|
||||
|
||||
_ => value.ToString() ?? string.Empty,
|
||||
|
||||
@ -358,17 +358,18 @@ public static partial class ManagedConfiguration
|
||||
if (!TryGet(configSelection, propertyExpression, out var configMeta))
|
||||
return false;
|
||||
|
||||
if (configMeta.ManagedMode is ManagedConfigurationMode.EDITABLE_DEFAULT)
|
||||
return CleanupEditableDefaultState(configMeta, SettingName(propertyExpression), availablePlugins.ToList());
|
||||
|
||||
if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
|
||||
return false;
|
||||
|
||||
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
|
||||
if (plugin is null)
|
||||
{
|
||||
configMeta.ResetLockedConfiguration();
|
||||
return true;
|
||||
}
|
||||
if (plugin is not null)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
configMeta.ResetLockedConfiguration();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsConfigurationLeftOver<TClass, TValue>(
|
||||
|
||||
@ -33,7 +33,8 @@ public sealed record Provider(
|
||||
string Hostname = "http://localhost:1234",
|
||||
Host Host = Host.NONE,
|
||||
HFInferenceProvider HFInferenceProvider = HFInferenceProvider.NONE,
|
||||
string AdditionalJsonApiParameters = "") : ConfigurationBaseObject, ISecretId
|
||||
string AdditionalJsonApiParameters = "",
|
||||
ProviderCapabilityOverrides? CapabilityOverrides = null) : ConfigurationBaseObject, ISecretId
|
||||
{
|
||||
private static readonly ILogger<Provider> LOGGER = Program.LOGGER_FACTORY.CreateLogger<Provider>();
|
||||
|
||||
@ -152,6 +153,8 @@ public sealed record Provider(
|
||||
additionalJsonApiParameters = string.Empty;
|
||||
}
|
||||
|
||||
var capabilityOverrides = ProviderCapabilityOverrides.TryParseFromLuaTable(idx, table, configPluginId, LOGGER);
|
||||
|
||||
provider = new Provider
|
||||
{
|
||||
Num = 0, // will be set later by the PluginConfigurationObject
|
||||
@ -166,6 +169,7 @@ public sealed record Provider(
|
||||
Host = host,
|
||||
HFInferenceProvider = hfInferenceProvider,
|
||||
AdditionalJsonApiParameters = additionalJsonApiParameters,
|
||||
CapabilityOverrides = capabilityOverrides,
|
||||
};
|
||||
|
||||
// Handle encrypted API key if present:
|
||||
@ -241,6 +245,8 @@ public sealed record Provider(
|
||||
""";
|
||||
}
|
||||
|
||||
var capabilityOverridesLine = this.CapabilityOverrides?.ExportAsLuaTable(" ") ?? string.Empty;
|
||||
|
||||
return $$"""
|
||||
CONFIG["LLM_PROVIDERS"][#CONFIG["LLM_PROVIDERS"]+1] = {
|
||||
["Id"] = "{{Guid.NewGuid().ToString()}}",
|
||||
@ -252,6 +258,7 @@ public sealed record Provider(
|
||||
{{hfInferenceProviderLine}}
|
||||
{{apiKeyLine}}
|
||||
["AdditionalJsonApiParameters"] = "{{LuaTools.EscapeLuaString(this.AdditionalJsonApiParameters)}}",
|
||||
{{capabilityOverridesLine}}
|
||||
["Model"] = {
|
||||
["Id"] = "{{LuaTools.EscapeLuaString(this.Model.Id)}}",
|
||||
["DisplayName"] = "{{LuaTools.EscapeLuaString(this.Model.DisplayName ?? this.Model.Id)}}",
|
||||
|
||||
207
app/MindWork AI Studio/Settings/ProviderCapabilityOverrides.cs
Normal file
207
app/MindWork AI Studio/Settings/ProviderCapabilityOverrides.cs
Normal file
@ -0,0 +1,207 @@
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using AIStudio.Provider;
|
||||
|
||||
using Lua;
|
||||
|
||||
using LuaTable = Lua.LuaTable;
|
||||
|
||||
namespace AIStudio.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Optional expert capability overrides for a configured LLM provider.
|
||||
/// Missing values keep the automatic capability detection result.
|
||||
/// </summary>
|
||||
public sealed record ProviderCapabilityOverrides
|
||||
{
|
||||
private static readonly IReadOnlyList<Capability> SUPPORTED_CAPABILITIES =
|
||||
[
|
||||
Capability.AUDIO_INPUT,
|
||||
Capability.MULTIPLE_IMAGE_INPUT,
|
||||
Capability.SPEECH_INPUT,
|
||||
Capability.VIDEO_INPUT,
|
||||
Capability.OPTIONAL_REASONING,
|
||||
Capability.ALWAYS_REASONING,
|
||||
Capability.REASONING_BY_DEFAULT
|
||||
];
|
||||
|
||||
[JsonPropertyName("AUDIO_INPUT")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? AudioInput { get; init; }
|
||||
|
||||
[JsonPropertyName("MULTIPLE_IMAGE_INPUT")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? MultipleImageInput { get; init; }
|
||||
|
||||
[JsonPropertyName("SPEECH_INPUT")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? SpeechInput { get; init; }
|
||||
|
||||
[JsonPropertyName("VIDEO_INPUT")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? VideoInput { get; init; }
|
||||
|
||||
[JsonPropertyName("OPTIONAL_REASONING")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? OptionalReasoning { get; init; }
|
||||
|
||||
[JsonPropertyName("ALWAYS_REASONING")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? AlwaysReasoning { get; init; }
|
||||
|
||||
[JsonPropertyName("REASONING_BY_DEFAULT")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? ReasoningByDefault { get; init; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool HasOverrides =>
|
||||
this.AudioInput is not null ||
|
||||
this.MultipleImageInput is not null ||
|
||||
this.SpeechInput is not null ||
|
||||
this.VideoInput is not null ||
|
||||
this.OptionalReasoning is not null ||
|
||||
this.AlwaysReasoning is not null ||
|
||||
this.ReasoningByDefault is not null;
|
||||
|
||||
public bool? GetOverride(Capability capability) => capability switch
|
||||
{
|
||||
Capability.AUDIO_INPUT => this.AudioInput,
|
||||
Capability.MULTIPLE_IMAGE_INPUT => this.MultipleImageInput,
|
||||
Capability.SPEECH_INPUT => this.SpeechInput,
|
||||
Capability.VIDEO_INPUT => this.VideoInput,
|
||||
Capability.OPTIONAL_REASONING => this.OptionalReasoning,
|
||||
Capability.ALWAYS_REASONING => this.AlwaysReasoning,
|
||||
Capability.REASONING_BY_DEFAULT => this.ReasoningByDefault,
|
||||
_ => null
|
||||
};
|
||||
|
||||
public ProviderCapabilityOverrides SetOverride(Capability capability, bool? value) => capability switch
|
||||
{
|
||||
Capability.AUDIO_INPUT => this with { AudioInput = value },
|
||||
Capability.MULTIPLE_IMAGE_INPUT => this with { MultipleImageInput = value },
|
||||
Capability.SPEECH_INPUT => this with { SpeechInput = value },
|
||||
Capability.VIDEO_INPUT => this with { VideoInput = value },
|
||||
Capability.OPTIONAL_REASONING => this with { OptionalReasoning = value },
|
||||
Capability.ALWAYS_REASONING => this with { AlwaysReasoning = value },
|
||||
Capability.REASONING_BY_DEFAULT => this with { ReasoningByDefault = value },
|
||||
_ => this
|
||||
};
|
||||
|
||||
public List<Capability> ApplyTo(IEnumerable<Capability> automaticCapabilities)
|
||||
{
|
||||
var mergedCapabilities = automaticCapabilities.Distinct().ToList();
|
||||
foreach (var capability in SUPPORTED_CAPABILITIES)
|
||||
{
|
||||
var overrideValue = this.GetOverride(capability);
|
||||
if (overrideValue == true && !mergedCapabilities.Contains(capability))
|
||||
mergedCapabilities.Add(capability);
|
||||
else if (overrideValue == false)
|
||||
mergedCapabilities.Remove(capability);
|
||||
}
|
||||
|
||||
this.NormalizeReasoningCapabilities(mergedCapabilities);
|
||||
return mergedCapabilities;
|
||||
}
|
||||
|
||||
private void NormalizeReasoningCapabilities(List<Capability> capabilities)
|
||||
{
|
||||
if (this.AlwaysReasoning == true ||
|
||||
this.AlwaysReasoning is not false &&
|
||||
this.OptionalReasoning is not true &&
|
||||
this.ReasoningByDefault is not true &&
|
||||
capabilities.Contains(Capability.ALWAYS_REASONING))
|
||||
{
|
||||
capabilities.Remove(Capability.OPTIONAL_REASONING);
|
||||
capabilities.Remove(Capability.REASONING_BY_DEFAULT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.AlwaysReasoning == false ||
|
||||
this.OptionalReasoning == true ||
|
||||
this.ReasoningByDefault == true)
|
||||
capabilities.Remove(Capability.ALWAYS_REASONING);
|
||||
|
||||
if (this.OptionalReasoning == false)
|
||||
{
|
||||
capabilities.Remove(Capability.REASONING_BY_DEFAULT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ReasoningByDefault == true && !capabilities.Contains(Capability.OPTIONAL_REASONING))
|
||||
capabilities.Add(Capability.OPTIONAL_REASONING);
|
||||
|
||||
if (!capabilities.Contains(Capability.OPTIONAL_REASONING))
|
||||
capabilities.Remove(Capability.REASONING_BY_DEFAULT);
|
||||
}
|
||||
|
||||
public string ExportAsLuaTable(string indentation)
|
||||
{
|
||||
if (!this.HasOverrides)
|
||||
return string.Empty;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine($@"{indentation}[""CapabilityOverrides""] = {{");
|
||||
foreach (var capability in SUPPORTED_CAPABILITIES)
|
||||
{
|
||||
var overrideValue = this.GetOverride(capability);
|
||||
if (overrideValue is null)
|
||||
continue;
|
||||
|
||||
builder.AppendLine($@"{indentation} [""{capability}""] = {overrideValue.Value.ToString().ToLowerInvariant()},");
|
||||
}
|
||||
|
||||
builder.Append($@"{indentation}}},");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static ProviderCapabilityOverrides? TryParseFromLuaTable(int idx, LuaTable providerTable, Guid configPluginId, ILogger logger)
|
||||
{
|
||||
if (!providerTable.TryGetValue("CapabilityOverrides", out var capabilityOverridesValue))
|
||||
return null;
|
||||
|
||||
if (capabilityOverridesValue.Type is not LuaValueType.Table || !capabilityOverridesValue.TryRead<LuaTable>(out var capabilityOverridesTable))
|
||||
{
|
||||
logger.LogWarning("The configured provider {ProviderIndex} contains an invalid CapabilityOverrides table. Automatic capability detection will be used instead. (Plugin ID: {PluginId})", idx, configPluginId);
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = new ProviderCapabilityOverrides();
|
||||
var previousKey = LuaValue.Nil;
|
||||
while (capabilityOverridesTable.TryGetNext(previousKey, out var pair))
|
||||
{
|
||||
previousKey = pair.Key;
|
||||
|
||||
if (!pair.Key.TryRead<string>(out var keyText))
|
||||
{
|
||||
logger.LogWarning("The configured provider {ProviderIndex} contains a CapabilityOverrides entry with a non-string key. The entry will be ignored. (Plugin ID: {PluginId})", idx, configPluginId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TryParseSupportedCapability(keyText, out var capability))
|
||||
{
|
||||
logger.LogWarning("The configured provider {ProviderIndex} contains an unsupported capability override '{CapabilityKey}'. The entry will be ignored. (Plugin ID: {PluginId})", idx, keyText, configPluginId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pair.Value.TryRead<bool>(out var overrideValue))
|
||||
{
|
||||
logger.LogWarning("The configured provider {ProviderIndex} contains a non-boolean capability override for '{CapabilityKey}'. Automatic capability detection will be used for that capability. (Plugin ID: {PluginId})", idx, keyText, configPluginId);
|
||||
continue;
|
||||
}
|
||||
|
||||
result = result.SetOverride(capability, overrideValue);
|
||||
}
|
||||
|
||||
return result.HasOverrides ? result : null;
|
||||
}
|
||||
|
||||
private static bool TryParseSupportedCapability(string capabilityKey, out Capability capability)
|
||||
{
|
||||
capability = Capability.NONE;
|
||||
if (!Enum.TryParse(capabilityKey, true, out capability))
|
||||
return false;
|
||||
|
||||
return SUPPORTED_CAPABILITIES.Contains(capability);
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,19 @@ public static partial class ProviderExtensions
|
||||
|
||||
if (modelName.IndexOf("gemini-") is not -1)
|
||||
{
|
||||
// Gemini 2.5 Flash Lite supports thinking, but the default is off:
|
||||
if (modelName.IndexOf("gemini-2.5-flash-lite") is not -1)
|
||||
return
|
||||
[
|
||||
Capability.TEXT_INPUT, Capability.MULTIPLE_IMAGE_INPUT, Capability.AUDIO_INPUT,
|
||||
Capability.SPEECH_INPUT, Capability.VIDEO_INPUT,
|
||||
|
||||
Capability.TEXT_OUTPUT,
|
||||
|
||||
Capability.OPTIONAL_REASONING, Capability.FUNCTION_CALLING,
|
||||
Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
// Reasoning models:
|
||||
if (modelName.IndexOf("gemini-2.5") is not -1)
|
||||
return
|
||||
|
||||
@ -175,6 +175,17 @@ public static partial class ProviderExtensions
|
||||
Capability.WEB_SEARCH,
|
||||
Capability.RESPONSES_API, Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
if(modelName is "gpt-5.5" || modelName.StartsWith("gpt-5.5-"))
|
||||
return
|
||||
[
|
||||
Capability.TEXT_INPUT, Capability.MULTIPLE_IMAGE_INPUT,
|
||||
Capability.TEXT_OUTPUT, Capability.IMAGE_OUTPUT,
|
||||
|
||||
Capability.FUNCTION_CALLING, Capability.OPTIONAL_REASONING, Capability.REASONING_BY_DEFAULT,
|
||||
Capability.WEB_SEARCH,
|
||||
Capability.RESPONSES_API, Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
return
|
||||
[
|
||||
|
||||
@ -109,7 +109,7 @@ public static partial class ProviderExtensions
|
||||
Capability.TEXT_INPUT, Capability.MULTIPLE_IMAGE_INPUT,
|
||||
Capability.TEXT_OUTPUT,
|
||||
|
||||
Capability.ALWAYS_REASONING, Capability.FUNCTION_CALLING,
|
||||
Capability.OPTIONAL_REASONING, Capability.FUNCTION_CALLING,
|
||||
Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
@ -121,7 +121,7 @@ public static partial class ProviderExtensions
|
||||
Capability.MULTIPLE_IMAGE_INPUT,
|
||||
Capability.TEXT_OUTPUT,
|
||||
|
||||
Capability.ALWAYS_REASONING, Capability.FUNCTION_CALLING,
|
||||
Capability.OPTIONAL_REASONING, Capability.FUNCTION_CALLING,
|
||||
Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
@ -158,6 +158,22 @@ public static partial class ProviderExtensions
|
||||
Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
|
||||
// Mistral medium 3.5:
|
||||
if (modelName.IndexOf("mistral-medium-3.5") is not -1)
|
||||
return
|
||||
[
|
||||
Capability.TEXT_INPUT,
|
||||
Capability.MULTIPLE_IMAGE_INPUT,
|
||||
Capability.TEXT_OUTPUT,
|
||||
|
||||
Capability.OPTIONAL_REASONING,
|
||||
|
||||
Capability.FUNCTION_CALLING,
|
||||
Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
|
||||
|
||||
if (modelName.IndexOf("mistral-3") is not -1 ||
|
||||
modelName.IndexOf("mistral-large-3") is not -1)
|
||||
return
|
||||
@ -357,4 +373,4 @@ public static partial class ProviderExtensions
|
||||
Capability.CHAT_COMPLETION_API,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
516
app/MindWork AI Studio/Settings/ProviderExtensions.Reasoning.cs
Normal file
516
app/MindWork AI Studio/Settings/ProviderExtensions.Reasoning.cs
Normal file
@ -0,0 +1,516 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
using Host = AIStudio.Provider.SelfHosted.Host;
|
||||
|
||||
namespace AIStudio.Settings;
|
||||
|
||||
public static partial class ProviderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The reasoning-related intent found in the configured additional API parameters.
|
||||
/// </summary>
|
||||
private enum ReasoningConfigurationState
|
||||
{
|
||||
/// <summary>
|
||||
/// No recognized reasoning parameter was found.
|
||||
/// </summary>
|
||||
NOT_CONFIGURED,
|
||||
|
||||
/// <summary>
|
||||
/// A recognized reasoning parameter explicitly enables reasoning.
|
||||
/// </summary>
|
||||
EXPLICITLY_ENABLED,
|
||||
|
||||
/// <summary>
|
||||
/// A recognized reasoning parameter explicitly disables reasoning.
|
||||
/// </summary>
|
||||
EXPLICITLY_DISABLED,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the effective reasoning indicator state for the configured provider instance.
|
||||
/// </summary>
|
||||
/// <param name="provider">The configured provider.</param>
|
||||
/// <returns>The effective reasoning indicator state.</returns>
|
||||
/// <remarks>
|
||||
/// This combines static model capabilities with per-provider additional API parameters.
|
||||
/// For default-on models, an explicit disabling parameter hides the icon; for optional
|
||||
/// models, an explicit enabling parameter is required before the icon is shown.
|
||||
/// </remarks>
|
||||
public static ReasoningIndicatorState GetReasoningIndicatorState(this Provider provider)
|
||||
{
|
||||
var capabilities = provider.GetModelCapabilities();
|
||||
if (capabilities.Contains(Capability.ALWAYS_REASONING))
|
||||
return ReasoningIndicatorState.ALWAYS_ON;
|
||||
|
||||
var reasoningConfigurationState = GetReasoningConfigurationState(provider);
|
||||
if (capabilities.Contains(Capability.REASONING_BY_DEFAULT))
|
||||
{
|
||||
return reasoningConfigurationState switch
|
||||
{
|
||||
ReasoningConfigurationState.EXPLICITLY_DISABLED => ReasoningIndicatorState.NONE,
|
||||
ReasoningConfigurationState.EXPLICITLY_ENABLED => ReasoningIndicatorState.CONFIGURED,
|
||||
_ => ReasoningIndicatorState.DEFAULT_ON,
|
||||
};
|
||||
}
|
||||
|
||||
if (capabilities.Contains(Capability.OPTIONAL_REASONING) &&
|
||||
reasoningConfigurationState is ReasoningConfigurationState.EXPLICITLY_ENABLED)
|
||||
return ReasoningIndicatorState.CONFIGURED;
|
||||
|
||||
return ReasoningIndicatorState.NONE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse additional API parameters and dispatch them to provider-specific reasoning detectors.
|
||||
/// </summary>
|
||||
/// <param name="provider">The configured provider whose additional API parameters should be inspected.</param>
|
||||
/// <returns>The explicit reasoning configuration state, or <see cref="ReasoningConfigurationState.NOT_CONFIGURED"/> if nothing known was found.</returns>
|
||||
private static ReasoningConfigurationState GetReasoningConfigurationState(Provider provider)
|
||||
{
|
||||
if (!AdditionalApiParametersParser.TryParse(provider.AdditionalJsonApiParameters, out var parameters, out _))
|
||||
return ReasoningConfigurationState.NOT_CONFIGURED;
|
||||
|
||||
return provider.UsedLLMProvider switch
|
||||
{
|
||||
LLMProviders.OPEN_AI => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetReasoningEffortState(parameters)),
|
||||
|
||||
LLMProviders.ANTHROPIC => GetAnthropicReasoningState(parameters),
|
||||
|
||||
LLMProviders.MISTRAL or LLMProviders.PERPLEXITY => GetReasoningEffortState(parameters),
|
||||
|
||||
LLMProviders.GOOGLE => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetGoogleReasoningState(parameters)),
|
||||
|
||||
LLMProviders.ALIBABA_CLOUD => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetQwenReasoningState(parameters)),
|
||||
|
||||
LLMProviders.OPEN_ROUTER or
|
||||
LLMProviders.X or
|
||||
LLMProviders.DEEP_SEEK or
|
||||
LLMProviders.GROQ or
|
||||
LLMProviders.FIREWORKS or
|
||||
LLMProviders.HUGGINGFACE or
|
||||
LLMProviders.HELMHOLTZ or
|
||||
LLMProviders.GWDG => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetReasoningEffortState(parameters),
|
||||
GetQwenReasoningState(parameters),
|
||||
GetGoogleReasoningState(parameters)),
|
||||
|
||||
LLMProviders.SELF_HOSTED => provider.Host switch
|
||||
{
|
||||
Host.OLLAMA => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetOllamaReasoningState(parameters),
|
||||
GetQwenReasoningState(parameters)),
|
||||
|
||||
Host.LLAMA_CPP => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetLlamaCppReasoningState(parameters),
|
||||
GetQwenReasoningState(parameters)),
|
||||
|
||||
Host.VLLM => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetReasoningEffortState(parameters),
|
||||
GetVllmReasoningState(parameters),
|
||||
GetQwenReasoningState(parameters),
|
||||
GetGoogleReasoningState(parameters)),
|
||||
|
||||
_ => MergeReasoningStates(
|
||||
GetOpenAICompatibleReasoningState(parameters),
|
||||
GetReasoningEffortState(parameters),
|
||||
GetQwenReasoningState(parameters),
|
||||
GetGoogleReasoningState(parameters)),
|
||||
},
|
||||
|
||||
_ => ReasoningConfigurationState.NOT_CONFIGURED,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect OpenAI-compatible reasoning parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// OpenAI-compatible providers commonly use a nested <c>reasoning</c> object and/or
|
||||
/// a top-level <c>reasoning_effort</c> parameter.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetOpenAICompatibleReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
var reasoningState = ReasoningConfigurationState.NOT_CONFIGURED;
|
||||
if (TryGetParameter(parameters, "reasoning", out var reasoning))
|
||||
{
|
||||
reasoningState = reasoning switch
|
||||
{
|
||||
IDictionary<string, object> reasoningObject when TryGetParameter(reasoningObject, "effort", out var effort) => GetLevelState(effort),
|
||||
IDictionary<string, object> reasoningObject when TryGetParameter(reasoningObject, "summary", out var summary) => GetLevelState(summary),
|
||||
IDictionary<string, object> => ReasoningConfigurationState.NOT_CONFIGURED,
|
||||
_ => GetLevelState(reasoning),
|
||||
};
|
||||
}
|
||||
|
||||
return MergeReasoningStates(reasoningState, GetReasoningEffortState(parameters));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect a top-level <c>reasoning_effort</c> parameter.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
private static ReasoningConfigurationState GetReasoningEffortState(IDictionary<string, object> parameters)
|
||||
{
|
||||
return TryGetParameter(parameters, "reasoning_effort", out var reasoningEffort)
|
||||
? GetLevelState(reasoningEffort)
|
||||
: ReasoningConfigurationState.NOT_CONFIGURED;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect Anthropic extended-thinking parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
private static ReasoningConfigurationState GetAnthropicReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
if (!TryGetParameter(parameters, "thinking", out var thinking))
|
||||
return ReasoningConfigurationState.NOT_CONFIGURED;
|
||||
|
||||
return thinking switch
|
||||
{
|
||||
IDictionary<string, object> thinkingObject when TryGetParameter(thinkingObject, "type", out var type) => GetAnthropicThinkingTypeState(type),
|
||||
_ => GetLevelState(thinking),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect Google Gemini thinking parameters across OpenAI-compatible additional parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// Google can expose thinking options through <c>thinking_config</c>,
|
||||
/// <c>generation_config.thinking_config</c>, <c>thinking_level</c>, and summary settings.
|
||||
/// Summary settings only prove that thinking is enabled when they request summaries;
|
||||
/// disabling summaries does not necessarily disable reasoning.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetGoogleReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
var states = new List<ReasoningConfigurationState>();
|
||||
|
||||
if (TryGetParameter(parameters, "thinking_config", out var thinkingConfig) &&
|
||||
thinkingConfig is IDictionary<string, object> thinkingConfigObject)
|
||||
states.Add(GetGoogleThinkingConfigState(thinkingConfigObject));
|
||||
|
||||
if (TryGetParameter(parameters, "generation_config", out var generationConfig) &&
|
||||
generationConfig is IDictionary<string, object> generationConfigObject)
|
||||
{
|
||||
if (TryGetParameter(generationConfigObject, "thinking_config", out var nestedThinkingConfig) &&
|
||||
nestedThinkingConfig is IDictionary<string, object> nestedThinkingConfigObject)
|
||||
states.Add(GetGoogleThinkingConfigState(nestedThinkingConfigObject));
|
||||
|
||||
if (TryGetParameter(generationConfigObject, "thinking_summaries", out var thinkingSummaries))
|
||||
states.Add(GetThinkingSummariesState(thinkingSummaries));
|
||||
|
||||
if (TryGetParameter(generationConfigObject, "thinking_level", out var thinkingLevel))
|
||||
states.Add(GetLevelState(thinkingLevel));
|
||||
}
|
||||
|
||||
if (TryGetParameter(parameters, "thinking_summaries", out var topLevelThinkingSummaries))
|
||||
states.Add(GetThinkingSummariesState(topLevelThinkingSummaries));
|
||||
|
||||
if (TryGetParameter(parameters, "thinking_level", out var topLevelThinkingLevel))
|
||||
states.Add(GetLevelState(topLevelThinkingLevel));
|
||||
|
||||
return MergeReasoningStates(states);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect Google Gemini thinking-budget and include-thoughts settings.
|
||||
/// </summary>
|
||||
/// <param name="thinkingConfig">The parsed <c>thinking_config</c> object.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
private static ReasoningConfigurationState GetGoogleThinkingConfigState(IDictionary<string, object> thinkingConfig)
|
||||
{
|
||||
var states = new List<ReasoningConfigurationState>();
|
||||
|
||||
if (TryGetParameter(thinkingConfig, "thinking_budget", out var thinkingBudget) ||
|
||||
TryGetParameter(thinkingConfig, "thinkingBudget", out thinkingBudget))
|
||||
states.Add(GetBudgetState(thinkingBudget));
|
||||
|
||||
if (TryGetParameter(thinkingConfig, "include_thoughts", out var includeThoughts) ||
|
||||
TryGetParameter(thinkingConfig, "includeThoughts", out includeThoughts))
|
||||
states.Add(GetLevelState(includeThoughts));
|
||||
|
||||
return MergeReasoningStates(states);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect Google Gemini thinking-summary values that imply reasoning is active.
|
||||
/// </summary>
|
||||
/// <param name="value">The configured thinking-summary value.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// A disabled or missing summary does not prove that thinking is disabled, so only
|
||||
/// known enabling values are treated as explicit reasoning configuration.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetThinkingSummariesState(object? value) => value switch
|
||||
{
|
||||
string text when text.Equals("auto", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("on", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("summarized", StringComparison.OrdinalIgnoreCase)
|
||||
=> ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
|
||||
true => ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
_ => ReasoningConfigurationState.NOT_CONFIGURED,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Detect Ollama's <c>think</c> parameter.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
private static ReasoningConfigurationState GetOllamaReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
return TryGetParameter(parameters, "think", out var think)
|
||||
? GetLevelState(think)
|
||||
: ReasoningConfigurationState.NOT_CONFIGURED;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect llama.cpp server reasoning parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// llama.cpp exposes runtime reasoning control through parameters such as
|
||||
/// <c>reasoning</c>, <c>reasoning_budget</c>, and template-specific kwargs.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetLlamaCppReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
var states = new List<ReasoningConfigurationState>();
|
||||
|
||||
if (TryGetParameter(parameters, "reasoning", out var reasoning))
|
||||
states.Add(GetLlamaCppReasoningModeState(reasoning));
|
||||
|
||||
if (TryGetParameter(parameters, "reasoning_budget", out var reasoningBudget))
|
||||
states.Add(GetBudgetState(reasoningBudget));
|
||||
|
||||
if (TryGetParameter(parameters, "chat_template_kwargs", out var chatTemplateKwargs) &&
|
||||
chatTemplateKwargs is IDictionary<string, object> chatTemplateKwargsObject)
|
||||
states.Add(GetQwenReasoningState(chatTemplateKwargsObject));
|
||||
|
||||
return MergeReasoningStates(states);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect vLLM reasoning parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// vLLM supports both top-level reasoning fields and chat-template kwargs, depending
|
||||
/// on model family and reasoning parser configuration.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetVllmReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
var states = new List<ReasoningConfigurationState>();
|
||||
|
||||
if (TryGetParameter(parameters, "thinking_token_budget", out var thinkingTokenBudget))
|
||||
states.Add(GetBudgetState(thinkingTokenBudget));
|
||||
|
||||
if (TryGetParameter(parameters, "chat_template_kwargs", out var chatTemplateKwargs) &&
|
||||
chatTemplateKwargs is IDictionary<string, object> chatTemplateKwargsObject)
|
||||
{
|
||||
states.Add(GetQwenReasoningState(chatTemplateKwargsObject));
|
||||
|
||||
if (TryGetParameter(chatTemplateKwargsObject, "thinking", out var thinking))
|
||||
states.Add(GetLevelState(thinking));
|
||||
}
|
||||
|
||||
return MergeReasoningStates(states);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect Qwen-style <c>enable_thinking</c> parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed additional API parameters.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// Some OpenAI-compatible servers accept <c>enable_thinking</c> either at the
|
||||
/// top level or under <c>chat_template_kwargs</c>.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetQwenReasoningState(IDictionary<string, object> parameters)
|
||||
{
|
||||
var states = new List<ReasoningConfigurationState>();
|
||||
|
||||
if (TryGetParameter(parameters, "enable_thinking", out var enableThinking))
|
||||
states.Add(GetLevelState(enableThinking));
|
||||
|
||||
if (TryGetParameter(parameters, "chat_template_kwargs", out var chatTemplateKwargs) &&
|
||||
chatTemplateKwargs is IDictionary<string, object> chatTemplateKwargsObject &&
|
||||
TryGetParameter(chatTemplateKwargsObject, "enable_thinking", out var nestedEnableThinking))
|
||||
states.Add(GetLevelState(nestedEnableThinking));
|
||||
|
||||
return MergeReasoningStates(states);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interpret Anthropic's <c>thinking.type</c> value.
|
||||
/// </summary>
|
||||
/// <param name="value">The configured Anthropic thinking type.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
private static ReasoningConfigurationState GetAnthropicThinkingTypeState(object? value) => value switch
|
||||
{
|
||||
string text when text.Equals("enabled", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("adaptive", StringComparison.OrdinalIgnoreCase)
|
||||
=> ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
|
||||
string text when IsDisabledText(text) => ReasoningConfigurationState.EXPLICITLY_DISABLED,
|
||||
_ => GetLevelState(value),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Interpret llama.cpp's <c>reasoning</c> mode value.
|
||||
/// </summary>
|
||||
/// <param name="value">The configured llama.cpp reasoning mode.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// <c>auto</c> means the server decides from the model/template, so it is treated as
|
||||
/// not configured by the user rather than as explicitly enabled.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetLlamaCppReasoningModeState(object? value) => value switch
|
||||
{
|
||||
string text when text.Equals("on", StringComparison.OrdinalIgnoreCase) => ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
string text when text.Equals("off", StringComparison.OrdinalIgnoreCase) => ReasoningConfigurationState.EXPLICITLY_DISABLED,
|
||||
string text when text.Equals("auto", StringComparison.OrdinalIgnoreCase) => ReasoningConfigurationState.NOT_CONFIGURED,
|
||||
_ => GetLevelState(value),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Interpret token-budget style values used by several providers.
|
||||
/// </summary>
|
||||
/// <param name="value">The configured budget value.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
/// <remarks>
|
||||
/// A zero budget disables reasoning; non-zero values, including unrestricted negative
|
||||
/// budgets, indicate that reasoning is available for the request.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState GetBudgetState(object? value) => value switch
|
||||
{
|
||||
int i => i is 0 ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
long l => l is 0 ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
double d => Math.Abs(d) < double.Epsilon ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
decimal m => m is 0 ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
_ => GetLevelState(value),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Interpret common boolean, numeric, and level-style reasoning values.
|
||||
/// </summary>
|
||||
/// <param name="value">The raw parsed parameter value.</param>
|
||||
/// <returns>The detected reasoning configuration state.</returns>
|
||||
private static ReasoningConfigurationState GetLevelState(object? value) => value switch
|
||||
{
|
||||
bool booleanValue => booleanValue ? ReasoningConfigurationState.EXPLICITLY_ENABLED : ReasoningConfigurationState.EXPLICITLY_DISABLED,
|
||||
int i => i is 0 ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
long l => l is 0 ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
double d => Math.Abs(d) < double.Epsilon ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
decimal m => m is 0 ? ReasoningConfigurationState.EXPLICITLY_DISABLED : ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
string text when IsDisabledText(text) => ReasoningConfigurationState.EXPLICITLY_DISABLED,
|
||||
string text when IsEnabledText(text) => ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
||||
_ => ReasoningConfigurationState.NOT_CONFIGURED,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether a string value is a known reasoning-enabling value.
|
||||
/// </summary>
|
||||
/// <param name="text">The string value to inspect.</param>
|
||||
/// <returns><see langword="true"/> if the value should be treated as enabling reasoning.</returns>
|
||||
private static bool IsEnabledText(string text)
|
||||
{
|
||||
return text.Equals("true", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("yes", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("on", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("enabled", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("low", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("minimal", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("medium", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("high", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("max", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether a string value is a known reasoning-disabling value.
|
||||
/// </summary>
|
||||
/// <param name="text">The string value to inspect.</param>
|
||||
/// <returns><see langword="true"/> if the value should be treated as disabling reasoning.</returns>
|
||||
private static bool IsDisabledText(string text)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(text) ||
|
||||
text.Equals("false", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("no", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("off", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("none", StringComparison.OrdinalIgnoreCase) ||
|
||||
text.Equals("disabled", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merge multiple detected reasoning states into a single state.
|
||||
/// </summary>
|
||||
/// <param name="states">The detected states from provider-specific parameter checks.</param>
|
||||
/// <returns>The merged state.</returns>
|
||||
/// <remarks>
|
||||
/// Explicit disabling wins over enabling because user-provided off switches should
|
||||
/// suppress default-on reasoning indicators.
|
||||
/// </remarks>
|
||||
private static ReasoningConfigurationState MergeReasoningStates(IEnumerable<ReasoningConfigurationState> states)
|
||||
{
|
||||
var result = ReasoningConfigurationState.NOT_CONFIGURED;
|
||||
foreach (var state in states)
|
||||
{
|
||||
if (state is ReasoningConfigurationState.EXPLICITLY_DISABLED)
|
||||
return ReasoningConfigurationState.EXPLICITLY_DISABLED;
|
||||
|
||||
if (state is ReasoningConfigurationState.EXPLICITLY_ENABLED)
|
||||
result = ReasoningConfigurationState.EXPLICITLY_ENABLED;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merge multiple detected reasoning states into a single state.
|
||||
/// </summary>
|
||||
/// <param name="states">The detected states from provider-specific parameter checks.</param>
|
||||
/// <returns>The merged state.</returns>
|
||||
private static ReasoningConfigurationState MergeReasoningStates(params ReasoningConfigurationState[] states)
|
||||
{
|
||||
return MergeReasoningStates(states.AsEnumerable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to read a parameter from a dictionary using case-insensitive key matching.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parsed parameter dictionary.</param>
|
||||
/// <param name="key">The parameter name to find.</param>
|
||||
/// <param name="value">The matched parameter value, if found.</param>
|
||||
/// <returns><see langword="true"/> if a matching key was found; otherwise <see langword="false"/>.</returns>
|
||||
private static bool TryGetParameter(IDictionary<string, object> parameters, string key, out object? value)
|
||||
{
|
||||
value = null;
|
||||
if (parameters.Count is 0)
|
||||
return false;
|
||||
|
||||
var foundKey = parameters.Keys.FirstOrDefault(k => string.Equals(k, key, StringComparison.OrdinalIgnoreCase));
|
||||
if (foundKey is null)
|
||||
return false;
|
||||
|
||||
value = parameters[foundKey];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,11 @@ public static partial class ProviderExtensions
|
||||
/// </summary>
|
||||
/// <param name="provider">The configured provider.</param>
|
||||
/// <returns>The capabilities of the configured model.</returns>
|
||||
public static List<Capability> GetModelCapabilities(this Provider provider) => provider.UsedLLMProvider.GetModelCapabilities(provider.Model);
|
||||
public static List<Capability> GetModelCapabilities(this Provider provider)
|
||||
{
|
||||
var automaticCapabilities = provider.UsedLLMProvider.GetModelCapabilities(provider.Model);
|
||||
return provider.CapabilityOverrides?.ApplyTo(automaticCapabilities) ?? automaticCapabilities;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the capabilities of a model for a specific provider.
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Identifies one logical assistant session slot.
|
||||
/// </summary>
|
||||
public readonly record struct AssistantSessionKey
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new assistant session key.
|
||||
/// </summary>
|
||||
/// <param name="component">The application component the assistant belongs to.</param>
|
||||
/// <param name="instanceId">The assistant-specific instance ID, such as a component type or plugin ID.</param>
|
||||
public AssistantSessionKey(Components component, string instanceId)
|
||||
{
|
||||
this.Component = component;
|
||||
this.InstanceId = instanceId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application component the assistant belongs to.
|
||||
/// </summary>
|
||||
public Components Component { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assistant-specific instance ID, such as a component type or plugin ID.
|
||||
/// </summary>
|
||||
public string InstanceId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts the key into a compact diagnostic string.
|
||||
/// </summary>
|
||||
/// <returns>The component and instance ID joined by a colon.</returns>
|
||||
public override string ToString() => $"{this.Component}:{this.InstanceId}";
|
||||
}
|
||||
@ -0,0 +1,365 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using AIStudio.Chat;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Keeps assistant sessions alive while their Blazor components are not mounted.
|
||||
/// </summary>
|
||||
/// <param name="messageBus">The message bus used to publish assistant session changes.</param>
|
||||
public sealed class AssistantSessionService(MessageBus messageBus)
|
||||
{
|
||||
/// <summary>
|
||||
/// Mutable runtime state owned exclusively by <see cref="AssistantSessionService"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This type intentionally exists in addition to <see cref="AssistantSessionSnapshot"/>.
|
||||
/// It holds runtime-only data such as the cancellation token source and lock, while
|
||||
/// snapshots are copied DTOs for UI components and message bus payloads.
|
||||
/// </remarks>
|
||||
private sealed class AssistantSessionState
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies this concrete run of an assistant session.
|
||||
/// </summary>
|
||||
public required Guid SessionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the assistant and logical session slot this run belongs to.
|
||||
/// </summary>
|
||||
public required AssistantSessionKey Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the active assistant run.
|
||||
/// </summary>
|
||||
public required CancellationTokenSource CancellationTokenSource { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores when the session run started.
|
||||
/// </summary>
|
||||
public required DateTimeOffset StartedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores when the session state was last changed.
|
||||
/// </summary>
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores when the session reached a terminal state.
|
||||
/// </summary>
|
||||
public DateTimeOffset? FinishedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores the user-visible assistant title.
|
||||
/// </summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the current lifecycle state of the session.
|
||||
/// </summary>
|
||||
public AssistantSessionStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores the user-visible error message for failed sessions.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the current assistant chat thread, including streamed output.
|
||||
/// </summary>
|
||||
public ChatThread? ChatThread { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores the assistant component state captured from the running UI instance.
|
||||
/// </summary>
|
||||
public Dictionary<string, IAssistantSessionSnapshotField> State { get; set; } = new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Guards mutable fields while snapshots are created or updates are applied.
|
||||
/// </summary>
|
||||
public readonly Lock SyncRoot = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores one assistant session per session key.
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<AssistantSessionKey, AssistantSessionState> sessions = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether at least one assistant session is still active.
|
||||
/// </summary>
|
||||
public bool HasActiveSessions => this.sessions.Values.Any(session => session.Status is AssistantSessionStatus.RUNNING or AssistantSessionStatus.CANCELING);
|
||||
|
||||
/// <summary>
|
||||
/// Gets copied snapshots for all known assistant sessions.
|
||||
/// </summary>
|
||||
/// <returns>Session snapshots ordered by newest update first.</returns>
|
||||
public IReadOnlyCollection<AssistantSessionSnapshot> GetSnapshots()
|
||||
{
|
||||
return this.sessions.Values
|
||||
.Select(CreateSnapshot)
|
||||
.OrderByDescending(snapshot => snapshot.UpdatedAt)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the current snapshot for an assistant session key.
|
||||
/// </summary>
|
||||
/// <param name="key">The assistant session key to look up.</param>
|
||||
/// <returns>The current snapshot, or <c>null</c> when no session exists.</returns>
|
||||
public AssistantSessionSnapshot? TryGetSnapshot(AssistantSessionKey key)
|
||||
{
|
||||
return this.sessions.TryGetValue(key, out var session) ? CreateSnapshot(session) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get and remove an inactive assistant session snapshot.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method intentionally does not publish a change event. It is used when
|
||||
/// a UI instance consumes a finished session exactly once and should keep the
|
||||
/// restored result locally until the user leaves or resets the assistant.
|
||||
/// </remarks>
|
||||
/// <param name="key">The assistant session key to look up and remove.</param>
|
||||
/// <returns>The removed inactive snapshot, or <c>null</c> when no inactive session exists.</returns>
|
||||
public AssistantSessionSnapshot? TryTakeInactiveSnapshot(AssistantSessionKey key)
|
||||
{
|
||||
if (!this.sessions.TryGetValue(key, out var session))
|
||||
return null;
|
||||
|
||||
AssistantSessionSnapshot snapshot;
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
if (session.Status is AssistantSessionStatus.RUNNING or AssistantSessionStatus.CANCELING)
|
||||
return null;
|
||||
|
||||
snapshot = CreateSnapshotWithoutLock(session);
|
||||
}
|
||||
|
||||
return ((ICollection<KeyValuePair<AssistantSessionKey, AssistantSessionState>>)this.sessions).Remove(new(key, session)) ? snapshot : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a new assistant session when no active session exists for the key.
|
||||
/// </summary>
|
||||
/// <param name="key">The assistant session key.</param>
|
||||
/// <param name="title">The user-visible assistant title.</param>
|
||||
/// <param name="cancellationTokenSource">The cancellation token source owned by the new runtime session.</param>
|
||||
/// <param name="chatThread">The current assistant chat thread, if one already exists.</param>
|
||||
/// <param name="state">The initial assistant component state.</param>
|
||||
/// <param name="sendingComponent">The component that initiated the session start.</param>
|
||||
/// <returns>The new session snapshot, or the existing active session snapshot.</returns>
|
||||
public async Task<AssistantSessionSnapshot> TryBeginAsync(AssistantSessionKey key, string title, CancellationTokenSource cancellationTokenSource, ChatThread? chatThread, Dictionary<string, IAssistantSessionSnapshotField> state, ComponentBase? sendingComponent = null)
|
||||
{
|
||||
if (this.sessions.TryGetValue(key, out var existing) && existing.Status is AssistantSessionStatus.RUNNING or AssistantSessionStatus.CANCELING)
|
||||
return CreateSnapshot(existing);
|
||||
|
||||
var now = DateTimeOffset.Now;
|
||||
var session = new AssistantSessionState
|
||||
{
|
||||
SessionId = Guid.NewGuid(),
|
||||
Key = key,
|
||||
CancellationTokenSource = cancellationTokenSource,
|
||||
StartedAt = now,
|
||||
UpdatedAt = now,
|
||||
Title = title,
|
||||
Status = AssistantSessionStatus.RUNNING,
|
||||
ChatThread = chatThread,
|
||||
State = state,
|
||||
};
|
||||
|
||||
this.sessions[key] = session;
|
||||
var snapshot = CreateSnapshot(session);
|
||||
await this.NotifyChangedAsync(session, sendingComponent);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a running assistant session with the latest UI and chat state.
|
||||
/// </summary>
|
||||
/// <param name="key">The assistant session key.</param>
|
||||
/// <param name="sessionId">The concrete run ID that is allowed to write the checkpoint.</param>
|
||||
/// <param name="title">The current user-visible assistant title.</param>
|
||||
/// <param name="chatThread">The current assistant chat thread.</param>
|
||||
/// <param name="state">The current assistant component state.</param>
|
||||
/// <param name="sendingComponent">The component that initiated the checkpoint.</param>
|
||||
public async Task CheckpointAsync(AssistantSessionKey key, Guid sessionId, string title, ChatThread? chatThread, Dictionary<string, IAssistantSessionSnapshotField> state, ComponentBase? sendingComponent = null)
|
||||
{
|
||||
if (!this.sessions.TryGetValue(key, out var session))
|
||||
return;
|
||||
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
if (session.SessionId != sessionId)
|
||||
return;
|
||||
|
||||
session.Title = title;
|
||||
session.ChatThread = chatThread;
|
||||
session.State = state;
|
||||
session.UpdatedAt = DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
await this.NotifyChangedAsync(session, sendingComponent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests cancellation for an active assistant session.
|
||||
/// </summary>
|
||||
/// <param name="key">The assistant session key to cancel.</param>
|
||||
/// <param name="sendingComponent">The component that initiated the cancellation.</param>
|
||||
public async Task CancelAsync(AssistantSessionKey key, ComponentBase? sendingComponent = null)
|
||||
{
|
||||
if (!this.sessions.TryGetValue(key, out var session))
|
||||
return;
|
||||
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
if (session.Status is not AssistantSessionStatus.RUNNING)
|
||||
return;
|
||||
|
||||
session.Status = AssistantSessionStatus.CANCELING;
|
||||
session.UpdatedAt = DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!session.CancellationTokenSource.IsCancellationRequested)
|
||||
await session.CancellationTokenSource.CancelAsync();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await this.NotifyChangedAsync(session, sendingComponent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves an assistant session into a terminal state and publishes completion.
|
||||
/// </summary>
|
||||
/// <param name="key">The assistant session key.</param>
|
||||
/// <param name="sessionId">The concrete run ID that is allowed to complete the session.</param>
|
||||
/// <param name="status">The terminal status to store.</param>
|
||||
/// <param name="errorMessage">The user-visible error message for failed sessions.</param>
|
||||
/// <param name="chatThread">The final assistant chat thread.</param>
|
||||
/// <param name="state">The final assistant component state.</param>
|
||||
/// <param name="sendingComponent">The component that initiated the completion.</param>
|
||||
public async Task CompleteAsync(AssistantSessionKey key, Guid sessionId, AssistantSessionStatus status, string errorMessage, ChatThread? chatThread, Dictionary<string, IAssistantSessionSnapshotField> state, ComponentBase? sendingComponent = null)
|
||||
{
|
||||
if (!this.sessions.TryGetValue(key, out var session))
|
||||
return;
|
||||
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
if (session.SessionId != sessionId)
|
||||
return;
|
||||
|
||||
session.Status = status;
|
||||
session.ErrorMessage = errorMessage;
|
||||
session.ChatThread = chatThread;
|
||||
session.State = state;
|
||||
session.UpdatedAt = DateTimeOffset.Now;
|
||||
session.FinishedAt = session.UpdatedAt;
|
||||
}
|
||||
|
||||
await this.NotifyChangedAsync(session, sendingComponent);
|
||||
await messageBus.SendMessage(sendingComponent, Event.ASSISTANT_SESSION_FINISHED, CreateSnapshot(session));
|
||||
|
||||
try
|
||||
{
|
||||
session.CancellationTokenSource.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears an inactive assistant session.
|
||||
/// </summary>
|
||||
/// <param name="key">The assistant session key to clear.</param>
|
||||
public async Task ClearAsync(AssistantSessionKey key)
|
||||
{
|
||||
if (!this.sessions.TryGetValue(key, out var session))
|
||||
return;
|
||||
|
||||
if (session.Status is AssistantSessionStatus.RUNNING or AssistantSessionStatus.CANCELING)
|
||||
return;
|
||||
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
session.Status = AssistantSessionStatus.NONE;
|
||||
session.ChatThread = null;
|
||||
session.State = new(StringComparer.Ordinal);
|
||||
session.UpdatedAt = DateTimeOffset.Now;
|
||||
session.FinishedAt = session.UpdatedAt;
|
||||
}
|
||||
|
||||
this.sessions.TryRemove(key, out _);
|
||||
await messageBus.SendMessage(null, Event.ASSISTANT_SESSION_CHANGED, CreateSnapshot(session));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all inactive sessions for a component.
|
||||
/// </summary>
|
||||
/// <param name="component">The component whose inactive sessions should be cleared.</param>
|
||||
public async Task ClearInactiveSessionsForComponentAsync(Components component)
|
||||
{
|
||||
var matchingKeys = this.sessions
|
||||
.Where(pair => pair.Key.Component == component && pair.Value.Status is not AssistantSessionStatus.RUNNING and not AssistantSessionStatus.CANCELING)
|
||||
.Select(pair => pair.Key)
|
||||
.ToList();
|
||||
|
||||
foreach (var key in matchingKeys)
|
||||
await this.ClearAsync(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Publishes an assistant session change event.
|
||||
/// </summary>
|
||||
/// <param name="session">The runtime session whose copied snapshot should be published.</param>
|
||||
/// <param name="sendingComponent">The component that initiated the session change.</param>
|
||||
private async Task NotifyChangedAsync(AssistantSessionState session, ComponentBase? sendingComponent = null)
|
||||
{
|
||||
await messageBus.SendMessage(sendingComponent, Event.ASSISTANT_SESSION_CHANGED, CreateSnapshot(session));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copied, external snapshot from the internal runtime state.
|
||||
/// </summary>
|
||||
/// <param name="session">The runtime session to copy.</param>
|
||||
/// <returns>A snapshot safe to send to UI components.</returns>
|
||||
private static AssistantSessionSnapshot CreateSnapshot(AssistantSessionState session)
|
||||
{
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
return CreateSnapshotWithoutLock(session);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copied, external snapshot while the caller already holds the session lock.
|
||||
/// </summary>
|
||||
/// <param name="session">The runtime session to copy.</param>
|
||||
/// <returns>A snapshot safe to send to UI components.</returns>
|
||||
private static AssistantSessionSnapshot CreateSnapshotWithoutLock(AssistantSessionState session)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
SessionId = session.SessionId,
|
||||
Key = session.Key,
|
||||
Title = session.Title,
|
||||
Status = session.Status,
|
||||
StartedAt = session.StartedAt,
|
||||
UpdatedAt = session.UpdatedAt,
|
||||
FinishedAt = session.FinishedAt,
|
||||
ErrorMessage = session.ErrorMessage,
|
||||
ChatThread = session.ChatThread,
|
||||
State = new Dictionary<string, IAssistantSessionSnapshotField>(session.State, StringComparer.Ordinal),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
using AIStudio.Chat;
|
||||
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Immutable-style view of an assistant session for UI consumers and message bus events.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The service creates snapshots by copying its internal runtime state. Consumers must
|
||||
/// treat the contained chat thread and state objects as read-only views of the session.
|
||||
/// </remarks>
|
||||
public sealed record AssistantSessionSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the concrete run represented by this snapshot.
|
||||
/// </summary>
|
||||
public required Guid SessionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the assistant and logical session slot represented by this snapshot.
|
||||
/// </summary>
|
||||
public required AssistantSessionKey Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user-visible assistant title.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current lifecycle status.
|
||||
/// </summary>
|
||||
public required AssistantSessionStatus Status { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets when the session run started.
|
||||
/// </summary>
|
||||
public required DateTimeOffset StartedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets when the session was last changed.
|
||||
/// </summary>
|
||||
public required DateTimeOffset UpdatedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets when the session reached a terminal state.
|
||||
/// </summary>
|
||||
public DateTimeOffset? FinishedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user-visible error message for failed sessions.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assistant chat thread captured for this session.
|
||||
/// </summary>
|
||||
public ChatThread? ChatThread { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assistant component state captured for this session.
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, IAssistantSessionSnapshotField> State { get; init; } = new Dictionary<string, IAssistantSessionSnapshotField>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the session is still running or canceling.
|
||||
/// </summary>
|
||||
public bool IsActive => this.Status is AssistantSessionStatus.RUNNING or AssistantSessionStatus.CANCELING;
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Stores one typed value in an assistant session snapshot.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The captured value type.</typeparam>
|
||||
public sealed record AssistantSessionSnapshotField<T> : IAssistantSessionSnapshotField
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new typed snapshot field.
|
||||
/// </summary>
|
||||
/// <param name="value">The captured value.</param>
|
||||
public AssistantSessionSnapshotField(T value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the captured value.
|
||||
/// </summary>
|
||||
public T Value { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Type ValueType => typeof(T);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryRead<TValue>(out TValue? value)
|
||||
{
|
||||
if (this.Value is TValue typedValue)
|
||||
{
|
||||
value = typedValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.Value is null && default(TValue) is null)
|
||||
{
|
||||
value = default;
|
||||
return true;
|
||||
}
|
||||
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Identifies a typed assistant session state value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The value type stored for this key.</typeparam>
|
||||
public readonly record struct AssistantSessionStateKey<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new assistant session state key.
|
||||
/// </summary>
|
||||
/// <param name="name">The stable dictionary name used in assistant session snapshots.</param>
|
||||
public AssistantSessionStateKey(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the stable dictionary name used in assistant session snapshots.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the stable dictionary name.
|
||||
/// </summary>
|
||||
/// <returns>The stable dictionary name.</returns>
|
||||
public override string ToString() => this.Name;
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Restores typed assistant session state values from a snapshot.
|
||||
/// </summary>
|
||||
/// <param name="fields">The captured snapshot fields.</param>
|
||||
/// <param name="assistantTitle">The user-visible assistant title.</param>
|
||||
public sealed class AssistantSessionStateReader(IReadOnlyDictionary<string, IAssistantSessionSnapshotField> fields, string assistantTitle)
|
||||
{
|
||||
private static readonly ILogger<AssistantSessionStateReader> LOG = Program.LOGGER_FACTORY.CreateLogger<AssistantSessionStateReader>();
|
||||
|
||||
/// <summary>
|
||||
/// Restores a typed value when it exists in the snapshot.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The value type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="apply">The action that applies the restored value.</param>
|
||||
public void Restore<T>(AssistantSessionStateKey<T> key, Action<T> apply)
|
||||
{
|
||||
if (this.TryRead(key, out var value))
|
||||
apply(value!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores a list into an existing list instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The list item type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="target">The existing list to update.</param>
|
||||
public void RestoreList<T>(AssistantSessionStateKey<List<T>> key, List<T> target)
|
||||
{
|
||||
this.Restore(key, values =>
|
||||
{
|
||||
target.Clear();
|
||||
target.AddRange(values);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores a hash set into an existing hash set instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The set item type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="target">The existing hash set to update.</param>
|
||||
public void RestoreHashSet<T>(AssistantSessionStateKey<HashSet<T>> key, HashSet<T> target)
|
||||
{
|
||||
this.Restore(key, values =>
|
||||
{
|
||||
target.Clear();
|
||||
target.UnionWith(values);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores a dictionary into an existing dictionary instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The dictionary key type.</typeparam>
|
||||
/// <typeparam name="TValue">The dictionary value type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="target">The existing dictionary to update.</param>
|
||||
public void RestoreDictionary<TKey, TValue>(AssistantSessionStateKey<Dictionary<TKey, TValue>> key, Dictionary<TKey, TValue> target) where TKey : notnull
|
||||
{
|
||||
this.Restore(key, values =>
|
||||
{
|
||||
target.Clear();
|
||||
foreach (var (itemKey, itemValue) in values)
|
||||
target[itemKey] = itemValue;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores text into an existing string builder instance.
|
||||
/// </summary>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="target">The existing string builder to update.</param>
|
||||
public void RestoreStringBuilder(AssistantSessionStateKey<string> key, StringBuilder target)
|
||||
{
|
||||
this.Restore(key, value =>
|
||||
{
|
||||
target.Clear();
|
||||
target.Append(value);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to read a typed value from the snapshot.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The requested value type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="value">The restored value when reading succeeds.</param>
|
||||
/// <returns><c>true</c> when a value exists and matches the requested type; otherwise, <c>false</c>.</returns>
|
||||
private bool TryRead<T>(AssistantSessionStateKey<T> key, out T? value)
|
||||
{
|
||||
value = default;
|
||||
if (!fields.TryGetValue(key.Name, out var field))
|
||||
return false;
|
||||
|
||||
if (field.TryRead(out value))
|
||||
return true;
|
||||
|
||||
LOG.LogWarning(
|
||||
"Could not restore assistant session field '{FieldStateKey}' for assistant '{AssistantTitle}'. ExpectedType='{ExpectedType}', CapturedValueType='{CapturedValueType}'. The current value is kept.",
|
||||
key.Name,
|
||||
assistantTitle,
|
||||
typeof(T).FullName,
|
||||
field.ValueType.FullName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Collects typed assistant session state values for a snapshot.
|
||||
/// </summary>
|
||||
public sealed class AssistantSessionStateWriter
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores captured fields by their stable dictionary names.
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, IAssistantSessionSnapshotField> fields = new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Stores a typed state value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The value type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="value">The captured value.</param>
|
||||
public void Set<T>(AssistantSessionStateKey<T> key, T value)
|
||||
{
|
||||
this.fields[key.Name] = new AssistantSessionSnapshotField<T>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores a list copy.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The list item type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="values">The values to copy.</param>
|
||||
public void SetList<T>(AssistantSessionStateKey<List<T>> key, IEnumerable<T> values)
|
||||
{
|
||||
this.Set(key, values.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores a hash set copy.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The set item type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="values">The values to copy.</param>
|
||||
public void SetHashSet<T>(AssistantSessionStateKey<HashSet<T>> key, IEnumerable<T> values)
|
||||
{
|
||||
this.Set(key, values.ToHashSet());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores a dictionary copy.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The dictionary key type.</typeparam>
|
||||
/// <typeparam name="TValue">The dictionary value type.</typeparam>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="values">The values to copy.</param>
|
||||
public void SetDictionary<TKey, TValue>(AssistantSessionStateKey<Dictionary<TKey, TValue>> key, IDictionary<TKey, TValue> values) where TKey : notnull
|
||||
{
|
||||
this.Set(key, new Dictionary<TKey, TValue>(values));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the current text from a string builder.
|
||||
/// </summary>
|
||||
/// <param name="key">The typed state key.</param>
|
||||
/// <param name="value">The string builder to read.</param>
|
||||
public void SetStringBuilder(AssistantSessionStateKey<string> key, StringBuilder value)
|
||||
{
|
||||
this.Set(key, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the captured fields as a dictionary.
|
||||
/// </summary>
|
||||
/// <returns>A copied dictionary containing the captured fields.</returns>
|
||||
public Dictionary<string, IAssistantSessionSnapshotField> ToDictionary()
|
||||
{
|
||||
return new(this.fields, StringComparer.Ordinal);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Describes the lifecycle state of an assistant session.
|
||||
/// </summary>
|
||||
public enum AssistantSessionStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// No session state is available.
|
||||
/// </summary>
|
||||
NONE,
|
||||
|
||||
/// <summary>
|
||||
/// The assistant session is running.
|
||||
/// </summary>
|
||||
RUNNING,
|
||||
|
||||
/// <summary>
|
||||
/// Cancellation was requested and the assistant is shutting down.
|
||||
/// </summary>
|
||||
CANCELING,
|
||||
|
||||
/// <summary>
|
||||
/// The assistant session completed successfully.
|
||||
/// </summary>
|
||||
COMPLETED,
|
||||
|
||||
/// <summary>
|
||||
/// The assistant session was canceled.
|
||||
/// </summary>
|
||||
CANCELED,
|
||||
|
||||
/// <summary>
|
||||
/// The assistant session failed.
|
||||
/// </summary>
|
||||
FAILED,
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
namespace AIStudio.Tools.AssistantSessions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a typed value stored in an assistant session snapshot.
|
||||
/// </summary>
|
||||
public interface IAssistantSessionSnapshotField
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type used when the value was captured.
|
||||
/// </summary>
|
||||
Type ValueType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Tries to read the captured value as the requested type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The requested value type.</typeparam>
|
||||
/// <param name="value">The typed value when reading succeeds.</param>
|
||||
/// <returns><c>true</c> when the captured value matches <typeparamref name="T"/>; otherwise, <c>false</c>.</returns>
|
||||
bool TryRead<T>(out T? value);
|
||||
}
|
||||
@ -31,12 +31,27 @@ public static class CommonTools
|
||||
if (string.IsNullOrWhiteSpace(ietfTag))
|
||||
return CultureInfo.InvariantCulture;
|
||||
|
||||
var normalizedTag = ietfTag.Trim().Replace('_', '-');
|
||||
|
||||
try
|
||||
{
|
||||
return CultureInfo.GetCultureInfo(ietfTag);
|
||||
return CultureInfo.GetCultureInfo(normalizedTag);
|
||||
}
|
||||
catch (CultureNotFoundException)
|
||||
{
|
||||
var separatorIndex = normalizedTag.IndexOf('-');
|
||||
if (separatorIndex > 0)
|
||||
{
|
||||
var neutralLanguageTag = normalizedTag[..separatorIndex];
|
||||
try
|
||||
{
|
||||
return CultureInfo.GetCultureInfo(neutralLanguageTag);
|
||||
}
|
||||
catch (CultureNotFoundException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return CultureInfo.InvariantCulture;
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,6 +144,16 @@ public enum Event
|
||||
/// Notifies receivers that chat generation state changed.
|
||||
/// </summary>
|
||||
CHAT_GENERATION_CHANGED,
|
||||
|
||||
/// <summary>
|
||||
/// Notifies receivers that an assistant session changed.
|
||||
/// </summary>
|
||||
ASSISTANT_SESSION_CHANGED,
|
||||
|
||||
/// <summary>
|
||||
/// Notifies receivers that an assistant session finished.
|
||||
/// </summary>
|
||||
ASSISTANT_SESSION_FINISHED,
|
||||
|
||||
// Workspace events:
|
||||
/// <summary>
|
||||
|
||||
@ -10,6 +10,12 @@ public static class Markdown
|
||||
.DisableHtml()
|
||||
.Build();
|
||||
|
||||
public static readonly MarkdownPipeline CHAT_MARKDOWN_PIPELINE = new MarkdownPipelineBuilder()
|
||||
.UseAdvancedExtensions()
|
||||
.UseSoftlineBreakAsHardlineBreak()
|
||||
.DisableHtml()
|
||||
.Build();
|
||||
|
||||
public static MudMarkdownProps DefaultConfig => new()
|
||||
{
|
||||
Heading =
|
||||
|
||||
@ -9,4 +9,14 @@ public static class MudThemeExtensions
|
||||
true => theme.PaletteDark,
|
||||
false => theme.PaletteLight,
|
||||
};
|
||||
|
||||
public static string GetActivityIndicatorColor(this MudTheme theme, SettingsManager settingsManager) => settingsManager.IsDarkMode switch
|
||||
{
|
||||
true => theme.GetActivityIndicatorDarkColor(),
|
||||
false => theme.GetActivityIndicatorLightColor(),
|
||||
};
|
||||
|
||||
public static string GetActivityIndicatorLightColor(this MudTheme theme) => theme.PaletteLight.Info.Value;
|
||||
|
||||
public static string GetActivityIndicatorDarkColor(this MudTheme theme) => theme.PaletteDark.InfoLighten;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants;
|
||||
|
||||
public enum AssistantPluginLaunchBehavior
|
||||
{
|
||||
NONE,
|
||||
OPEN_WORKSPACE_CHAT_BY_NAME,
|
||||
}
|
||||
@ -30,6 +30,49 @@ public sealed class AssistantState
|
||||
this.Times.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies all dynamic assistant state values from another state instance.
|
||||
/// </summary>
|
||||
/// <param name="other">The state instance to copy from.</param>
|
||||
public void CopyFrom(AssistantState other)
|
||||
{
|
||||
this.Clear();
|
||||
CopyDictionary(other.Text, this.Text);
|
||||
CopyDictionary(other.SingleSelect, this.SingleSelect);
|
||||
CopyDictionary(other.MultiSelect, this.MultiSelect);
|
||||
CopyDictionary(other.Booleans, this.Booleans);
|
||||
CopyDictionary(other.WebContent, this.WebContent);
|
||||
CopyDictionary(other.FileContent, this.FileContent);
|
||||
CopyDictionary(other.Colors, this.Colors);
|
||||
CopyDictionary(other.Dates, this.Dates);
|
||||
CopyDictionary(other.DateRanges, this.DateRanges);
|
||||
CopyDictionary(other.Times, this.Times);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of the dynamic assistant state.
|
||||
/// </summary>
|
||||
/// <returns>A copied assistant state instance.</returns>
|
||||
public AssistantState Clone()
|
||||
{
|
||||
var clone = new AssistantState();
|
||||
clone.CopyFrom(this);
|
||||
return clone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies all entries from one dictionary into another dictionary.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The dictionary key type.</typeparam>
|
||||
/// <typeparam name="TValue">The dictionary value type.</typeparam>
|
||||
/// <param name="source">The source dictionary.</param>
|
||||
/// <param name="target">The target dictionary.</param>
|
||||
private static void CopyDictionary<TKey, TValue>(Dictionary<TKey, TValue> source, Dictionary<TKey, TValue> target) where TKey : notnull
|
||||
{
|
||||
foreach (var (key, value) in source)
|
||||
target[key] = value;
|
||||
}
|
||||
|
||||
public bool TryApplyValue(string fieldName, LuaValue value, out string expectedType)
|
||||
{
|
||||
expectedType = string.Empty;
|
||||
|
||||
@ -8,6 +8,8 @@ public static class PluginAssistantSecurityResolver
|
||||
{
|
||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(PluginAssistantSecurityResolver).Namespace, nameof(PluginAssistantSecurityResolver));
|
||||
|
||||
private static string NormalizeHash(string hash) => string.IsNullOrWhiteSpace(hash) ? string.Empty : hash.Trim().ToUpperInvariant();
|
||||
|
||||
private static string GetAvailabilityLabel(bool requiresAudit, bool hasAudit, bool hasHashMismatch, bool isBlocked, bool canOverride)
|
||||
{
|
||||
if (hasHashMismatch)
|
||||
@ -75,10 +77,55 @@ public static class PluginAssistantSecurityResolver
|
||||
var auditSettings = settingsManager.ConfigurationData.AssistantPluginAudit;
|
||||
var enforceAuditBeforeActivation = auditSettings.RequireAuditBeforeActivation;
|
||||
var isEnforcementDisabled = !enforceAuditBeforeActivation;
|
||||
var currentHash = plugin.ComputeAuditHash();
|
||||
var currentHash = NormalizeHash(plugin.ComputeAuditHash());
|
||||
var enterpriseApproval = auditSettings.EnterpriseApprovedPlugins
|
||||
.FirstOrDefault(x => string.Equals(NormalizeHash(x.PluginHash), currentHash, StringComparison.Ordinal));
|
||||
|
||||
if (enterpriseApproval is not null)
|
||||
{
|
||||
var enterpriseHeadline = string.IsNullOrWhiteSpace(enterpriseApproval.DisplayName)
|
||||
? TB("This assistant was approved by your organization.")
|
||||
: string.Format(TB("This assistant was approved by your organization as '{0}'."), enterpriseApproval.DisplayName);
|
||||
|
||||
return new PluginAssistantSecurityState
|
||||
{
|
||||
Plugin = plugin,
|
||||
Audit = null,
|
||||
EnterpriseApproval = enterpriseApproval,
|
||||
Settings = auditSettings,
|
||||
Source = PluginAssistantSecurityStatusSource.ENTERPRISE_APPROVAL,
|
||||
CurrentHash = currentHash,
|
||||
HashMatches = true,
|
||||
HasHashMismatch = false,
|
||||
IsBelowMinimum = false,
|
||||
MeetsMinimumLevel = true,
|
||||
RequiresAudit = false,
|
||||
IsBlocked = false,
|
||||
CanOverride = false,
|
||||
CanActivatePlugin = true,
|
||||
CanStartAssistant = true,
|
||||
AuditLabel = TB("Safe"),
|
||||
AuditColor = AssistantAuditLevel.SAFE.GetColor(),
|
||||
AuditIcon = AssistantAuditLevel.SAFE.GetIcon(),
|
||||
AvailabilityLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit: true, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
AvailabilityColor = GetAvailabilityColor(requiresAudit: false, hasAudit: true, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
AvailabilityIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit: true, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
StatusLabel = TB("Unlocked"),
|
||||
SourceLabel = TB("Approved by your organization"),
|
||||
SourceColor = Color.Success,
|
||||
SourceIcon = MudBlazor.Icons.Material.Filled.Business,
|
||||
BadgeIcon = MudBlazor.Icons.Material.Filled.Business,
|
||||
Headline = enterpriseHeadline,
|
||||
Description = TB("The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage."),
|
||||
StatusColor = Color.Success,
|
||||
StatusIcon = MudBlazor.Icons.Material.Filled.VerifiedUser,
|
||||
ActionLabel = TB("Open Security Details"),
|
||||
};
|
||||
}
|
||||
|
||||
var audit = settingsManager.ConfigurationData.AssistantPluginAudits.FirstOrDefault(x => x.PluginId == plugin.Id);
|
||||
var hasAudit = audit is not null && audit.Level is not AssistantAuditLevel.UNKNOWN;
|
||||
var hashMatches = hasAudit && string.Equals(audit!.PluginHash, currentHash, StringComparison.Ordinal);
|
||||
var hashMatches = hasAudit && string.Equals(NormalizeHash(audit!.PluginHash), currentHash, StringComparison.Ordinal);
|
||||
var hasHashMismatch = hasAudit && !hashMatches;
|
||||
var isBelowMinimum = hashMatches && audit is not null && audit.Level < auditSettings.MinimumLevel;
|
||||
var meetsMinimum = hashMatches && audit is not null && audit.Level >= auditSettings.MinimumLevel;
|
||||
@ -94,6 +141,7 @@ public static class PluginAssistantSecurityResolver
|
||||
Plugin = plugin,
|
||||
Audit = null,
|
||||
Settings = auditSettings,
|
||||
Source = PluginAssistantSecurityStatusSource.NONE,
|
||||
CurrentHash = currentHash,
|
||||
HashMatches = false,
|
||||
HasHashMismatch = false,
|
||||
@ -111,6 +159,9 @@ public static class PluginAssistantSecurityResolver
|
||||
AvailabilityColor = GetAvailabilityColor(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
AvailabilityIcon = GetAvailabilityIcon(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
StatusLabel = GetAvailabilityLabel(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
SourceLabel = TB("No Approval"),
|
||||
SourceColor = Color.Default,
|
||||
SourceIcon = MudBlazor.Icons.Material.Filled.HelpOutline,
|
||||
BadgeIcon = GetSecurityBadgeIcon(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
Headline = requiresAudit ? TB("This assistant is currently locked.") : TB("This assistant currently has no stored audit."),
|
||||
Description = requiresAudit
|
||||
@ -129,6 +180,7 @@ public static class PluginAssistantSecurityResolver
|
||||
Plugin = plugin,
|
||||
Audit = audit,
|
||||
Settings = auditSettings,
|
||||
Source = PluginAssistantSecurityStatusSource.NONE,
|
||||
CurrentHash = currentHash,
|
||||
HashMatches = false,
|
||||
HasHashMismatch = true,
|
||||
@ -146,6 +198,9 @@ public static class PluginAssistantSecurityResolver
|
||||
AvailabilityColor = GetAvailabilityColor(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
AvailabilityIcon = GetAvailabilityIcon(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
StatusLabel = GetAvailabilityLabel(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
SourceLabel = TB("No Approval"),
|
||||
SourceColor = Color.Default,
|
||||
SourceIcon = MudBlazor.Icons.Material.Filled.Warning,
|
||||
BadgeIcon = GetSecurityBadgeIcon(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
|
||||
Headline = requiresAudit ? TB("This assistant is locked until it is audited again.") : TB("This assistant changed after its last audit."),
|
||||
Description = requiresAudit
|
||||
@ -167,6 +222,7 @@ public static class PluginAssistantSecurityResolver
|
||||
Plugin = plugin,
|
||||
Audit = audit,
|
||||
Settings = auditSettings,
|
||||
Source = PluginAssistantSecurityStatusSource.USER_AUDIT,
|
||||
CurrentHash = currentHash,
|
||||
HashMatches = true,
|
||||
HasHashMismatch = false,
|
||||
@ -184,6 +240,9 @@ public static class PluginAssistantSecurityResolver
|
||||
AvailabilityColor = GetAvailabilityColor(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
|
||||
AvailabilityIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
|
||||
StatusLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
|
||||
SourceLabel = TB("User Audit"),
|
||||
SourceColor = auditLevel.GetColor(),
|
||||
SourceIcon = MudBlazor.Icons.Material.Filled.Verified,
|
||||
BadgeIcon = GetSecurityBadgeIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
|
||||
Headline = isBlockedByMinimum
|
||||
? TB("This assistant is currently locked.")
|
||||
@ -208,6 +267,7 @@ public static class PluginAssistantSecurityResolver
|
||||
Plugin = plugin,
|
||||
Audit = audit,
|
||||
Settings = auditSettings,
|
||||
Source = PluginAssistantSecurityStatusSource.USER_AUDIT,
|
||||
CurrentHash = currentHash,
|
||||
HashMatches = true,
|
||||
HasHashMismatch = false,
|
||||
@ -225,6 +285,9 @@ public static class PluginAssistantSecurityResolver
|
||||
AvailabilityColor = GetAvailabilityColor(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
AvailabilityIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
StatusLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
SourceLabel = TB("User Audit"),
|
||||
SourceColor = auditLevelDefault.GetColor(),
|
||||
SourceIcon = MudBlazor.Icons.Material.Filled.Verified,
|
||||
BadgeIcon = GetSecurityBadgeIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
|
||||
Headline = TB("This assistant is currently unlocked."),
|
||||
Description = string.Format(TB("The stored audit matches the current plugin code and meets your required minimum level '{0}'."), auditSettings.MinimumLevel.GetName()),
|
||||
|
||||
@ -13,9 +13,12 @@ public sealed class PluginAssistantSecurityState
|
||||
{
|
||||
public PluginAssistants Plugin { get; init; } = null!;
|
||||
public PluginAssistantAudit? Audit { get; init; }
|
||||
public DataAssistantPluginEnterpriseApproval? EnterpriseApproval { get; init; }
|
||||
public DataAssistantPluginAudit Settings { get; init; } = new();
|
||||
public PluginAssistantSecurityStatusSource Source { get; init; } = PluginAssistantSecurityStatusSource.NONE;
|
||||
public string CurrentHash { get; init; } = string.Empty;
|
||||
public bool HasAudit => this.Audit is not null;
|
||||
public bool IsEnterpriseApproved => this.Source is PluginAssistantSecurityStatusSource.ENTERPRISE_APPROVAL;
|
||||
public bool HashMatches { get; init; }
|
||||
public bool HasHashMismatch { get; init; }
|
||||
public bool IsBelowMinimum { get; init; }
|
||||
@ -32,6 +35,9 @@ public sealed class PluginAssistantSecurityState
|
||||
public Color AvailabilityColor { get; init; } = Color.Info;
|
||||
public string AvailabilityIcon { get; init; } = MudBlazor.Icons.Material.Filled.Lock;
|
||||
public string StatusLabel { get; init; } = string.Empty;
|
||||
public string SourceLabel { get; init; } = string.Empty;
|
||||
public Color SourceColor { get; init; } = Color.Info;
|
||||
public string SourceIcon { get; init; } = MudBlazor.Icons.Material.Filled.Info;
|
||||
public string Headline { get; init; } = string.Empty;
|
||||
public string Description { get; init; } = string.Empty;
|
||||
public Color StatusColor { get; init; } = Color.Info;
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants;
|
||||
|
||||
public enum PluginAssistantSecurityStatusSource
|
||||
{
|
||||
NONE,
|
||||
USER_AUDIT,
|
||||
ENTERPRISE_APPROVAL,
|
||||
}
|
||||
@ -2,8 +2,8 @@ using System.Collections.Immutable;
|
||||
using AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
using AIStudio.Tools.PluginSystem.Assistants.DataModel.Layout;
|
||||
using Lua;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using AssistantPluginHash = SharedTools.AssistantPluginHash;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants;
|
||||
|
||||
@ -36,6 +36,9 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
|
||||
public bool AllowProfiles { get; private set; } = true;
|
||||
public bool HasEmbeddedProfileSelection { get; private set; }
|
||||
public bool HasCustomPromptBuilder => this.buildPromptFunction is not null;
|
||||
public AssistantPluginLaunchBehavior LaunchBehavior { get; private set; }
|
||||
public string LaunchWorkspaceName { get; private set; } = string.Empty;
|
||||
public bool StartsChatDirectly => this.LaunchBehavior is AssistantPluginLaunchBehavior.OPEN_WORKSPACE_CHAT_BY_NAME;
|
||||
public const int TEXT_AREA_MAX_VALUE = 524288;
|
||||
|
||||
private LuaFunction? buildPromptFunction;
|
||||
@ -61,6 +64,8 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
|
||||
message = string.Empty;
|
||||
this.HasEmbeddedProfileSelection = false;
|
||||
this.buildPromptFunction = null;
|
||||
this.LaunchBehavior = AssistantPluginLaunchBehavior.NONE;
|
||||
this.LaunchWorkspaceName = string.Empty;
|
||||
|
||||
this.RegisterLuaHelpers();
|
||||
|
||||
@ -123,6 +128,12 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
|
||||
this.SubmitText = assistantSubmitText;
|
||||
this.AllowProfiles = assistantAllowProfiles;
|
||||
|
||||
if (!this.TryReadLaunchConfiguration(assistantTable, out var launchConfigIssue))
|
||||
{
|
||||
message = launchConfigIssue;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure that the UI table exists nested in the ASSISTANT table and is a valid Lua table:
|
||||
if (!assistantTable.TryGetValue("UI", out var uiVal) || !uiVal.TryRead<LuaTable>(out var uiTable))
|
||||
{
|
||||
@ -140,6 +151,51 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryReadLaunchConfiguration(LuaTable assistantTable, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
if (!assistantTable.TryGetValue("LaunchBehavior", out var launchBehaviorValue))
|
||||
return true;
|
||||
|
||||
if (!launchBehaviorValue.TryRead<string>(out var launchBehaviorText) ||
|
||||
!Enum.TryParse<AssistantPluginLaunchBehavior>(launchBehaviorText, true, out var launchBehavior))
|
||||
{
|
||||
message = TB("The ASSISTANT table contains an invalid LaunchBehavior value.");
|
||||
return false;
|
||||
}
|
||||
|
||||
this.LaunchBehavior = launchBehavior;
|
||||
if (launchBehavior is AssistantPluginLaunchBehavior.NONE)
|
||||
return true;
|
||||
|
||||
switch (launchBehavior)
|
||||
{
|
||||
case AssistantPluginLaunchBehavior.OPEN_WORKSPACE_CHAT_BY_NAME:
|
||||
if (!assistantTable.TryGetValue("WorkspaceName", out var workspaceNameValue) ||
|
||||
!workspaceNameValue.TryRead<string>(out var workspaceName))
|
||||
{
|
||||
message = TB("The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName.");
|
||||
return false;
|
||||
}
|
||||
|
||||
workspaceName = workspaceName.Trim();
|
||||
if (string.IsNullOrWhiteSpace(workspaceName))
|
||||
{
|
||||
message = TB("The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
this.LaunchWorkspaceName = workspaceName;
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
message = TB("The ASSISTANT table contains an unsupported LaunchBehavior value.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string?> TryBuildPromptAsync(LuaTable input, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (this.buildPromptFunction is null)
|
||||
@ -224,33 +280,7 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
|
||||
/// sequence of relative path length, relative path, content length, and content
|
||||
/// for each file in ordinal path order.
|
||||
/// </summary>
|
||||
public string ComputeAuditHash()
|
||||
{
|
||||
var luaFiles = this.ReadAllLuaFiles();
|
||||
|
||||
if (luaFiles.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
using var stream = new MemoryStream();
|
||||
using var writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true);
|
||||
|
||||
foreach (var (relativePath, content) in luaFiles.OrderBy(pair => pair.Key, StringComparer.Ordinal))
|
||||
{
|
||||
var normalizedPath = relativePath.Replace('\\', '/');
|
||||
var pathBytes = Encoding.UTF8.GetBytes(normalizedPath);
|
||||
var contentBytes = Encoding.UTF8.GetBytes(content);
|
||||
|
||||
writer.Write(pathBytes.Length);
|
||||
writer.Write(pathBytes);
|
||||
writer.Write(contentBytes.Length);
|
||||
writer.Write(contentBytes);
|
||||
}
|
||||
|
||||
writer.Flush();
|
||||
|
||||
var bytes = SHA256.HashData(stream.ToArray());
|
||||
return Convert.ToHexString(bytes);
|
||||
}
|
||||
public string ComputeAuditHash() => AssistantPluginHash.Compute(this.PluginPath);
|
||||
|
||||
private static string BuildSecureSystemPrompt(string pluginSystemPrompt)
|
||||
{
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.Services;
|
||||
@ -204,6 +205,26 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
|
||||
// Config: data source security settings
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.DataSourceSecurity, x => x.TrustedProviderIds, this.Id, settingsTable, dryRun);
|
||||
|
||||
// Config: data source selection agent settings
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AgentDataSourceSelection, x => x.PreselectAgentOptions, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AgentDataSourceSelection, x => x.PreselectedAgentProvider, Guid.Empty, this.Id, settingsTable, dryRun);
|
||||
|
||||
// Config: retrieval context validation agent settings
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AgentRetrievalContextValidation, x => x.EnableRetrievalContextValidation, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AgentRetrievalContextValidation, x => x.PreselectAgentOptions, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AgentRetrievalContextValidation, x => x.PreselectedAgentProvider, Guid.Empty, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AgentRetrievalContextValidation, x => x.NumParallelValidations, this.Id, settingsTable, dryRun);
|
||||
|
||||
// Config: assistant plugin audit settings
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AssistantPluginAudit, x => x.RequireAuditBeforeActivation, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AssistantPluginAudit, x => x.PreselectedAgentProvider, Guid.Empty, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AssistantPluginAudit, x => x.MinimumLevel, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AssistantPluginAudit, x => x.BlockActivationBelowMinimum, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.AssistantPluginAudit, x => x.AutomaticallyAuditAssistants, this.Id, settingsTable, dryRun);
|
||||
|
||||
// Config: enterprise-managed approvals for assistant plugins
|
||||
this.TryProcessEnterpriseApprovedAssistantPlugins(settingsTable, dryRun);
|
||||
|
||||
// Handle configured LLM providers:
|
||||
PluginConfigurationObject.TryParse(PluginConfigurationObjectType.LLM_PROVIDER, x => x.Providers, x => x.NextProviderNum, mainTable, this.Id, ref this.configObjects, dryRun);
|
||||
@ -243,6 +264,11 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedProvider, Guid.Empty, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedProfile, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedChatTemplate, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedDataSourcesDisabled, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedDataSourcesAutomaticSelection, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedDataSourcesAutomaticValidation, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.PreselectedDataSourceIds, this.Id, settingsTable, dryRun);
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.Chat, x => x.SendToChatDataSourceBehavior, this.Id, settingsTable, dryRun);
|
||||
|
||||
// Config: transcription provider?
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.UseTranscriptionProvider, Guid.Empty, this.Id, settingsTable, dryRun);
|
||||
@ -251,6 +277,120 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TryProcessEnterpriseApprovedAssistantPlugins(LuaTable settingsTable, bool dryRun)
|
||||
{
|
||||
if (!ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.EnterpriseApprovedPlugins, out ConfigMeta<DataAssistantPluginAudit, IList<DataAssistantPluginEnterpriseApproval>> configMeta))
|
||||
return;
|
||||
|
||||
var settingName = SettingsManager.ToSettingName<DataAssistantPluginAudit, IList<DataAssistantPluginEnterpriseApproval>>(x => x.EnterpriseApprovedPlugins);
|
||||
var successful = false;
|
||||
IList<DataAssistantPluginEnterpriseApproval> configuredApprovals = [];
|
||||
|
||||
if (settingsTable.TryGetValue(settingName, out var configuredLuaValue)
|
||||
&& configuredLuaValue.Type is LuaValueType.Table
|
||||
&& configuredLuaValue.TryRead<LuaTable>(out var approvalsTable))
|
||||
{
|
||||
var approvals = new List<DataAssistantPluginEnterpriseApproval>(approvalsTable.ArrayLength);
|
||||
for (var index = 1; index <= approvalsTable.ArrayLength; index++)
|
||||
{
|
||||
var entryValue = approvalsTable[index];
|
||||
if (entryValue.TryRead<string>(out var hashText))
|
||||
{
|
||||
var normalizedHash = NormalizeApprovalHash(hashText);
|
||||
if (!string.IsNullOrWhiteSpace(normalizedHash))
|
||||
approvals.Add(new() { PluginHash = normalizedHash });
|
||||
else
|
||||
LOG.LogWarning("The enterprise assistant approval entry at index {Index} contains an empty hash (config plugin id: {ConfigPluginId}).", index, this.Id);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entryValue.TryRead<LuaTable>(out var entryTable))
|
||||
{
|
||||
LOG.LogWarning("The enterprise assistant approval entry at index {Index} is neither a string nor a table (config plugin id: {ConfigPluginId}).", index, this.Id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TryParseEnterpriseApprovedAssistantPlugin(index, entryTable, this.Id, out var approval))
|
||||
continue;
|
||||
|
||||
approvals.Add(approval);
|
||||
}
|
||||
|
||||
configuredApprovals = approvals;
|
||||
successful = true;
|
||||
}
|
||||
|
||||
if (dryRun)
|
||||
return;
|
||||
|
||||
switch (successful)
|
||||
{
|
||||
case true:
|
||||
configMeta.SetValue(configuredApprovals);
|
||||
configMeta.LockConfiguration(this.Id);
|
||||
break;
|
||||
|
||||
case false when configMeta.IsLocked && configMeta.LockedByConfigPluginId == this.Id:
|
||||
configMeta.ResetLockedConfiguration();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryParseEnterpriseApprovedAssistantPlugin(int index, LuaTable table, Guid configPluginId, out DataAssistantPluginEnterpriseApproval approval)
|
||||
{
|
||||
approval = new();
|
||||
|
||||
if (!table.TryGetValue("PluginHash", out var pluginHashValue) || !pluginHashValue.TryRead<string>(out var pluginHash))
|
||||
{
|
||||
LOG.LogWarning("The enterprise assistant approval entry at index {Index} is missing a valid PluginHash (config plugin id: {ConfigPluginId}).", index, configPluginId);
|
||||
return false;
|
||||
}
|
||||
|
||||
var normalizedHash = NormalizeApprovalHash(pluginHash);
|
||||
if (string.IsNullOrWhiteSpace(normalizedHash))
|
||||
{
|
||||
LOG.LogWarning("The enterprise assistant approval entry at index {Index} contains an empty PluginHash (config plugin id: {ConfigPluginId}).", index, configPluginId);
|
||||
return false;
|
||||
}
|
||||
|
||||
var displayName = TryReadOptionalString(table, "DisplayName");
|
||||
var comment = TryReadOptionalString(table, "Comment");
|
||||
var approvedBy = TryReadOptionalString(table, "ApprovedBy");
|
||||
var approvedAtUtc = TryReadOptionalDateTimeOffset(table, "ApprovedAtUtc", index, configPluginId);
|
||||
|
||||
approval = new()
|
||||
{
|
||||
PluginHash = normalizedHash,
|
||||
DisplayName = displayName,
|
||||
Comment = comment,
|
||||
ApprovedBy = approvedBy,
|
||||
ApprovedAtUtc = approvedAtUtc,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string TryReadOptionalString(LuaTable table, string key)
|
||||
{
|
||||
return table.TryGetValue(key, out var value) && value.TryRead<string>(out var text)
|
||||
? text
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
private static DateTimeOffset? TryReadOptionalDateTimeOffset(LuaTable table, string key, int index, Guid configPluginId)
|
||||
{
|
||||
if (!table.TryGetValue(key, out var value))
|
||||
return null;
|
||||
|
||||
if (value.TryRead<string>(out var text) && DateTimeOffset.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out var parsed))
|
||||
return parsed.ToUniversalTime();
|
||||
|
||||
LOG.LogWarning("The enterprise assistant approval entry at index {Index} contains an invalid {Key} value (config plugin id: {ConfigPluginId}).", index, key, configPluginId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string NormalizeApprovalHash(string hash) => string.IsNullOrWhiteSpace(hash) ? string.Empty : hash.Trim().ToUpperInvariant();
|
||||
|
||||
private void TryReadMandatoryInfos(LuaTable mainTable)
|
||||
{
|
||||
if (!mainTable.TryGetValue("MANDATORY_INFOS", out var mandatoryInfosValue) || !mandatoryInfosValue.TryRead<LuaTable>(out var mandatoryInfosTable))
|
||||
|
||||
@ -214,6 +214,21 @@ public static partial class PluginFactory
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Chat, x => x.PreselectedChatTemplate, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Chat, x => x.PreselectedDataSourcesDisabled, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Chat, x => x.PreselectedDataSourcesAutomaticSelection, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Chat, x => x.PreselectedDataSourcesAutomaticValidation, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Chat, x => x.PreselectedDataSourceIds, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.Chat, x => x.SendToChatDataSourceBehavior, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check for the update interval:
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.UpdateInterval, AVAILABLE_PLUGINS))
|
||||
@ -300,6 +315,26 @@ public static partial class PluginFactory
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.DataSourceSecurity, x => x.TrustedProviderIds, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check data source selection agent settings:
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AgentDataSourceSelection, x => x.PreselectAgentOptions, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AgentDataSourceSelection, x => x.PreselectedAgentProvider, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check retrieval context validation agent settings:
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AgentRetrievalContextValidation, x => x.EnableRetrievalContextValidation, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AgentRetrievalContextValidation, x => x.PreselectAgentOptions, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AgentRetrievalContextValidation, x => x.PreselectedAgentProvider, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AgentRetrievalContextValidation, x => x.NumParallelValidations, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check if audit is required before it can be activated
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AssistantPluginAudit, x => x.RequireAuditBeforeActivation, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
@ -319,6 +354,10 @@ public static partial class PluginFactory
|
||||
// Check if security audits are invoked automatically and transparent for the user
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AssistantPluginAudit, x => x.AutomaticallyAuditAssistants, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check enterprise-managed assistant plugin approvals
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AssistantPluginAudit, x => x.EnterpriseApprovedPlugins, AVAILABLE_PLUGINS))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
if (wasConfigurationChanged)
|
||||
{
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
using System.Text;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.PluginSystem.Assistants;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem;
|
||||
|
||||
@ -78,11 +81,36 @@ public static partial class PluginFactory
|
||||
LOG.LogError(e, $"An error occurred while starting the plugin: Id='{availablePlugin.Id}', Type='{availablePlugin.Type}', Name='{availablePlugin.Name}', Version='{availablePlugin.Version}'.");
|
||||
}
|
||||
}
|
||||
|
||||
LogAssistantPluginStartupState();
|
||||
|
||||
// Inform all components that the plugins have been reloaded or started:
|
||||
await MessageBus.INSTANCE.SendMessage<bool>(null, Event.PLUGINS_RELOADED);
|
||||
return configObjects;
|
||||
}
|
||||
|
||||
private static void LogAssistantPluginStartupState()
|
||||
{
|
||||
ManagedConfiguration.TryGet(x => x.AssistantPluginAudit, x => x.EnterpriseApprovedPlugins, out ConfigMeta<DataAssistantPluginAudit, IList<DataAssistantPluginEnterpriseApproval>> configMeta);
|
||||
var approvedByConfigPluginId = configMeta is { IsLocked: true } ? configMeta.LockedByConfigPluginId : Guid.Empty;
|
||||
var approvedByConfigPluginName = approvedByConfigPluginId == Guid.Empty
|
||||
? string.Empty
|
||||
: AVAILABLE_PLUGINS.FirstOrDefault(x => x.Id == approvedByConfigPluginId)?.Name ?? string.Empty;
|
||||
|
||||
foreach (var assistantPlugin in RUNNING_PLUGINS.OfType<PluginAssistants>())
|
||||
{
|
||||
var securityState = PluginAssistantSecurityResolver.Resolve(SettingsManagerAccess, assistantPlugin);
|
||||
if (securityState.IsEnterpriseApproved)
|
||||
{
|
||||
LOG.LogInformation(
|
||||
$"Successfully started assistant plugin: Id='{assistantPlugin.Id}', Type='{assistantPlugin.Type}', Name='{assistantPlugin.Name}', Version='{assistantPlugin.Version}', SecuritySource='EnterpriseApproval', ApprovedByConfigPluginId='{approvedByConfigPluginId}', ApprovedByConfigPluginName='{approvedByConfigPluginName}'");
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG.LogInformation(
|
||||
$"Successfully started assistant plugin: Id='{assistantPlugin.Id}', Type='{assistantPlugin.Type}', Name='{assistantPlugin.Name}', Version='{assistantPlugin.Version}'");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<PluginBase> Start(IAvailablePlugin meta, CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
||||
@ -70,9 +70,10 @@ public sealed class DataSourceService
|
||||
|
||||
private async Task<AllowedSelectedDataSources> GetDataSources(bool usingTrustedProvider, IReadOnlyCollection<IDataSource>? previousSelectedDataSources = null)
|
||||
{
|
||||
var allDataSources = this.settingsManager.ConfigurationData.DataSources;
|
||||
var allDataSources = this.settingsManager.ConfigurationData.DataSources.ToList();
|
||||
var previousSelectedDataSourceIds = previousSelectedDataSources?.Select(source => source.Id).ToHashSet(StringComparer.Ordinal) ?? [];
|
||||
var filteredDataSources = new List<IDataSource>(allDataSources.Count);
|
||||
var filteredSelectedDataSources = new List<IDataSource>(previousSelectedDataSources?.Count ?? 0);
|
||||
var filteredSelectedDataSources = new List<IDataSource>(previousSelectedDataSourceIds.Count);
|
||||
var tasks = new List<Task<IDataSource?>>(allDataSources.Count);
|
||||
|
||||
// Start all checks in parallel:
|
||||
@ -86,7 +87,7 @@ public sealed class DataSourceService
|
||||
if (source is not null)
|
||||
{
|
||||
filteredDataSources.Add(source);
|
||||
if (previousSelectedDataSources is not null && previousSelectedDataSources.Contains(source))
|
||||
if (previousSelectedDataSourceIds.Contains(source.Id))
|
||||
filteredSelectedDataSources.Add(source);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,83 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
public static class SourceExtensions
|
||||
public static partial class SourceExtensions
|
||||
{
|
||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(SourceExtensions).Namespace, nameof(SourceExtensions));
|
||||
|
||||
private static void AppendMarkdownLink(StringBuilder sb, string title, string url)
|
||||
{
|
||||
sb.Append('[');
|
||||
sb.Append(EscapeMarkdownLinkText(title));
|
||||
sb.Append("](<");
|
||||
sb.Append(NormalizeLinkDestination(url));
|
||||
sb.Append(">)");
|
||||
}
|
||||
|
||||
private static string EscapeMarkdownLinkText(string text)
|
||||
{
|
||||
return text
|
||||
.Replace(@"\", @"\\")
|
||||
.Replace("[", @"\[")
|
||||
.Replace("]", @"\]")
|
||||
.Replace("\r", " ")
|
||||
.Replace("\n", " ");
|
||||
}
|
||||
|
||||
private static string NormalizeLinkDestination(string url)
|
||||
{
|
||||
var normalized = url.Trim().Replace("\r", string.Empty).Replace("\n", string.Empty);
|
||||
normalized = TryUnwrapMarkdownLink(normalized);
|
||||
|
||||
if (Uri.TryCreate(normalized, UriKind.Absolute, out var absoluteUri))
|
||||
return absoluteUri.GetComponents(UriComponents.AbsoluteUri, UriFormat.UriEscaped);
|
||||
|
||||
var sb = new StringBuilder(normalized.Length);
|
||||
foreach (var c in normalized)
|
||||
{
|
||||
if (IsSafeUrlCharacter(c))
|
||||
{
|
||||
sb.Append(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.Append(Uri.EscapeDataString(c.ToString()));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static string TryUnwrapMarkdownLink(string value)
|
||||
{
|
||||
var match = MarkdownLinkWithOptionalSuffix().Match(value);
|
||||
if (!match.Success)
|
||||
return value;
|
||||
|
||||
var label = match.Groups["label"].Value;
|
||||
var url = match.Groups["url"].Value;
|
||||
var suffix = match.Groups["suffix"].Value;
|
||||
if (string.IsNullOrEmpty(suffix))
|
||||
return url;
|
||||
|
||||
if (Uri.TryCreate(label, UriKind.Absolute, out var labelUri) &&
|
||||
Uri.TryCreate(url, UriKind.Absolute, out var urlUri) &&
|
||||
Uri.Compare(labelUri, urlUri, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
return url + suffix;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static bool IsSafeUrlCharacter(char c)
|
||||
{
|
||||
if (char.IsAsciiLetterOrDigit(c))
|
||||
return true;
|
||||
|
||||
return c is '-' or '.' or '_' or '~' or ':' or '/' or '?' or '#' or '[' or ']' or '@' or '!' or '$' or '&' or '\'' or '(' or ')' or '*' or '+' or ',' or ';' or '=';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a list of sources to a markdown-formatted string.
|
||||
@ -36,11 +107,8 @@ public static class SourceExtensions
|
||||
}
|
||||
|
||||
sb.Append($"- [{++sourceNum}] ");
|
||||
sb.Append('[');
|
||||
sb.Append(source.Title);
|
||||
sb.Append("](");
|
||||
sb.Append(source.URL);
|
||||
sb.AppendLine(")");
|
||||
AppendMarkdownLink(sb, source.Title, source.URL);
|
||||
sb.AppendLine();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -55,11 +123,8 @@ public static class SourceExtensions
|
||||
foreach (var source in ragSources)
|
||||
{
|
||||
sb.Append($"- [{++sourceNum}] ");
|
||||
sb.Append('[');
|
||||
sb.Append(source.Title);
|
||||
sb.Append("](");
|
||||
sb.Append(source.URL);
|
||||
sb.AppendLine(")");
|
||||
AppendMarkdownLink(sb, source.Title, source.URL);
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
@ -76,4 +141,7 @@ public static class SourceExtensions
|
||||
if (sources.All(s => s.URL != addedSource.URL && s.Title != addedSource.Title))
|
||||
sources.Add((Source)addedSource);
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^\[(?<label>[^\]]+)\]\((?<url>[^)\r\n]+)\)(?<suffix>.*)$")]
|
||||
private static partial Regex MarkdownLinkWithOptionalSuffix();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user