mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 11:41:38 +00:00
increased functionality for text area by adding optional properties
This commit is contained in:
parent
2afc8c6391
commit
5a3e49d839
@ -9,7 +9,8 @@
|
|||||||
case AssistantUiCompontentType.TEXT_AREA:
|
case AssistantUiCompontentType.TEXT_AREA:
|
||||||
if (component is AssistantTextArea textArea)
|
if (component is AssistantTextArea textArea)
|
||||||
{
|
{
|
||||||
<MudTextField T="string" @bind-Text="@this.inputFields[textArea.Name]" Label="@textArea.Label" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3"/>
|
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"/>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public partial class AssistantDynamic : AssistantBaseCore<SettingsDialogDynamic>
|
|||||||
case AssistantUiCompontentType.TEXT_AREA:
|
case AssistantUiCompontentType.TEXT_AREA:
|
||||||
if (component is AssistantTextArea textArea)
|
if (component is AssistantTextArea textArea)
|
||||||
{
|
{
|
||||||
this.inputFields.Add(textArea.Name, string.Empty);
|
this.inputFields.Add(textArea.Name, textArea.PrefillText);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -78,10 +78,28 @@ public partial class AssistantDynamic : AssistantBaseCore<SettingsDialogDynamic>
|
|||||||
private string CollectUserPrompt()
|
private string CollectUserPrompt()
|
||||||
{
|
{
|
||||||
var prompt = string.Empty;
|
var prompt = string.Empty;
|
||||||
foreach (var entry in this.inputFields)
|
|
||||||
|
foreach (var component in this.RootComponent!.Children)
|
||||||
{
|
{
|
||||||
prompt += $"{entry.Value}{Environment.NewLine}";
|
var userInput = string.Empty;
|
||||||
|
switch (component.Type)
|
||||||
|
{
|
||||||
|
case AssistantUiCompontentType.TEXT_AREA:
|
||||||
|
if (component is AssistantTextArea textArea)
|
||||||
|
{
|
||||||
|
prompt += $"context:{Environment.NewLine}{textArea.UserPrompt}{Environment.NewLine}{Environment.NewLine}---{Environment.NewLine}";
|
||||||
|
if (this.inputFields.TryGetValue(textArea.Name, out userInput))
|
||||||
|
{
|
||||||
|
prompt += $"user prompt:{Environment.NewLine}{userInput}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prompt += $"{userInput}{Environment.NewLine}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,28 @@ public class AssistantTextArea : AssistantComponentBase
|
|||||||
set => this.Props[nameof(this.Label)] = value;
|
set => 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSingleLine
|
||||||
|
{
|
||||||
|
get => this.Props.TryGetValue(nameof(this.IsSingleLine), out var val) && val is true;
|
||||||
|
set => this.Props[nameof(this.IsSingleLine)] = value;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ReadOnly
|
public bool ReadOnly
|
||||||
{
|
{
|
||||||
get => this.Props.TryGetValue(nameof(this.ReadOnly), out var val) && val is true;
|
get => this.Props.TryGetValue(nameof(this.ReadOnly), out var val) && val is true;
|
||||||
|
|||||||
@ -11,7 +11,7 @@ public static class ComponentPropSpecs
|
|||||||
),
|
),
|
||||||
[AssistantUiCompontentType.TEXT_AREA] = new(
|
[AssistantUiCompontentType.TEXT_AREA] = new(
|
||||||
required: ["Name", "Label"],
|
required: ["Name", "Label"],
|
||||||
optional: []
|
optional: ["UserPrompt", "PrefillText", "ReadOnly", "IsSingleLine"]
|
||||||
),
|
),
|
||||||
[AssistantUiCompontentType.BUTTON] = new(
|
[AssistantUiCompontentType.BUTTON] = new(
|
||||||
required: ["Name", "Text", "Action"],
|
required: ["Name", "Text", "Action"],
|
||||||
|
|||||||
@ -262,14 +262,12 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssistantDropdownItem
|
|
||||||
if (val.TryRead<LuaTable>(out var table) && this.TryParseDropdownItem(table, out var item))
|
if (val.TryRead<LuaTable>(out var table) && this.TryParseDropdownItem(table, out var item))
|
||||||
{
|
{
|
||||||
result = item;
|
result = item;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// List<AssistantDropdownItem>
|
|
||||||
if (val.TryRead<LuaTable>(out var listTable) && this.TryParseDropdownItemList(listTable, out var itemList))
|
if (val.TryRead<LuaTable>(out var listTable) && this.TryParseDropdownItemList(listTable, out var itemList))
|
||||||
{
|
{
|
||||||
result = itemList;
|
result = itemList;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user