mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 17:36:28 +00:00
Resolved warnings
This commit is contained in:
parent
c28410400c
commit
a927fb7fb7
@ -6,7 +6,6 @@ using AIStudio.Settings;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.PluginSystem.Assistants;
|
||||
using AIStudio.Tools.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Agents.AssistantAudit;
|
||||
|
||||
@ -251,7 +250,7 @@ public sealed class AssistantAuditAgent(ILogger<AssistantAuditAgent> logger, ILo
|
||||
/// </summary>
|
||||
private static AssistantAuditResult NormalizeResult(AssistantAuditResult result)
|
||||
{
|
||||
var normalizedFindings = result.Findings ?? [];
|
||||
var normalizedFindings = result.Findings;
|
||||
var parsedLevel = AssistantAuditLevelExtensions.Parse(result.Level);
|
||||
var lowestFindingLevel = GetMostSevereFindingLevel(normalizedFindings);
|
||||
if (lowestFindingLevel != AssistantAuditLevel.UNKNOWN && (parsedLevel == AssistantAuditLevel.UNKNOWN || lowestFindingLevel < parsedLevel))
|
||||
|
||||
@ -30,7 +30,7 @@ public sealed class AssistantAuditFinding
|
||||
_ => "unknown",
|
||||
};
|
||||
|
||||
init => this.Severity = value?.Trim().ToLowerInvariant() switch
|
||||
init => this.Severity = value.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"critical" => AssistantAuditLevel.DANGEROUS,
|
||||
"medium" => AssistantAuditLevel.CAUTION,
|
||||
|
||||
@ -56,16 +56,16 @@
|
||||
<div id="@BEFORE_RESULT_DIV_ID" class="mt-3">
|
||||
</div>
|
||||
|
||||
@if (this.ShowResult && !this.ShowEntireChatThread && this.resultingContentBlock 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)
|
||||
{
|
||||
foreach (var block in this.chatThread.Blocks.OrderBy(n => n.Time))
|
||||
{
|
||||
@if (!block.HideFromUser)
|
||||
@if (block is { HideFromUser: false, Content: not null })
|
||||
{
|
||||
<ContentBlockComponent Role="@block.Role" Type="@block.ContentType" Time="@block.Time" Content="@block.Content"/>
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
@attribute [Route(Routes.ASSISTANT_DYNAMIC)]
|
||||
@using AIStudio.Agents.AssistantAudit
|
||||
@using AIStudio.Settings
|
||||
@using AIStudio.Tools.PluginSystem.Assistants.DataModel
|
||||
@using AIStudio.Tools.PluginSystem.Assistants.DataModel.Layout
|
||||
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.NoSettingsPanel>
|
||||
@ -44,17 +43,17 @@ else
|
||||
|
||||
@code {
|
||||
private RenderFragment RenderSwitch(AssistantSwitch assistantSwitch) => @<MudSwitch T="bool"
|
||||
Value="@this.assistantState.Bools[assistantSwitch.Name]"
|
||||
ValueChanged="@((bool value) => ExecuteSwitchChangedAsync(assistantSwitch, value))"
|
||||
Value="@this.assistantState.Booleans[assistantSwitch.Name]"
|
||||
ValueChanged="@(value => this.ExecuteSwitchChangedAsync(assistantSwitch, value))"
|
||||
LabelPlacement="@assistantSwitch.GetLabelPlacement()"
|
||||
Color="@assistantSwitch.GetColor(assistantSwitch.CheckedColor)"
|
||||
UncheckedColor="@assistantSwitch.GetColor(assistantSwitch.UncheckedColor)"
|
||||
Color="@AssistantSwitch.GetColor(assistantSwitch.CheckedColor)"
|
||||
UncheckedColor="@AssistantSwitch.GetColor(assistantSwitch.UncheckedColor)"
|
||||
ThumbIcon="@assistantSwitch.GetIconSvg()"
|
||||
ThumbIconColor="@assistantSwitch.GetColor(assistantSwitch.IconColor)"
|
||||
Disabled="@(assistantSwitch.Disabled || IsSwitchActionRunning(assistantSwitch.Name))"
|
||||
ThumbIconColor="@AssistantSwitch.GetColor(assistantSwitch.IconColor)"
|
||||
Disabled="@(assistantSwitch.Disabled || this.IsSwitchActionRunning(assistantSwitch.Name))"
|
||||
Class="@assistantSwitch.Class"
|
||||
Style="@GetOptionalStyle(assistantSwitch.Style)">
|
||||
@(this.assistantState.Bools[assistantSwitch.Name] ? assistantSwitch.LabelOn : assistantSwitch.LabelOff)
|
||||
@(this.assistantState.Booleans[assistantSwitch.Name] ? assistantSwitch.LabelOn : assistantSwitch.LabelOff)
|
||||
</MudSwitch>;
|
||||
}
|
||||
|
||||
@ -76,7 +75,7 @@ else
|
||||
|
||||
<MudTextField T="string"
|
||||
Text="@this.assistantState.Text[textArea.Name]"
|
||||
TextChanged="@((string value) => this.assistantState.Text[textArea.Name] = value)"
|
||||
TextChanged="@(value => this.assistantState.Text[textArea.Name] = value)"
|
||||
Label="@textArea.Label"
|
||||
HelperText="@textArea.HelperText"
|
||||
HelperTextOnFocus="@textArea.HelperTextOnFocus"
|
||||
@ -93,7 +92,7 @@ else
|
||||
AutoGrow="@autoGrow"
|
||||
MaxLines="12"
|
||||
Class='@MergeClass(textArea.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(textArea.Style)" />
|
||||
Style="@GetOptionalStyle(textArea.Style)" />
|
||||
}
|
||||
break;
|
||||
|
||||
@ -105,7 +104,7 @@ else
|
||||
{
|
||||
var image = assistantImage;
|
||||
<div Class="mb-4">
|
||||
<MudImage Fluid="true" Src="@resolvedSource" Alt="@image.Alt" Class='@MergeClass(image.Class, "rounded-lg mb-2")' Style="@this.GetOptionalStyle(image.Style)" Elevation="20" />
|
||||
<MudImage Fluid="true" Src="@resolvedSource" Alt="@image.Alt" Class='@MergeClass(image.Class, "rounded-lg mb-2")' Style="@GetOptionalStyle(image.Style)" Elevation="20" />
|
||||
@if (!string.IsNullOrWhiteSpace(image.Caption))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Align="Align.Center">@image.Caption</MudText>
|
||||
@ -119,7 +118,7 @@ else
|
||||
if (component is AssistantWebContentReader webContent)
|
||||
{
|
||||
var webState = this.assistantState.WebContent[webContent.Name];
|
||||
<div class="@webContent.Class" style="@this.GetOptionalStyle(webContent.Style)">
|
||||
<div class="@webContent.Class" style="@GetOptionalStyle(webContent.Style)">
|
||||
<ReadWebContent @bind-Content="@webState.Content"
|
||||
ProviderSettings="@this.providerSettings"
|
||||
@bind-AgentIsRunning="@webState.AgentIsRunning"
|
||||
@ -133,7 +132,7 @@ else
|
||||
if (component is AssistantFileContentReader fileContent)
|
||||
{
|
||||
var fileState = this.assistantState.FileContent[fileContent.Name];
|
||||
<div class="@fileContent.Class" style="@this.GetOptionalStyle(fileContent.Style)">
|
||||
<div class="@fileContent.Class" style="@GetOptionalStyle(fileContent.Style)">
|
||||
<ReadFileContent @bind-FileContent="@fileState.Content" />
|
||||
</div>
|
||||
}
|
||||
@ -159,13 +158,13 @@ else
|
||||
HasSelectAll="@assistantDropdown.HasSelectAll"
|
||||
SelectAllText="@assistantDropdown.SelectAllText"
|
||||
Class="@assistantDropdown.Class"
|
||||
Style="@this.GetOptionalStyle(assistantDropdown.Style)" />
|
||||
Style="@GetOptionalStyle(assistantDropdown.Style)" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<DynamicAssistantDropdown Items="@assistantDropdown.Items"
|
||||
Value="@this.assistantState.SingleSelect[assistantDropdown.Name]"
|
||||
ValueChanged="@((string value) => this.assistantState.SingleSelect[assistantDropdown.Name] = value)"
|
||||
ValueChanged="@(value => this.assistantState.SingleSelect[assistantDropdown.Name] = value)"
|
||||
Default="@assistantDropdown.Default"
|
||||
Label="@assistantDropdown.Label"
|
||||
HelperText="@assistantDropdown.HelperText"
|
||||
@ -177,7 +176,7 @@ else
|
||||
HasSelectAll="@assistantDropdown.HasSelectAll"
|
||||
SelectAllText="@assistantDropdown.SelectAllText"
|
||||
Class="@assistantDropdown.Class"
|
||||
Style="@this.GetOptionalStyle(assistantDropdown.Style)" />
|
||||
Style="@GetOptionalStyle(assistantDropdown.Style)" />
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -194,7 +193,7 @@ else
|
||||
var variant = button.GetButtonVariant();
|
||||
var disabled = this.IsButtonActionRunning(button.Name);
|
||||
var buttonClass = MergeClass(button.Class, "");
|
||||
var style = this.GetOptionalStyle(button.Style);
|
||||
var style = GetOptionalStyle(button.Style);
|
||||
|
||||
if (!button.IsIconButton)
|
||||
{
|
||||
@ -238,7 +237,7 @@ else
|
||||
Vertical="@buttonGroup.Vertical"
|
||||
DropShadow="@buttonGroup.DropShadow"
|
||||
Class='@MergeClass(buttonGroup.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(buttonGroup.Style)">
|
||||
Style="@GetOptionalStyle(buttonGroup.Style)">
|
||||
@this.RenderChildren(buttonGroup.Children)
|
||||
</MudButtonGroup>
|
||||
}
|
||||
@ -251,7 +250,7 @@ else
|
||||
<MudGrid Justify="@(AssistantComponentPropHelper.GetJustify(grid.Justify) ?? Justify.FlexStart)"
|
||||
Spacing="@grid.Spacing"
|
||||
Class="@grid.Class"
|
||||
Style="@this.GetOptionalStyle(grid.Style)">
|
||||
Style="@GetOptionalStyle(grid.Style)">
|
||||
@this.RenderChildren(grid.Children)
|
||||
</MudGrid>
|
||||
}
|
||||
@ -291,7 +290,7 @@ else
|
||||
Wrap="@(AssistantComponentPropHelper.GetWrap(stack.Wrap) ?? Wrap.Wrap)"
|
||||
Spacing="@stack.Spacing"
|
||||
Class="@stack.Class"
|
||||
Style="@this.GetOptionalStyle(stack.Style)">
|
||||
Style="@GetOptionalStyle(stack.Style)">
|
||||
@this.RenderChildren(stack.Children)
|
||||
</MudStack>
|
||||
}
|
||||
@ -308,7 +307,7 @@ else
|
||||
Elevation="@accordion.Elevation"
|
||||
Gutters="@accordion.HasSectionPaddings"
|
||||
Class="@MergeClass(accordion.Class, "my-6")"
|
||||
Style="@this.GetOptionalStyle(accordion.Style)">
|
||||
Style="@GetOptionalStyle(accordion.Style)">
|
||||
@this.RenderChildren(accordion.Children)
|
||||
</MudExpansionPanels>
|
||||
}
|
||||
@ -328,7 +327,7 @@ else
|
||||
Icon="@AssistantComponentPropHelper.GetIconSvg(accordionSection.ExpandIcon)"
|
||||
MaxHeight="@accordionSection.MaxHeight"
|
||||
Class="@accordionSection.Class"
|
||||
Style="@this.GetOptionalStyle(accordionSection.Style)">
|
||||
Style="@GetOptionalStyle(accordionSection.Style)">
|
||||
<TitleContent>
|
||||
<div class="d-flex">
|
||||
<MudIcon Icon="@AssistantComponentPropHelper.GetIconSvg(accordionSection.HeaderIcon)" class="mr-3"></MudIcon>
|
||||
@ -349,7 +348,7 @@ else
|
||||
case AssistantComponentType.PROVIDER_SELECTION:
|
||||
if (component is AssistantProviderSelection providerSelection)
|
||||
{
|
||||
<div class="@providerSelection.Class" style="@this.GetOptionalStyle(providerSelection.Style)">
|
||||
<div class="@providerSelection.Class" style="@GetOptionalStyle(providerSelection.Style)">
|
||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider" />
|
||||
</div>
|
||||
}
|
||||
@ -359,8 +358,8 @@ else
|
||||
if (component is AssistantProfileSelection profileSelection)
|
||||
{
|
||||
var selection = profileSelection;
|
||||
<div class="@selection.Class" style="@this.GetOptionalStyle(selection.Style)">
|
||||
<ProfileFormSelection Validation="@((Profile profile) => this.ValidateProfileSelection(selection, profile))" @bind-Profile="@this.currentProfile" />
|
||||
<div class="@selection.Class" style="@GetOptionalStyle(selection.Style)">
|
||||
<ProfileFormSelection Validation="@(profile => this.ValidateProfileSelection(selection, profile))" @bind-Profile="@this.currentProfile" />
|
||||
</div>
|
||||
}
|
||||
break;
|
||||
@ -395,7 +394,7 @@ else
|
||||
_ => Typo.h5
|
||||
};
|
||||
|
||||
<MudText Typo="@typo" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
|
||||
<MudText Typo="@typo" Class="@heading.Class" Style="@GetOptionalStyle(heading.Style)">@heading.Text</MudText>
|
||||
}
|
||||
break;
|
||||
|
||||
@ -403,7 +402,7 @@ else
|
||||
if (component is AssistantText assistantText)
|
||||
{
|
||||
var text = assistantText;
|
||||
<MudText Typo="Typo.body1" Class='@MergeClass(text.Class, "mb-3")' Style="@this.GetOptionalStyle(text.Style)">@text.Content</MudText>
|
||||
<MudText Typo="Typo.body1" Class='@MergeClass(text.Class, "mb-3")' Style="@GetOptionalStyle(text.Style)">@text.Content</MudText>
|
||||
}
|
||||
break;
|
||||
|
||||
@ -411,7 +410,7 @@ else
|
||||
if (component is AssistantList assistantList)
|
||||
{
|
||||
var list = assistantList;
|
||||
<MudList T="string" Class='@MergeClass(list.Class, "mb-6")' Style="@this.GetOptionalStyle(list.Style)">
|
||||
<MudList T="string" Class='@MergeClass(list.Class, "mb-6")' Style="@GetOptionalStyle(list.Style)">
|
||||
@foreach (var item in list.Items)
|
||||
{
|
||||
var iconColor = AssistantComponentPropHelper.GetColor(item.IconColor, Color.Default);
|
||||
@ -439,7 +438,7 @@ else
|
||||
|
||||
<MudItem Class="d-flex">
|
||||
<MudColorPicker Text="@this.assistantState.Colors[colorPicker.Name]"
|
||||
TextChanged="@((string value) => this.assistantState.Colors[colorPicker.Name] = value)"
|
||||
TextChanged="@(value => this.assistantState.Colors[colorPicker.Name] = value)"
|
||||
Label="@colorPicker.Label"
|
||||
Placeholder="@colorPicker.Placeholder"
|
||||
ShowAlpha="@colorPicker.ShowAlpha"
|
||||
@ -462,7 +461,7 @@ else
|
||||
|
||||
<MudPaper Class="d-flex" Elevation="0">
|
||||
<MudDatePicker Date="@datePicker.ParseValue(this.assistantState.Dates[datePicker.Name])"
|
||||
DateChanged="@((DateTime? value) => this.assistantState.Dates[datePicker.Name] = datePicker.FormatValue(value))"
|
||||
DateChanged="@(value => this.assistantState.Dates[datePicker.Name] = datePicker.FormatValue(value))"
|
||||
Label="@datePicker.Label"
|
||||
Color="@AssistantComponentPropHelper.GetColor(datePicker.Color, Color.Primary)"
|
||||
Placeholder="@datePicker.Placeholder"
|
||||
@ -472,7 +471,7 @@ else
|
||||
PickerVariant="@AssistantComponentPropHelper.GetPickerVariant(datePicker.PickerVariant, PickerVariant.Static)"
|
||||
Variant="Variant.Outlined"
|
||||
Class='@MergeClass(datePicker.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(datePicker.Style)"
|
||||
Style="@GetOptionalStyle(datePicker.Style)"
|
||||
/>
|
||||
</MudPaper>
|
||||
}
|
||||
@ -485,6 +484,7 @@ else
|
||||
var format = dateRangePicker.GetDateFormat();
|
||||
|
||||
<MudPaper Class="d-flex" Elevation="0">
|
||||
@* ReSharper disable CSharpWarnings::CS8619 *@
|
||||
<MudDateRangePicker DateRange="@dateRangePicker.ParseValue(this.assistantState.DateRanges[dateRangePicker.Name])"
|
||||
DateRangeChanged="@(value => this.assistantState.DateRanges[dateRangePicker.Name] = dateRangePicker.FormatValue(value))"
|
||||
Label="@dateRangePicker.Label"
|
||||
@ -497,8 +497,9 @@ else
|
||||
Elevation="@dateRangePicker.Elevation"
|
||||
Variant="Variant.Outlined"
|
||||
Class='@MergeClass(dateRangePicker.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(dateRangePicker.Style)"
|
||||
Style="@GetOptionalStyle(dateRangePicker.Style)"
|
||||
/>
|
||||
@* ReSharper restore CSharpWarnings::CS8619 *@
|
||||
</MudPaper>
|
||||
}
|
||||
break;
|
||||
@ -511,7 +512,7 @@ else
|
||||
|
||||
<MudPaper Class="d-flex" Elevation="0">
|
||||
<MudTimePicker Time="@timePicker.ParseValue(this.assistantState.Times[timePicker.Name])"
|
||||
TimeChanged="@((TimeSpan? value) => this.assistantState.Times[timePicker.Name] = timePicker.FormatValue(value))"
|
||||
TimeChanged="@(value => this.assistantState.Times[timePicker.Name] = timePicker.FormatValue(value))"
|
||||
Label="@timePicker.Label"
|
||||
Color="@AssistantComponentPropHelper.GetColor(timePicker.Color, Color.Primary)"
|
||||
Placeholder="@timePicker.Placeholder"
|
||||
@ -522,7 +523,7 @@ else
|
||||
Elevation="@timePicker.Elevation"
|
||||
Variant="Variant.Outlined"
|
||||
Class='@MergeClass(timePicker.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(timePicker.Style)"/>
|
||||
Style="@GetOptionalStyle(timePicker.Style)"/>
|
||||
</MudPaper>
|
||||
}
|
||||
break;
|
||||
@ -573,7 +574,7 @@ else
|
||||
if (!string.IsNullOrWhiteSpace(itemClass))
|
||||
builder.AddAttribute(7, nameof(MudItem.Class), itemClass);
|
||||
|
||||
var itemStyle = this.GetOptionalStyle(item.Style);
|
||||
var itemStyle = GetOptionalStyle(item.Style);
|
||||
if (!string.IsNullOrWhiteSpace(itemStyle))
|
||||
builder.AddAttribute(8, nameof(MudItem.Style), itemStyle);
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ namespace AIStudio.Assistants.Dynamic;
|
||||
public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
{
|
||||
[Parameter]
|
||||
public AssistantForm? RootComponent { get; set; } = null!;
|
||||
public AssistantForm? RootComponent { get; set; }
|
||||
|
||||
protected override string Title => this.title;
|
||||
protected override string Description => this.description;
|
||||
@ -171,9 +171,8 @@ public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
|
||||
private LuaTable BuildPromptInput()
|
||||
{
|
||||
var state = new LuaTable();
|
||||
var rootComponent = this.RootComponent;
|
||||
state = rootComponent is not null
|
||||
var state = rootComponent is not null
|
||||
? this.assistantState.ToLuaTable(rootComponent.Children)
|
||||
: new LuaTable();
|
||||
|
||||
@ -184,8 +183,8 @@ public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
["Actions"] = this.currentProfile.Actions,
|
||||
["Num"] = this.currentProfile.Num,
|
||||
};
|
||||
state["profile"] = profile;
|
||||
|
||||
state["profile"] = profile;
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -218,7 +217,7 @@ public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
return string.IsNullOrEmpty(trimmedFallback) ? trimmedCustom : $"{trimmedCustom} {trimmedFallback}";
|
||||
}
|
||||
|
||||
private string? GetOptionalStyle(string? style) => string.IsNullOrWhiteSpace(style) ? null : style;
|
||||
private static string GetOptionalStyle(string? style) => string.IsNullOrWhiteSpace(style) ? string.Empty : style;
|
||||
|
||||
private bool IsButtonActionRunning(string buttonName) => this.executingButtonActions.Contains(buttonName);
|
||||
private bool IsSwitchActionRunning(string switchName) => this.executingSwitchActions.Contains(switchName);
|
||||
@ -251,7 +250,7 @@ public partial class AssistantDynamic : AssistantBaseCore<NoSettingsPanel>
|
||||
if (string.IsNullOrWhiteSpace(switchComponent.Name))
|
||||
return;
|
||||
|
||||
this.assistantState.Bools[switchComponent.Name] = value;
|
||||
this.assistantState.Booleans[switchComponent.Name] = value;
|
||||
|
||||
if (this.assistantPlugin is null || switchComponent.OnChanged is null)
|
||||
{
|
||||
|
||||
@ -364,8 +364,6 @@ public partial class ContentBlockComponent : MSGComponentBase, IAsyncDisposable
|
||||
AddMarkdownSegment(markdownSegmentStart, lineStart);
|
||||
mathContentStart = nextLineStart;
|
||||
activeMathBlockFenceType = MathBlockFenceType.BRACKET;
|
||||
lineStart = nextLineStart;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (activeMathBlockFenceType is MathBlockFenceType.DOLLAR && trimmedLine.SequenceEqual(MATH_BLOCK_MARKER_DOLLAR.AsSpan()))
|
||||
@ -375,8 +373,6 @@ public partial class ContentBlockComponent : MSGComponentBase, IAsyncDisposable
|
||||
|
||||
markdownSegmentStart = nextLineStart;
|
||||
activeMathBlockFenceType = MathBlockFenceType.NONE;
|
||||
lineStart = nextLineStart;
|
||||
continue;
|
||||
}
|
||||
else if (activeMathBlockFenceType is MathBlockFenceType.BRACKET && trimmedLine.SequenceEqual(MATH_BLOCK_MARKER_BRACKET_CLOSE.AsSpan()))
|
||||
{
|
||||
@ -385,8 +381,6 @@ public partial class ContentBlockComponent : MSGComponentBase, IAsyncDisposable
|
||||
|
||||
markdownSegmentStart = nextLineStart;
|
||||
activeMathBlockFenceType = MathBlockFenceType.NONE;
|
||||
lineStart = nextLineStart;
|
||||
continue;
|
||||
}
|
||||
|
||||
lineStart = nextLineStart;
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Text.Json.Serialization;
|
||||
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.RAG.RAGProcesses;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
var block = blocks[i];
|
||||
var isLastBlock = i == blocks.Count - 1;
|
||||
var isSecondLastBlock = i == blocks.Count - 2;
|
||||
@if (!block.HideFromUser)
|
||||
@if (block is { HideFromUser: false, Content: not null })
|
||||
{
|
||||
<ContentBlockComponent
|
||||
@key="@block"
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
@using AIStudio.Tools.PluginSystem.Assistants.DataModel
|
||||
<MudStack Row="true" Class='@this.MergeClasses(this.Class, "mb-3")' Style="@this.Style">
|
||||
<MudStack Row="true" Class='@MergeClasses(this.Class, "mb-3")' Style="@this.Style">
|
||||
@if (this.IsMultiselect)
|
||||
{
|
||||
<MudSelect
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace AIStudio.Components
|
||||
{
|
||||
@ -92,7 +87,7 @@ namespace AIStudio.Components
|
||||
|
||||
private List<AssistantDropdownItem> GetRenderedItems()
|
||||
{
|
||||
var items = this.Items ?? [];
|
||||
var items = this.Items;
|
||||
if (string.IsNullOrWhiteSpace(this.Default.Value))
|
||||
return items;
|
||||
|
||||
@ -122,10 +117,10 @@ namespace AIStudio.Components
|
||||
return item?.Display ?? value;
|
||||
}
|
||||
|
||||
private string MergeClasses(string custom, string fallback)
|
||||
private static string MergeClasses(string custom, string fallback)
|
||||
{
|
||||
var trimmedCustom = custom?.Trim() ?? string.Empty;
|
||||
var trimmedFallback = fallback?.Trim() ?? string.Empty;
|
||||
var trimmedCustom = custom.Trim();
|
||||
var trimmedFallback = fallback.Trim();
|
||||
if (string.IsNullOrEmpty(trimmedCustom))
|
||||
return trimmedFallback;
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ else
|
||||
case TreeItemData treeItem:
|
||||
@if (treeItem.Type is TreeItemType.LOADING)
|
||||
{
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@false" Items="@treeItem.Children">
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@false" Items="@treeItem.Children!">
|
||||
<BodyContent>
|
||||
<MudSkeleton Width="85%" Height="22px"/>
|
||||
</BodyContent>
|
||||
@ -32,7 +32,7 @@ else
|
||||
}
|
||||
else if (treeItem.Type is TreeItemType.CHAT)
|
||||
{
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@treeItem.Expandable" Items="@treeItem.Children" OnClick="@(() => this.LoadChatAsync(treeItem.Path, true))">
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@treeItem.Expandable" Items="@treeItem.Children!" OnClick="@(() => this.LoadChatAsync(treeItem.Path, true))">
|
||||
<BodyContent>
|
||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||
<MudText Style="justify-self: start;">
|
||||
@ -65,7 +65,7 @@ else
|
||||
}
|
||||
else if (treeItem.Type is TreeItemType.WORKSPACE)
|
||||
{
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@treeItem.Expandable" Items="@treeItem.Children" OnClick="@(() => this.OnWorkspaceClicked(treeItem))">
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@treeItem.Expandable" Items="@treeItem.Children!" OnClick="@(() => this.OnWorkspaceClicked(treeItem))">
|
||||
<BodyContent>
|
||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||
<MudText Style="justify-self: start;">
|
||||
@ -86,7 +86,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@treeItem.Expandable" Items="@treeItem.Children">
|
||||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item.Value" Expanded="@item.Expanded" CanExpand="@treeItem.Expandable" Items="@treeItem.Children!">
|
||||
<BodyContent>
|
||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||
<MudText Style="justify-self: start;">
|
||||
|
||||
@ -32,7 +32,6 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
private PluginAssistantAudit? audit;
|
||||
private string promptPreview = string.Empty;
|
||||
private string promptFallbackPreview = string.Empty;
|
||||
private string componentSummary = string.Empty;
|
||||
private ImmutableDictionary<string, string> luaFiles = ImmutableDictionary.Create<string, string>();
|
||||
private IReadOnlyCollection<TreeItemData<ITreeItem>> componentTreeItems = [];
|
||||
private IReadOnlyCollection<TreeItemData<ITreeItem>> fileSystemTreeItems = [];
|
||||
@ -77,7 +76,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
{
|
||||
this.promptPreview = await this.plugin.BuildAuditPromptPreviewAsync();
|
||||
this.promptFallbackPreview = this.plugin.BuildAuditPromptFallbackPreview();
|
||||
this.componentSummary = this.plugin.CreateAuditComponentSummary();
|
||||
this.plugin.CreateAuditComponentSummary();
|
||||
this.componentTreeItems = this.CreateAuditTreeItems(this.plugin.RootComponent);
|
||||
this.fileSystemTreeItems = this.CreatePluginFileSystemTreeItems(this.plugin.PluginPath);
|
||||
this.luaFiles = this.plugin.ReadAllLuaFiles();
|
||||
@ -262,7 +261,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
if (value is IDictionary dictionary)
|
||||
return this.CreateDictionaryChildren(dictionary, depth);
|
||||
|
||||
if (value is IEnumerable enumerable && value is not string)
|
||||
if (value is IEnumerable enumerable and not string)
|
||||
return this.CreateEnumerableChildren(enumerable, depth);
|
||||
|
||||
return this.CreateObjectChildren(value, depth);
|
||||
@ -328,11 +327,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
};
|
||||
}
|
||||
|
||||
private TreeItemData<ITreeItem> CreateFileTreeItem(string filePath, int depth)
|
||||
{
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
|
||||
return new TreeItemData<ITreeItem>
|
||||
private TreeItemData<ITreeItem> CreateFileTreeItem(string filePath, int depth) => new()
|
||||
{
|
||||
Expanded = depth < 2,
|
||||
Expandable = false,
|
||||
@ -340,14 +335,13 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
{
|
||||
Text = Path.GetFileName(filePath),
|
||||
Caption = string.Empty,
|
||||
Icon = this.GetFileIcon(filePath),
|
||||
Icon = GetFileIcon(filePath),
|
||||
Expandable = false,
|
||||
IsComponent = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private string GetFileIcon(string filePath)
|
||||
private static string GetFileIcon(string filePath)
|
||||
{
|
||||
var extension = Path.GetExtension(filePath);
|
||||
return extension.ToLowerInvariant() switch
|
||||
@ -376,7 +370,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase
|
||||
|
||||
/// <summary>
|
||||
/// Falls back to public instance properties for simple DTO-style values such as dropdown items.
|
||||
/// Getter failures are treated defensively so the audit dialog never crashes because of a problematic property.
|
||||
/// Getter failures are treated defensively, so the audit dialog never crashes because of a problematic property.
|
||||
/// </summary>
|
||||
private List<TreeItemData<ITreeItem>> CreateObjectChildren(object value, int depth)
|
||||
{
|
||||
|
||||
@ -19,7 +19,7 @@ public sealed class AssistantPluginAuditService(AssistantAuditAgent auditAgent)
|
||||
PluginHash = plugin.ComputeAuditHash(),
|
||||
AuditedAtUtc = DateTimeOffset.UtcNow,
|
||||
AuditProviderId = provider.Id,
|
||||
AuditProviderName = provider == AIStudio.Settings.Provider.NONE
|
||||
AuditProviderName = provider == Settings.Provider.NONE
|
||||
? string.Empty
|
||||
: provider.InstanceName,
|
||||
Level = AssistantAuditLevelExtensions.Parse(result.Level),
|
||||
|
||||
@ -16,7 +16,7 @@ public sealed class AssistantButton : NamedAssistantComponentBase
|
||||
|
||||
public bool IsIconButton
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsIconButton), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsIconButton));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsIconButton), value);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public sealed class AssistantButton : NamedAssistantComponentBase
|
||||
|
||||
public bool IsFullWidth
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsFullWidth), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsFullWidth));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsFullWidth), value);
|
||||
}
|
||||
|
||||
|
||||
@ -26,13 +26,13 @@ public sealed class AssistantButtonGroup : NamedAssistantComponentBase
|
||||
|
||||
public bool OverrideStyles
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.OverrideStyles), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.OverrideStyles));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.OverrideStyles), value);
|
||||
}
|
||||
|
||||
public bool Vertical
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.Vertical), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.Vertical));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.Vertical), value);
|
||||
}
|
||||
|
||||
|
||||
@ -7,31 +7,23 @@ internal static class AssistantComponentPropHelper
|
||||
public static string ReadString(Dictionary<string, object> props, string key)
|
||||
{
|
||||
if (props.TryGetValue(key, out var value))
|
||||
{
|
||||
return value?.ToString() ?? string.Empty;
|
||||
}
|
||||
return value.ToString() ?? string.Empty;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static void WriteString(Dictionary<string, object> props, string key, string value)
|
||||
{
|
||||
props[key] = value ?? string.Empty;
|
||||
}
|
||||
public static void WriteString(Dictionary<string, object> props, string key, string value) => props[key] = value;
|
||||
|
||||
public static int ReadInt(Dictionary<string, object> props, string key, int fallback = 0)
|
||||
{
|
||||
return props.TryGetValue(key, out var value) && int.TryParse(value?.ToString(), out var i) ? i : fallback;
|
||||
return props.TryGetValue(key, out var value) && int.TryParse(value.ToString(), out var i) ? i : fallback;
|
||||
}
|
||||
|
||||
public static void WriteInt(Dictionary<string, object> props, string key, int value)
|
||||
{
|
||||
props[key] = value;
|
||||
}
|
||||
public static void WriteInt(Dictionary<string, object> props, string key, int value) => props[key] = value;
|
||||
|
||||
public static int? ReadNullableInt(Dictionary<string, object> props, string key)
|
||||
{
|
||||
return props.TryGetValue(key, out var value) && int.TryParse(value?.ToString(), out var i) ? i : null;
|
||||
return props.TryGetValue(key, out var value) && int.TryParse(value.ToString(), out var i) ? i : null;
|
||||
}
|
||||
|
||||
public static void WriteNullableInt(Dictionary<string, object> props, string key, int? value)
|
||||
@ -47,10 +39,7 @@ internal static class AssistantComponentPropHelper
|
||||
return props.TryGetValue(key, out var value) && bool.TryParse(value.ToString(), out var b) ? b : fallback;
|
||||
}
|
||||
|
||||
public static void WriteBool(Dictionary<string, object> props, string key, bool value)
|
||||
{
|
||||
props[key] = value;
|
||||
}
|
||||
public static void WriteBool(Dictionary<string, object> props, string key, bool value) => props[key] = value;
|
||||
|
||||
public static void WriteObject(Dictionary<string, object> props, string key, object? value)
|
||||
{
|
||||
@ -60,9 +49,9 @@ internal static class AssistantComponentPropHelper
|
||||
props[key] = value;
|
||||
}
|
||||
|
||||
public static MudBlazor.Color GetColor(string value, Color fallback) => Enum.TryParse<MudBlazor.Color>(value, out var color) ? color : fallback;
|
||||
public static MudBlazor.Variant GetVariant(string value, Variant fallback) => Enum.TryParse<MudBlazor.Variant>(value, out var variant) ? variant : fallback;
|
||||
public static MudBlazor.Adornment GetAdornment(string value, Adornment fallback) => Enum.TryParse<MudBlazor.Adornment>(value, out var adornment) ? adornment : fallback;
|
||||
public static Color GetColor(string value, Color fallback) => Enum.TryParse<Color>(value, out var color) ? color : fallback;
|
||||
public static Variant GetVariant(string value, Variant fallback) => Enum.TryParse<Variant>(value, out var variant) ? variant : fallback;
|
||||
public static Adornment GetAdornment(string value, Adornment fallback) => Enum.TryParse<Adornment>(value, out var adornment) ? adornment : fallback;
|
||||
public static string GetIconSvg(string value) => MudBlazorIconRegistry.TryGetSvg(value.TrimStart('@'), out var svg) ? svg : string.Empty;
|
||||
public static Size GetComponentSize(string value, Size fallback) => Enum.TryParse<Size>(value, out var size) ? size : fallback;
|
||||
public static Justify? GetJustify(string value) => Enum.TryParse<Justify>(value, out var justify) ? justify : null;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Globalization;
|
||||
using MudBlazor;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
|
||||
@ -42,13 +42,13 @@ internal sealed class AssistantDropdown : StatefulAssistantComponentBase
|
||||
|
||||
public bool IsMultiselect
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsMultiselect), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsMultiselect));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsMultiselect), value);
|
||||
}
|
||||
|
||||
public bool HasSelectAll
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HasSelectAll), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HasSelectAll));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HasSelectAll), value);
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ public sealed class AssistantState
|
||||
public readonly Dictionary<string, string> Text = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, string> SingleSelect = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, HashSet<string>> MultiSelect = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, bool> Bools = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, bool> Booleans = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, WebContentState> WebContent = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, FileContentState> FileContent = new(StringComparer.Ordinal);
|
||||
public readonly Dictionary<string, string> Colors = new(StringComparer.Ordinal);
|
||||
@ -21,7 +21,7 @@ public sealed class AssistantState
|
||||
this.Text.Clear();
|
||||
this.SingleSelect.Clear();
|
||||
this.MultiSelect.Clear();
|
||||
this.Bools.Clear();
|
||||
this.Booleans.Clear();
|
||||
this.WebContent.Clear();
|
||||
this.FileContent.Clear();
|
||||
this.Colors.Clear();
|
||||
@ -40,7 +40,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var textValue))
|
||||
return false;
|
||||
|
||||
this.Text[fieldName] = textValue ?? string.Empty;
|
||||
this.Text[fieldName] = textValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var singleSelectValue))
|
||||
return false;
|
||||
|
||||
this.SingleSelect[fieldName] = singleSelectValue ?? string.Empty;
|
||||
this.SingleSelect[fieldName] = singleSelectValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -70,13 +70,13 @@ public sealed class AssistantState
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.Bools.ContainsKey(fieldName))
|
||||
if (this.Booleans.ContainsKey(fieldName))
|
||||
{
|
||||
expectedType = "boolean";
|
||||
if (!value.TryRead<bool>(out var boolValue))
|
||||
return false;
|
||||
|
||||
this.Bools[fieldName] = boolValue;
|
||||
this.Booleans[fieldName] = boolValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var webContentValue))
|
||||
return false;
|
||||
|
||||
webContentState.Content = webContentValue ?? string.Empty;
|
||||
webContentState.Content = webContentValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var fileContentValue))
|
||||
return false;
|
||||
|
||||
fileContentState.Content = fileContentValue ?? string.Empty;
|
||||
fileContentState.Content = fileContentValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var colorValue))
|
||||
return false;
|
||||
|
||||
this.Colors[fieldName] = colorValue ?? string.Empty;
|
||||
this.Colors[fieldName] = colorValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var dateValue))
|
||||
return false;
|
||||
|
||||
this.Dates[fieldName] = dateValue ?? string.Empty;
|
||||
this.Dates[fieldName] = dateValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var dateRangeValue))
|
||||
return false;
|
||||
|
||||
this.DateRanges[fieldName] = dateRangeValue ?? string.Empty;
|
||||
this.DateRanges[fieldName] = dateRangeValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ public sealed class AssistantState
|
||||
if (!value.TryRead<string>(out var timeValue))
|
||||
return false;
|
||||
|
||||
this.Times[fieldName] = timeValue ?? string.Empty;
|
||||
this.Times[fieldName] = timeValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ public sealed class AssistantState
|
||||
{
|
||||
target[named.Name] = new LuaTable
|
||||
{
|
||||
["Type"] = Enum.GetName<AssistantComponentType>(component.Type) ?? string.Empty,
|
||||
["Type"] = Enum.GetName(component.Type) ?? string.Empty,
|
||||
["Value"] = component is IStatefulAssistantComponent ? this.ReadValueForLua(named.Name) : LuaValue.Nil,
|
||||
["Props"] = this.CreatePropsTable(component),
|
||||
};
|
||||
@ -177,12 +177,12 @@ public sealed class AssistantState
|
||||
return singleSelectValue;
|
||||
if (this.MultiSelect.TryGetValue(name, out var multiSelectValue))
|
||||
return AssistantLuaConversion.CreateLuaArray(multiSelectValue.OrderBy(static value => value, StringComparer.Ordinal));
|
||||
if (this.Bools.TryGetValue(name, out var boolValue))
|
||||
if (this.Booleans.TryGetValue(name, out var boolValue))
|
||||
return boolValue;
|
||||
if (this.WebContent.TryGetValue(name, out var webContentValue))
|
||||
return webContentValue.Content ?? string.Empty;
|
||||
return webContentValue.Content;
|
||||
if (this.FileContent.TryGetValue(name, out var fileContentValue))
|
||||
return fileContentValue.Content ?? string.Empty;
|
||||
return fileContentValue.Content;
|
||||
if (this.Colors.TryGetValue(name, out var colorValue))
|
||||
return colorValue;
|
||||
if (this.Dates.TryGetValue(name, out var dateValue))
|
||||
@ -211,6 +211,7 @@ public sealed class AssistantState
|
||||
continue;
|
||||
|
||||
if (!AssistantLuaConversion.TryWriteAssistantValue(table, key, value))
|
||||
// ReSharper disable once RedundantJumpStatement
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -17,13 +17,13 @@ public sealed class AssistantSwitch : StatefulAssistantComponentBase
|
||||
|
||||
public bool Value
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.Value), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.Value));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.Value), value);
|
||||
}
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.Disabled), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.Disabled));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.Disabled), value);
|
||||
}
|
||||
|
||||
@ -91,19 +91,19 @@ public sealed class AssistantSwitch : StatefulAssistantComponentBase
|
||||
|
||||
public override void InitializeState(AssistantState state)
|
||||
{
|
||||
if (!state.Bools.ContainsKey(this.Name))
|
||||
state.Bools[this.Name] = this.Value;
|
||||
if (!state.Booleans.ContainsKey(this.Name))
|
||||
state.Booleans[this.Name] = this.Value;
|
||||
}
|
||||
|
||||
public override string UserPromptFallback(AssistantState state)
|
||||
{
|
||||
state.Bools.TryGetValue(this.Name, out var userDecision);
|
||||
state.Booleans.TryGetValue(this.Name, out var userDecision);
|
||||
return this.BuildAuditPromptBlock(userDecision.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public MudBlazor.Color GetColor(string colorString) => Enum.TryParse<Color>(colorString, out var color) ? color : MudBlazor.Color.Inherit;
|
||||
public static Color GetColor(string colorString) => Enum.TryParse<Color>(colorString, out var color) ? color : Color.Inherit;
|
||||
public Placement GetLabelPlacement() => Enum.TryParse<Placement>(this.LabelPlacement, out var placement) ? placement : Placement.Right;
|
||||
public string GetIconSvg() => MudBlazorIconRegistry.TryGetSvg(this.Icon, out var svg) ? svg : string.Empty;
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
using AIStudio.Tools.PluginSystem.Assistants.Icons;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
internal sealed class AssistantTextArea : StatefulAssistantComponentBase
|
||||
@ -22,7 +20,7 @@ internal sealed class AssistantTextArea : StatefulAssistantComponentBase
|
||||
|
||||
public bool HelperTextOnFocus
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HelperTextOnFocus), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HelperTextOnFocus));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HelperTextOnFocus), value);
|
||||
}
|
||||
|
||||
@ -76,13 +74,13 @@ internal sealed class AssistantTextArea : StatefulAssistantComponentBase
|
||||
|
||||
public bool IsSingleLine
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSingleLine), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSingleLine));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsSingleLine), value);
|
||||
}
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.ReadOnly), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.ReadOnly));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.ReadOnly), value);
|
||||
}
|
||||
|
||||
@ -114,7 +112,7 @@ internal sealed class AssistantTextArea : StatefulAssistantComponentBase
|
||||
|
||||
#endregion
|
||||
|
||||
public Adornment GetAdornmentPos() => Enum.TryParse<MudBlazor.Adornment>(this.Adornment, out var position) ? position : MudBlazor.Adornment.Start;
|
||||
public Adornment GetAdornmentPos() => Enum.TryParse<Adornment>(this.Adornment, out var position) ? position : MudBlazor.Adornment.Start;
|
||||
|
||||
public Color GetAdornmentColor() => Enum.TryParse<Color>(this.AdornmentColor, out var color) ? color : Color.Default;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ internal sealed class AssistantTimePicker : StatefulAssistantComponentBase
|
||||
|
||||
public bool AmPm
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.AmPm), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.AmPm));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.AmPm), value);
|
||||
}
|
||||
|
||||
|
||||
@ -8,13 +8,13 @@ internal sealed class AssistantAccordion : NamedAssistantComponentBase
|
||||
|
||||
public bool AllowMultiSelection
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.AllowMultiSelection), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.AllowMultiSelection));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.AllowMultiSelection), value);
|
||||
}
|
||||
|
||||
public bool IsDense
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDense), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDense));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsDense), value);
|
||||
}
|
||||
|
||||
@ -26,13 +26,13 @@ internal sealed class AssistantAccordion : NamedAssistantComponentBase
|
||||
|
||||
public bool IsSquare
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSquare), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSquare));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsSquare), value);
|
||||
}
|
||||
|
||||
public int Elevation
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadInt(this.Props, nameof(this.Elevation), 0);
|
||||
get => AssistantComponentPropHelper.ReadInt(this.Props, nameof(this.Elevation));
|
||||
set => AssistantComponentPropHelper.WriteInt(this.Props, nameof(this.Elevation), value);
|
||||
}
|
||||
|
||||
|
||||
@ -40,19 +40,19 @@ internal sealed class AssistantAccordionSection : NamedAssistantComponentBase
|
||||
|
||||
public bool IsDisabled
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDisabled), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDisabled));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsDisabled), value);
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsExpanded), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsExpanded));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsExpanded), value);
|
||||
}
|
||||
|
||||
public bool IsDense
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDense), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDense));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsDense), value);
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ internal sealed class AssistantAccordionSection : NamedAssistantComponentBase
|
||||
|
||||
public bool HideIcon
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HideIcon), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HideIcon));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HideIcon), value);
|
||||
}
|
||||
|
||||
|
||||
@ -50,13 +50,13 @@ internal sealed class AssistantPaper : NamedAssistantComponentBase
|
||||
|
||||
public bool IsOutlined
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsOutlined), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsOutlined));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsOutlined), value);
|
||||
}
|
||||
|
||||
public bool IsSquare
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSquare), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSquare));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsSquare), value);
|
||||
}
|
||||
|
||||
|
||||
@ -8,13 +8,13 @@ internal sealed class AssistantStack : NamedAssistantComponentBase
|
||||
|
||||
public bool IsRow
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsRow), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsRow));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsRow), value);
|
||||
}
|
||||
|
||||
public bool IsReverse
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsReverse), false);
|
||||
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsReverse));
|
||||
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsReverse), value);
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ public static class PluginAssistantSecurityResolver
|
||||
return MudBlazor.Icons.Material.Filled.LockOpen;
|
||||
}
|
||||
|
||||
// ReSharper disable UnusedParameter.Local
|
||||
private static string GetSecurityBadgeIcon(bool requiresAudit, bool hasAudit, bool hasHashMismatch, bool isBlocked, bool canOverride)
|
||||
{
|
||||
if (hasHashMismatch)
|
||||
@ -61,6 +62,7 @@ public static class PluginAssistantSecurityResolver
|
||||
|
||||
return MudBlazor.Icons.Material.Filled.Security;
|
||||
}
|
||||
// ReSharper restore UnusedParameter.Local
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the effective security state for an assistant plugin.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user