mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-27 02:33:38 +00:00
Added a dialog that shows the system prompt and its parts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
40ac215359
commit
ac81bf25e9
42
app/MindWork AI Studio/Dialogs/SystemPromptDialog.razor
Normal file
42
app/MindWork AI Studio/Dialogs/SystemPromptDialog.razor
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@inherits MSGComponentBase
|
||||||
|
|
||||||
|
<MudDialog>
|
||||||
|
<DialogContent>
|
||||||
|
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
||||||
|
@T("This is the complete system prompt the AI receives with your next message. AI Studio assembles it from the parts listed here.")
|
||||||
|
</MudJustifiedText>
|
||||||
|
|
||||||
|
@* In the order in which the parts appear in the prompt below: *@
|
||||||
|
<MudSimpleTable Dense="@true" Class="mb-6">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>@T("Date and time")</td>
|
||||||
|
<td>@this.DateTimeText</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@T("Chat template")</td>
|
||||||
|
<td>@this.ChatTemplateText</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@T("Data from your data sources")</td>
|
||||||
|
<td>@this.RetrievedDataText</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@T("Profile")</td>
|
||||||
|
<td>@this.ProfileText</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@T("Tool instructions")</td>
|
||||||
|
<td>@this.ToolNamesText</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</MudSimpleTable>
|
||||||
|
|
||||||
|
<TextInfoLines Label="@T("Complete system prompt")" MaxLines="20" Value="@this.SystemPrompt" ClipboardTooltipSubject="@T("the complete system prompt")"/>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<MudButton OnClick="@this.Close" Variant="Variant.Filled" Color="Color.Primary">
|
||||||
|
@T("Close")
|
||||||
|
</MudButton>
|
||||||
|
</DialogActions>
|
||||||
|
</MudDialog>
|
||||||
97
app/MindWork AI Studio/Dialogs/SystemPromptDialog.razor.cs
Normal file
97
app/MindWork AI Studio/Dialogs/SystemPromptDialog.razor.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
using AIStudio.Components;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace AIStudio.Dialogs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows the system prompt a chat sends, together with the parts it was assembled from.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Nobody types this prompt as it is sent. A chat template replaces the default, a profile, the
|
||||||
|
/// retrieved data of a data source, and the policy of the selected tools are added to it, and the
|
||||||
|
/// date goes in front. The list above the text names these parts, so a person does not have to
|
||||||
|
/// work out from the text alone where a paragraph came from.
|
||||||
|
/// </remarks>
|
||||||
|
public partial class SystemPromptDialog : MSGComponentBase
|
||||||
|
{
|
||||||
|
[CascadingParameter]
|
||||||
|
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The whole system prompt, as the provider receives it.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public string SystemPrompt { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the chat template whose prompt replaces the default, or empty when there is none.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public string ChatTemplateName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the profile which takes part, or empty when there is none.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public string ProfileName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the chat template forbids a profile, which explains why none takes part even though one may be selected.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public bool IsProfileForbiddenByChatTemplate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the prompt carries data retrieved from a data source.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public bool HasRetrievedData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The names of the tools whose usage policy is part of the prompt.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public IReadOnlyList<string> ToolNames { get; set; } = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the current date and time go in front of the prompt.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public bool IncludesDateTime { get; set; }
|
||||||
|
|
||||||
|
private string ChatTemplateText => string.IsNullOrWhiteSpace(this.ChatTemplateName)
|
||||||
|
? T("None")
|
||||||
|
: this.ChatTemplateName;
|
||||||
|
|
||||||
|
private string ProfileText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this.IsProfileForbiddenByChatTemplate)
|
||||||
|
return T("Switched off by the chat template");
|
||||||
|
|
||||||
|
return string.IsNullOrWhiteSpace(this.ProfileName)
|
||||||
|
? T("None")
|
||||||
|
: this.ProfileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Not promised to be refreshed with the next message: the data is replaced only when a new
|
||||||
|
// retrieval finds something. Until then, what was retrieved earlier travels along again.
|
||||||
|
//
|
||||||
|
private string RetrievedDataText => this.HasRetrievedData
|
||||||
|
? T("Included, retrieved for an earlier message")
|
||||||
|
: T("None");
|
||||||
|
|
||||||
|
private string ToolNamesText => this.ToolNames.Count == 0
|
||||||
|
? T("None")
|
||||||
|
: string.Join(", ", this.ToolNames);
|
||||||
|
|
||||||
|
private string DateTimeText => this.IncludesDateTime
|
||||||
|
? T("Included")
|
||||||
|
: T("Not included");
|
||||||
|
|
||||||
|
private void Close() => this.MudDialog.Close();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user