Added new descriptive heading and text components

This commit is contained in:
krut_ni 2026-02-10 16:12:59 +01:00
parent 9374b56789
commit bc50b3728c
7 changed files with 100 additions and 0 deletions

View File

@ -36,5 +36,33 @@
<MudTextSwitch Label="@assistantSwitch.Label" @bind-Value="@this.switchFields[assistantSwitch.Name]" LabelOn="@assistantSwitch.LabelOn" LabelOff="@assistantSwitch.LabelOff" />
}
break;
case AssistantUiCompontentType.HEADING:
if (component is AssistantHeading assistantHeading)
{
var heading = assistantHeading;
@switch (assistantHeading.Level)
{
case 1:
<MudText Typo="Typo.h4">@heading.Text</MudText>
break;
case 2:
<MudText Typo="Typo.h5">@heading.Text</MudText>
break;
case 3:
<MudText Typo="Typo.h6">@heading.Text</MudText>
break;
default:
<MudText Typo="Typo.h4">@heading.Text</MudText>
break;
}
}
break;
case AssistantUiCompontentType.TEXT:
if (component is AssistantText assistantText)
{
var text = assistantText;
<MudText Typo="Typo.body1" Class="mb-3">@text.Content</MudText>
}
break;
}
}

View File

@ -106,6 +106,19 @@ ASSISTANT = {
["Label"] = "LLM auswählen"
}
},
{
["Type"] = "HEADING", -- descriptive component for headings
["Props"] = {
["Text"] = "This is a Section Heading", -- The heading text
["Level"] = 2 -- Heading level, 1 - 3
}
},
{
["Type"] = "TEXT", -- descriptive component for normal text
["Props"] = {
["Content"] = "This is a paragraph of descriptive text that explains something about the assistant or provides additional information."
}
},
}
},
}

View File

@ -25,6 +25,10 @@ public class AssistantComponentFactory
return new AssistantProviderSelection { Props = props, Children = children };
case AssistantUiCompontentType.SWITCH:
return new AssistantSwitch { Props = props, Children = children };
case AssistantUiCompontentType.HEADING:
return new AssistantHeading { Props = props, Children = children };
case AssistantUiCompontentType.TEXT:
return new AssistantText { Props = props, Children = children };
default:
LOGGER.LogError($"Unknown assistant component type!\n{type} is not a supported assistant component type");
throw new Exception($"Unknown assistant component type: {type}");

View File

@ -0,0 +1,27 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantHeading : AssistantComponentBase
{
public override AssistantUiCompontentType Type => AssistantUiCompontentType.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;
}
public int Level
{
get => this.Props.TryGetValue(nameof(this.Level), out var v)
&& int.TryParse(v.ToString(), out var i)
? i
: 2;
set => this.Props[nameof(this.Level)] = value;
}
}

View File

@ -0,0 +1,18 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantText : AssistantComponentBase
{
public override AssistantUiCompontentType Type => AssistantUiCompontentType.TEXT;
public Dictionary<string, object> Props { get; set; } = new();
public List<IAssistantComponent> Children { get; set; } = new();
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;
}
}

View File

@ -8,4 +8,6 @@ public enum AssistantUiCompontentType
DROPDOWN,
PROVIDER_SELECTION,
SWITCH,
HEADING,
TEXT,
}

View File

@ -29,5 +29,13 @@ public static class ComponentPropSpecs
required: ["Name", "Label", "LabelOn", "LabelOff", "Value"],
optional: ["UserPrompt"]
),
[AssistantUiCompontentType.HEADING] = new(
required: ["Text", "Level"],
optional: []
),
[AssistantUiCompontentType.TEXT] = new(
required: ["Content"],
optional: []
),
};
}