System prompt: build from agent persona/instructions, store in chain, remove UI textarea

This commit is contained in:
Meleki committed 2026-02-26 21:42:32 +01:00
1 parent a90b9427a5
commit 002ef293f0
6 files changed
+17 -39

No files matched your search

+14 -18
View File
@@ -75,6 +75,15 @@ public static class ChatEndpoint
res.Headers["Cache-Control"] = "no-cache";
res.Headers["Connection"] = "keep-alive";
var promptParts = new List<string>();
promptParts.Add($"Du bist {agent.Name}.");
if (!string.IsNullOrWhiteSpace(agent.Persona))
promptParts.Add($"## Persona\n{agent.Persona}");
if (!string.IsNullOrWhiteSpace(agent.Instructions))
promptParts.Add($"## Instructions\n{agent.Instructions}");
var systemPromptText = string.Join("\n\n", promptParts);
var chainId = Guid.NewGuid().ToString("N");
await db.CreateChain(new ChainRecord
@@ -83,7 +92,7 @@ public static class ChatEndpoint
SessionId = sessionId,
AgentId = agent.AgentId,
Model = modelId,
SystemPrompt = body.SystemPrompt
SystemPrompt = systemPromptText
});
// Session-Timestamp aktualisieren
@@ -107,23 +116,10 @@ public static class ChatEndpoint
});
}
var systemPrompt = new List<object>();
// Agent Persona
if (!string.IsNullOrWhiteSpace(agent.Persona))
systemPrompt.Add(new { type = "text", text = agent.Persona });
// Agent Instructions
if (!string.IsNullOrWhiteSpace(agent.Instructions))
systemPrompt.Add(new { type = "text", text = agent.Instructions });
// Zusätzlicher System Prompt aus dem UI
if (!string.IsNullOrWhiteSpace(body.SystemPrompt))
systemPrompt.Add(new { type = "text", text = body.SystemPrompt });
// Fallback wenn gar nix gesetzt
if (systemPrompt.Count == 0)
systemPrompt.Add(new { type = "text", text = "Du bist ein hilfreicher Assistent." });
var systemPrompt = new List<object>
{
new { type = "text", text = systemPromptText }
};
var anthropic = new AnthropicService(httpFactory, token, toolService, db);
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId);