mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-29 19:11:38 +00:00
added class and style properties to every component
This commit is contained in:
parent
024fb5821c
commit
6ad7aba58e
@ -12,7 +12,7 @@
|
||||
if (component is AssistantTextArea textArea)
|
||||
{
|
||||
var lines = textArea.IsSingleLine ? 1 : 6;
|
||||
<MudTextField T="string" @bind-Text="@this.inputFields[textArea.Name]" Label="@textArea.Label" ReadOnly="@textArea.ReadOnly" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Variant="Variant.Outlined" Lines="@lines" AutoGrow="@true" MaxLines="12" Class="mb-3"/>
|
||||
<MudTextField T="string" @bind-Text="@this.inputFields[textArea.Name]" Label="@textArea.Label" ReadOnly="@textArea.ReadOnly" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Variant="Variant.Outlined" Lines="@lines" AutoGrow="@true" MaxLines="12" Class='@MergeClass(textArea.Class, "mb-3")' Style="@this.GetOptionalStyle(textArea.Style)"/>
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.IMAGE:
|
||||
@ -23,7 +23,7 @@
|
||||
{
|
||||
var image = assistantImage;
|
||||
<div Class="mb-4">
|
||||
<MudImage Fluid="true" Src="@resolvedSource" Alt="@image.Alt" Class="rounded-lg mb-2" Elevation="20"/>
|
||||
<MudImage Fluid="true" Src="@resolvedSource" Alt="@image.Alt" Class='@MergeClass(image.Class, "rounded-lg mb-2")' Style="@this.GetOptionalStyle(image.Style)" Elevation="20"/>
|
||||
@if (!string.IsNullOrWhiteSpace(image.Caption))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Align="Align.Center">@image.Caption</MudText>
|
||||
@ -39,13 +39,17 @@
|
||||
ProviderSettings="@this.providerSettings"
|
||||
@bind-AgentIsRunning="@webState.AgentIsRunning"
|
||||
@bind-Preselect="@webState.Preselect"
|
||||
@bind-PreselectContentCleanerAgent="@webState.PreselectContentCleanerAgent" />
|
||||
@bind-PreselectContentCleanerAgent="@webState.PreselectContentCleanerAgent"
|
||||
Class="@webContent.Class"
|
||||
Style="@webContent.Style" />
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.FILE_CONTENT_READER:
|
||||
if (component is AssistantFileContentReader fileContent && this.fileContentFields.TryGetValue(fileContent.Name, out var fileState))
|
||||
{
|
||||
<ReadFileContent @bind-FileContent="@fileState.Content" />
|
||||
<ReadFileContent @bind-FileContent="@fileState.Content"
|
||||
Class="@fileContent.Class"
|
||||
Style="@fileContent.Style" />
|
||||
}
|
||||
break;
|
||||
|
||||
@ -56,26 +60,34 @@
|
||||
@bind-Value="@this.dropdownFields[assistantDropdown.Name]"
|
||||
Default="@assistantDropdown.Default"
|
||||
Label="@assistantDropdown.Label"
|
||||
Icon="@Icons.Material.Filled.Translate"/>
|
||||
Icon="@Icons.Material.Filled.Translate"
|
||||
Class="@assistantDropdown.Class"
|
||||
Style="@assistantDropdown.Style"/>
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.PROVIDER_SELECTION:
|
||||
if (component is AssistantProviderSelection providerSelection)
|
||||
{
|
||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"
|
||||
Class="@providerSelection.Class"
|
||||
Style="@providerSelection.Style"/>
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.PROFILE_SELECTION:
|
||||
if (component is AssistantProfileSelection profileSelection)
|
||||
{
|
||||
var selection = profileSelection;
|
||||
<ProfileFormSelection Validation="@((Profile profile) => this.ValidateProfileSelection(selection, profile))" @bind-Profile="@this.currentProfile"/>
|
||||
<ProfileFormSelection Validation="@((Profile profile) => this.ValidateProfileSelection(selection, profile))" @bind-Profile="@this.currentProfile"
|
||||
Class="@selection.Class"
|
||||
Style="@selection.Style"/>
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.SWITCH:
|
||||
if (component is AssistantSwitch assistantSwitch)
|
||||
{
|
||||
<MudTextSwitch Label="@assistantSwitch.Label" @bind-Value="@this.switchFields[assistantSwitch.Name]" LabelOn="@assistantSwitch.LabelOn" LabelOff="@assistantSwitch.LabelOff" />
|
||||
<MudTextSwitch Label="@assistantSwitch.Label" @bind-Value="@this.switchFields[assistantSwitch.Name]" LabelOn="@assistantSwitch.LabelOn" LabelOff="@assistantSwitch.LabelOff"
|
||||
Class="@assistantSwitch.Class"
|
||||
Style="@this.GetOptionalStyle(assistantSwitch.Style)" />
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.HEADING:
|
||||
@ -85,16 +97,16 @@
|
||||
@switch (assistantHeading.Level)
|
||||
{
|
||||
case 1:
|
||||
<MudText Typo="Typo.h4">@heading.Text</MudText>
|
||||
<MudText Typo="Typo.h4" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
|
||||
break;
|
||||
case 2:
|
||||
<MudText Typo="Typo.h5">@heading.Text</MudText>
|
||||
<MudText Typo="Typo.h5" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
|
||||
break;
|
||||
case 3:
|
||||
<MudText Typo="Typo.h6">@heading.Text</MudText>
|
||||
<MudText Typo="Typo.h6" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
|
||||
break;
|
||||
default:
|
||||
<MudText Typo="Typo.h4">@heading.Text</MudText>
|
||||
<MudText Typo="Typo.h4" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -103,14 +115,14 @@
|
||||
if (component is AssistantText assistantText)
|
||||
{
|
||||
var text = assistantText;
|
||||
<MudText Typo="Typo.body1" Class="mb-3">@text.Content</MudText>
|
||||
<MudText Typo="Typo.body1" Class='@MergeClass(text.Class, "mb-3")' Style="@this.GetOptionalStyle(text.Style)">@text.Content</MudText>
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.LIST:
|
||||
if (component is AssistantList assistantList)
|
||||
{
|
||||
var list = assistantList;
|
||||
<MudList T="string" Class="mb-6">
|
||||
<MudList T="string" Class='@MergeClass(list.Class, "mb-6")' Style="@this.GetOptionalStyle(list.Style)">
|
||||
@foreach (var item in list.Items)
|
||||
{
|
||||
@if (item.Type == "LINK")
|
||||
|
||||
@ -308,6 +308,21 @@ public partial class AssistantDynamic : AssistantBaseCore<SettingsDialogDynamic>
|
||||
return prompt;
|
||||
}
|
||||
|
||||
private static string MergeClass(string customClass, string fallback)
|
||||
{
|
||||
var trimmedCustom = customClass?.Trim() ?? string.Empty;
|
||||
var trimmedFallback = fallback?.Trim() ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(trimmedCustom))
|
||||
return trimmedFallback;
|
||||
|
||||
if (string.IsNullOrEmpty(trimmedFallback))
|
||||
return trimmedCustom;
|
||||
|
||||
return $"{trimmedCustom} {trimmedFallback}";
|
||||
}
|
||||
|
||||
private string? GetOptionalStyle(string? style) => string.IsNullOrWhiteSpace(style) ? null : style;
|
||||
|
||||
private string? ValidateProfileSelection(AssistantProfileSelection profileSelection, Profile profile)
|
||||
{
|
||||
if (profile == default || profile == Profile.NO_PROFILE)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<MudStack Row="true" Class="mb-3">
|
||||
<MudStack Row="true" Class='@this.MergeClasses(this.Class, "mb-3")' Style="@this.Style">
|
||||
<MudSelect
|
||||
T="string"
|
||||
Value="@this.Value"
|
||||
|
||||
@ -9,26 +9,23 @@ namespace AIStudio.Components
|
||||
{
|
||||
public partial class DynamicAssistantDropdown : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public List<AssistantDropdownItem> Items { get; set; } = new();
|
||||
[Parameter] public List<AssistantDropdownItem> Items { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public AssistantDropdownItem Default { get; set; } = new();
|
||||
[Parameter] public AssistantDropdownItem Default { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public string Value { get; set; } = string.Empty;
|
||||
[Parameter] public string Value { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> ValueChanged { get; set; }
|
||||
[Parameter] public EventCallback<string> ValueChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Label { get; set; } = string.Empty;
|
||||
[Parameter] public string Label { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public Func<string, string?> ValidateSelection { get; set; } = _ => null;
|
||||
[Parameter] public Func<string, string?> ValidateSelection { get; set; } = _ => null;
|
||||
|
||||
[Parameter]
|
||||
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
|
||||
[Parameter] public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
|
||||
|
||||
[Parameter] public string Class { get; set; } = string.Empty;
|
||||
|
||||
[Parameter] public string Style { get; set; } = string.Empty;
|
||||
|
||||
private async Task OnValueChanged(string newValue)
|
||||
{
|
||||
@ -38,5 +35,18 @@ namespace AIStudio.Components
|
||||
await this.ValueChanged.InvokeAsync(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
internal string MergeClasses(string custom, string fallback)
|
||||
{
|
||||
var trimmedCustom = custom?.Trim() ?? string.Empty;
|
||||
var trimmedFallback = fallback?.Trim() ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(trimmedCustom))
|
||||
return trimmedFallback;
|
||||
|
||||
if (string.IsNullOrEmpty(trimmedFallback))
|
||||
return trimmedCustom;
|
||||
|
||||
return $"{trimmedCustom} {trimmedFallback}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantButton : AssistantComponentBase
|
||||
internal sealed class AssistantButton : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.BUTTON;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,23 +8,30 @@ public class AssistantButton : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
public string Text
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Text), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Text)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Text));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Text), value);
|
||||
}
|
||||
|
||||
public string Action
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Action), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Action)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Action));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Action), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
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 string.Empty;
|
||||
}
|
||||
|
||||
public static void WriteString(Dictionary<string, object> props, string key, string value)
|
||||
{
|
||||
props[key] = value ?? string.Empty;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AssistantDropdown : AssistantComponentBase
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
internal sealed class AssistantDropdown : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.DROPDOWN;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,25 +10,20 @@ public class AssistantDropdown : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
|
||||
public string Label
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Label), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Label)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
|
||||
}
|
||||
|
||||
public string UserPrompt
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.UserPrompt)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
|
||||
}
|
||||
|
||||
public AssistantDropdownItem Default
|
||||
@ -78,4 +75,16 @@ public class AssistantDropdown : AssistantComponentBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantFileContentReader : AssistantComponentBase
|
||||
internal sealed class AssistantFileContentReader : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.FILE_CONTENT_READER;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,17 +8,25 @@ public class AssistantFileContentReader : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
|
||||
public string UserPrompt
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.UserPrompt)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantHeading : AssistantComponentBase
|
||||
internal sealed class AssistantHeading : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.HEADING;
|
||||
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
|
||||
public List<IAssistantComponent> Children { get; set; } = new();
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Text), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Text)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Text));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Text), value);
|
||||
}
|
||||
|
||||
public int Level
|
||||
@ -24,4 +22,16 @@ public class AssistantHeading : AssistantComponentBase
|
||||
: 2;
|
||||
set => this.Props[nameof(this.Level)] = value;
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantImage : AssistantComponentBase
|
||||
internal sealed class AssistantImage : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.IMAGE;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,25 +10,31 @@ public class AssistantImage : AssistantComponentBase
|
||||
|
||||
public string Src
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Src), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Src)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Src));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Src), value);
|
||||
}
|
||||
|
||||
public string Alt
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Alt), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Alt)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Alt));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Alt), value);
|
||||
}
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Caption), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Caption)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Caption));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Caption), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantList : AssistantComponentBase
|
||||
internal sealed class AssistantList : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.LIST;
|
||||
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
|
||||
public List<IAssistantComponent> Children { get; set; } = new();
|
||||
|
||||
public List<AssistantListItem> Items
|
||||
@ -15,4 +15,16 @@ public class AssistantList : AssistantComponentBase
|
||||
: [];
|
||||
set => this.Props[nameof(this.Items)] = value;
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantProfileSelection : AssistantComponentBase
|
||||
internal sealed class AssistantProfileSelection : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.PROFILE_SELECTION;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -10,9 +10,19 @@ public class AssistantProfileSelection : AssistantComponentBase
|
||||
|
||||
public string ValidationMessage
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.ValidationMessage), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.ValidationMessage)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.ValidationMessage));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.ValidationMessage), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AssistantProviderSelection : AssistantComponentBase
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
internal sealed class AssistantProviderSelection : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.PROVIDER_SELECTION;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,16 +10,25 @@ public class AssistantProviderSelection : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
|
||||
public string Label
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Label), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Label)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AssistantSwitch : AssistantComponentBase
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
internal sealed class AssistantSwitch : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.SWITCH;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,18 +10,14 @@ public class AssistantSwitch : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
|
||||
public string Label
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Label), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Label)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
|
||||
}
|
||||
|
||||
public bool Value
|
||||
@ -30,25 +28,31 @@ public class AssistantSwitch : AssistantComponentBase
|
||||
|
||||
public string UserPrompt
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var val)
|
||||
? val.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.UserPrompt)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
|
||||
}
|
||||
|
||||
public string LabelOn
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.LabelOn), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.LabelOn)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.LabelOn));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.LabelOn), value);
|
||||
}
|
||||
|
||||
public string LabelOff
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.LabelOff), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.LabelOff)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.LabelOff));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.LabelOff), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantText : AssistantComponentBase
|
||||
internal sealed class AssistantText : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.TEXT;
|
||||
|
||||
@ -10,9 +12,19 @@ public class AssistantText : AssistantComponentBase
|
||||
|
||||
public string Content
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Content), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Content)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Content));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Content), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AssistantTextArea : AssistantComponentBase
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
internal sealed class AssistantTextArea : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.TEXT_AREA;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,34 +10,26 @@ public class AssistantTextArea : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var val)
|
||||
? val.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
|
||||
public string Label
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Label), out var val)
|
||||
? val.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Label)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
|
||||
}
|
||||
|
||||
public string UserPrompt
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var val)
|
||||
? val.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.UserPrompt)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
|
||||
}
|
||||
|
||||
public string PrefillText
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.PrefillText), out var val)
|
||||
? val.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.PrefillText)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.PrefillText));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.PrefillText), value);
|
||||
}
|
||||
|
||||
public bool IsSingleLine
|
||||
@ -49,4 +43,16 @@ public class AssistantTextArea : AssistantComponentBase
|
||||
get => this.Props.TryGetValue(nameof(this.ReadOnly), out var val) && val is true;
|
||||
set => this.Props[nameof(this.ReadOnly)] = value;
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||||
|
||||
public class AssistantWebContentReader : AssistantComponentBase
|
||||
internal sealed class AssistantWebContentReader : AssistantComponentBase
|
||||
{
|
||||
public override AssistantComponentType Type => AssistantComponentType.WEB_CONTENT_READER;
|
||||
public Dictionary<string, object> Props { get; set; } = new();
|
||||
@ -8,18 +10,14 @@ public class AssistantWebContentReader : AssistantComponentBase
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.Name), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.Name)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||
}
|
||||
|
||||
public string UserPrompt
|
||||
{
|
||||
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var v)
|
||||
? v.ToString() ?? string.Empty
|
||||
: string.Empty;
|
||||
set => this.Props[nameof(this.UserPrompt)] = value;
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
|
||||
}
|
||||
|
||||
public bool Preselect
|
||||
@ -33,4 +31,16 @@ public class AssistantWebContentReader : AssistantComponentBase
|
||||
get => this.Props.TryGetValue(nameof(this.PreselectContentCleanerAgent), out var v) && v is true;
|
||||
set => this.Props[nameof(this.PreselectContentCleanerAgent)] = value;
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,55 +7,55 @@ public static class ComponentPropSpecs
|
||||
{
|
||||
[AssistantComponentType.FORM] = new(
|
||||
required: ["Children"],
|
||||
optional: []
|
||||
optional: ["Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.TEXT_AREA] = new(
|
||||
required: ["Name", "Label"],
|
||||
optional: ["UserPrompt", "PrefillText", "ReadOnly", "IsSingleLine"]
|
||||
optional: ["UserPrompt", "PrefillText", "ReadOnly", "IsSingleLine", "Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.BUTTON] = new(
|
||||
required: ["Name", "Text", "Action"],
|
||||
optional: []
|
||||
optional: ["Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.DROPDOWN] = new(
|
||||
required: ["Name", "Label", "Default", "Items"],
|
||||
optional: ["UserPrompt"]
|
||||
optional: ["UserPrompt", "Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.PROVIDER_SELECTION] = new(
|
||||
required: ["Name", "Label"],
|
||||
optional: []
|
||||
optional: ["Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.PROFILE_SELECTION] = new(
|
||||
required: [],
|
||||
optional: ["ValidationMessage"]
|
||||
optional: ["ValidationMessage", "Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.SWITCH] = new(
|
||||
required: ["Name", "Label", "LabelOn", "LabelOff", "Value"],
|
||||
optional: ["UserPrompt"]
|
||||
optional: ["UserPrompt", "Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.HEADING] = new(
|
||||
required: ["Text", "Level"],
|
||||
optional: []
|
||||
optional: ["Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.TEXT] = new(
|
||||
required: ["Content"],
|
||||
optional: []
|
||||
optional: ["Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.LIST] = new(
|
||||
required: ["Items"],
|
||||
optional: []
|
||||
optional: ["Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.WEB_CONTENT_READER] = new(
|
||||
required: ["Name"],
|
||||
optional: ["UserPrompt", "Preselect", "PreselectContentCleanerAgent"]
|
||||
optional: ["UserPrompt", "Preselect", "PreselectContentCleanerAgent", "Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.FILE_CONTENT_READER] = new(
|
||||
required: ["Name"],
|
||||
optional: ["UserPrompt"]
|
||||
optional: ["UserPrompt", "Class", "Style"]
|
||||
),
|
||||
[AssistantComponentType.IMAGE] = new(
|
||||
required: ["Src"],
|
||||
optional: ["Alt", "Caption"]
|
||||
optional: ["Alt", "Caption", "Class", "Style"]
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user