mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-12 05:07:21 +00:00
Fixed and improved the system prompt of chats started from assistants (#1172)
This commit is contained in:
1 parent
bbf4dc2231
commit
31862f5ecd
50 files changed
+1112
-107
No files matched your search
@@ -7,6 +7,47 @@ namespace AIStudio.Assistants.SWOTAnalysis;
|
||||
/// </summary>
|
||||
public partial class AssistantSWOTAnalysis
|
||||
{
|
||||
// The prompts of this assistant demand JSON, so the chat gets a prompt of its own, which keeps the method, the goal, and the language:
|
||||
protected override ChatSystemPromptChoice ChatSystemPrompt => ChatSystemPromptChoice.Custom(this.CreateChatSystemPrompt);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the system prompt of a chat which continues an analysis, for follow-up questions about it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It holds what the user set, never what a model wrote, for the same reason the chat leaves out the
|
||||
/// hidden request: a web address in the system prompt counts as given by the user, see
|
||||
/// ChatThread.RuntimeSystemPromptWebAddresses. The research therefore stays out of it as well.
|
||||
/// </remarks>
|
||||
private string CreateChatSystemPrompt() =>
|
||||
$"""
|
||||
You are an expert in strategic analysis and know the SWOT method well: strengths and weaknesses are internal,
|
||||
opportunities and threats are external; strengths and opportunities are positive, weaknesses and threats are
|
||||
negative. The user had a SWOT analysis created: the conversation so far holds its result, with the findings of
|
||||
the four categories, the overall assessment, and the prioritized actions. Now you answer the user's follow-up
|
||||
questions about the analysis, e.g., why a finding belongs to its category, how two findings relate, or what an
|
||||
action involves, and you work out further steps when the user asks for them.
|
||||
|
||||
The analysis rests on the content of the user and on research which this conversation does not hold. When an
|
||||
answer needs more than the result shows, say so, and mark what you add from general knowledge.
|
||||
|
||||
{ChatPromptSetting("The user stated this goal for the analysis:", this.analysisGoal)}
|
||||
{ChatPromptSetting("The user asked the analysis to consider these aspects:", this.importantAspects)}
|
||||
|
||||
When you write parts of the analysis anew, follow this rule for their language: {this.OutputLanguageInstruction}
|
||||
Otherwise, answer in the language the user writes in.
|
||||
""";
|
||||
|
||||
/// <summary>
|
||||
/// Puts a setting of the user into the system prompt of the chat, or nothing when the user left it empty.
|
||||
/// </summary>
|
||||
/// <param name="introduction">The sentence which introduces the setting.</param>
|
||||
/// <param name="setting">The setting as the user wrote it.</param>
|
||||
/// <returns>The introduction and the setting, or an empty string.</returns>
|
||||
private static string ChatPromptSetting(string introduction, string setting) => string.IsNullOrWhiteSpace(setting) ? string.Empty : $"""
|
||||
{introduction}
|
||||
{setting.Trim()}
|
||||
""";
|
||||
|
||||
/// <summary>
|
||||
/// The chat gets the visible request and the result only, not the hidden request behind it.
|
||||
/// </summary>
|
||||
@@ -36,7 +77,6 @@ public partial class AssistantSWOTAnalysis
|
||||
/// <returns>The thread of the chat, with the visible request and the visible result as its only blocks.</returns>
|
||||
internal static ChatThread CreateChatThreadForResult(ChatThread assistantThread, ContentBlock? visiblePrompt, ContentBlock? result) => assistantThread with
|
||||
{
|
||||
SystemPrompt = SystemPrompts.DEFAULT,
|
||||
Blocks = visiblePrompt is null || result is null
|
||||
? []
|
||||
|
||||
|
||||
Reference in new issue
Block a user