mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-04-09 19:41:37 +00:00
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
|
|
using System.Text;
|
||
|
|
|
||
|
|
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
||
|
|
|
||
|
|
public abstract class StatefulAssistantComponentBase : NamedAssistantComponentBase, IStatefulAssistantComponent
|
||
|
|
{
|
||
|
|
public abstract void InitializeState(AssistantState state);
|
||
|
|
public abstract string UserPromptFallback(AssistantState state);
|
||
|
|
|
||
|
|
public string UserPrompt
|
||
|
|
{
|
||
|
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
|
||
|
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected string BuildAuditPromptBlock(string? value)
|
||
|
|
{
|
||
|
|
var builder = new StringBuilder();
|
||
|
|
var fieldName = this.Type.ToString().ToLowerInvariant();
|
||
|
|
|
||
|
|
builder.AppendLine($"[{fieldName}]");
|
||
|
|
builder.Append("name: ").AppendLine(this.Name);
|
||
|
|
builder.AppendLine("context:");
|
||
|
|
builder.AppendLine(!string.IsNullOrEmpty(this.UserPrompt) ? this.UserPrompt : "<not provided>");
|
||
|
|
builder.AppendLine("value:");
|
||
|
|
builder.AppendLine(!string.IsNullOrEmpty(value) ? value : "<empty>");
|
||
|
|
builder.Append($"[/{fieldName}]").AppendLine().AppendLine();
|
||
|
|
return builder.ToString();
|
||
|
|
}
|
||
|
|
}
|