System-Prompt-Modal: strukturierte Blöcke via API statt Frontend-Parsing
- SystemPromptBuilder.BuildBlocks() liefert List<PromptBlock> mit Icon/Label/Content
- Neuer Endpoint GET /api/sessions/{id}/system-prompt-blocks (JSON-Array)
- Labels beschreiben präzise die Herkunft jedes Blocks (Agent, Session, System, Skills)
- Verhalten + Erinnerung nur noch mit Workspace + ToolChoice:any (Bugfix)
- Frontend: simples Block-Rendering statt komplexer Heuristik-Logik
- SP-Block Styling mit Label-Header und Content-Box
This commit is contained in:
1 parent
40e56acc30
commit
d42e5077c4
5 files changed
+148
-25
No files matched your search
@@ -21,6 +21,7 @@ public static class SessionEndpoint
|
||||
app.MapPut("/api/sessions/{sessionId}", HandleUpdate);
|
||||
app.MapDelete("/api/sessions/{sessionId}", HandleDelete);
|
||||
app.MapGet("/api/sessions/{sessionId}/system-prompt", HandleSystemPrompt);
|
||||
app.MapGet("/api/sessions/{sessionId}/system-prompt-blocks", HandleSystemPromptBlocks);
|
||||
app.MapGet("/api/sessions/{sessionId}/streaming", HandleStreaming);
|
||||
app.MapPost("/api/sessions/{sessionId}/exec", HandleExec);
|
||||
app.MapGet("/api/sessions/{sessionId}/git-status", HandleGitStatus);
|
||||
@@ -132,6 +133,38 @@ public static class SessionEndpoint
|
||||
await ctx.Response.WriteAsync(systemPrompt);
|
||||
}
|
||||
|
||||
private static async Task HandleSystemPromptBlocks(HttpContext ctx, DatabaseService db, MemoryService memoryService, SkillService skillService)
|
||||
{
|
||||
var sessionId = ctx.Request.RouteValues["sessionId"]?.ToString();
|
||||
if (string.IsNullOrEmpty(sessionId)) { ctx.Response.StatusCode = 400; return; }
|
||||
|
||||
var session = await db.GetSession(sessionId);
|
||||
if (session == null) { ctx.Response.StatusCode = 404; return; }
|
||||
|
||||
if (string.IsNullOrEmpty(session.AgentId))
|
||||
{
|
||||
ctx.Response.StatusCode = 400;
|
||||
await ctx.Response.WriteAsJsonAsync(new { error = "Kein Agent ausgewählt" });
|
||||
return;
|
||||
}
|
||||
|
||||
var agent = await db.GetAgent(session.AgentId);
|
||||
if (agent == null)
|
||||
{
|
||||
ctx.Response.StatusCode = 400;
|
||||
await ctx.Response.WriteAsJsonAsync(new { error = "Agent nicht gefunden" });
|
||||
return;
|
||||
}
|
||||
|
||||
var markedMessages = await db.GetMarkedMessages(sessionId);
|
||||
var agentMemoryDir = memoryService.GetAgentMemoryDir(agent.AgentId);
|
||||
var dataDir = memoryService.DataDir;
|
||||
var agentSkills = await db.GetAgentSkills(agent.AgentId);
|
||||
var blocks = SystemPromptBuilder.BuildBlocks(agent, session, markedMessages, memoryService, agentMemoryDir, dataDir, agentSkills, skillService);
|
||||
|
||||
await ctx.Response.WriteAsJsonAsync(blocks.Select(b => new { b.Icon, b.Label, b.Content }));
|
||||
}
|
||||
|
||||
private static async Task HandleStreaming(HttpContext ctx, StreamingTracker streamingTracker)
|
||||
{
|
||||
var sessionId = ctx.Request.RouteValues["sessionId"]?.ToString();
|
||||
|
||||
Reference in new issue
Block a user