Session-Kontext: Textarea für System-Prompt pro Session

This commit is contained in:
Meleki committed 2026-02-27 06:52:47 +01:00
1 parent b752c99a64
commit 48be82905e
7 files changed
+17 -18

No files matched your search

+3
View File
@@ -83,6 +83,9 @@ public static class ChatEndpoint
if (!string.IsNullOrWhiteSpace(agent.Instructions))
promptParts.Add($"## Instructions\n{agent.Instructions}");
if (!string.IsNullOrWhiteSpace(session.Context))
promptParts.Add($"## Kontext\n{session.Context}");
var systemPromptText = string.Join("\n\n", promptParts);
var chainId = Guid.NewGuid().ToString("N");
+2 -1
View File
@@ -51,8 +51,9 @@ public static class SessionEndpoint
var image = body.TryGetProperty("image", out var img) ? img.GetString() : null;
var agentId = body.TryGetProperty("agentId", out var a) ? a.GetString() : null;
var workspace = body.TryGetProperty("workspace", out var w) ? w.GetString() : null;
var context = body.TryGetProperty("context", out var ctxEl) ? ctxEl.GetString() : null;
var session = await db.CreateSession(name, description, image, agentId, workspace);
var session = await db.CreateSession(name, description, image, agentId, workspace, context);
await ctx.Response.WriteAsJsonAsync(session);
}
+1
View File
@@ -9,6 +9,7 @@ public class SessionRecord
public string Image { get; set; }
public string AgentId { get; set; }
public string Workspace { get; set; }
public string Context { get; set; }
public bool IsDeleted { get; set; }
public string CreatedAt { get; set; }
public string UpdatedAt { get; set; }
+6 -3
View File
@@ -102,6 +102,7 @@ public class DatabaseService
TryAddColumn(conn, "sessions", "description", "TEXT");
TryAddColumn(conn, "sessions", "image", "TEXT");
TryAddColumn(conn, "sessions", "workspace", "TEXT");
TryAddColumn(conn, "sessions", "context", "TEXT");
TryAddColumn(conn, "sessions", "is_deleted", "INTEGER NOT NULL DEFAULT 0");
TryAddColumn(conn, "chains", "agent_id", "TEXT");
}
@@ -163,7 +164,7 @@ public class DatabaseService
// ── Sessions ──
public async Task<SessionRecord> CreateSession(string name = null, string description = null, string image = null, string agentId = null, string workspace = null)
public async Task<SessionRecord> CreateSession(string name = null, string description = null, string image = null, string agentId = null, string workspace = null, string context = null)
{
using var conn = CreateConnection();
var now = DateTime.UtcNow.ToString("o");
@@ -175,12 +176,13 @@ public class DatabaseService
Image = image,
AgentId = agentId,
Workspace = workspace,
Context = context,
CreatedAt = now,
UpdatedAt = now
};
await conn.ExecuteAsync(@"
INSERT INTO sessions (session_id, name, description, image, agent_id, workspace, created_at, updated_at)
VALUES (@SessionId, @Name, @Description, @Image, @AgentId, @Workspace, @CreatedAt, @UpdatedAt)
INSERT INTO sessions (session_id, name, description, image, agent_id, workspace, context, created_at, updated_at)
VALUES (@SessionId, @Name, @Description, @Image, @AgentId, @Workspace, @Context, @CreatedAt, @UpdatedAt)
", session);
return session;
}
@@ -220,6 +222,7 @@ public class DatabaseService
if (body.TryGetProperty("image", out var img)) { sets.Add("image = @image"); p.Add("image", img.GetString()); }
if (body.TryGetProperty("agentId", out var a)) { sets.Add("agent_id = @agentId2"); p.Add("agentId2", a.GetString()); }
if (body.TryGetProperty("workspace", out var w)) { sets.Add("workspace = @workspace"); p.Add("workspace", w.GetString()); }
if (body.TryGetProperty("context", out var ctx)) { sets.Add("context = @context"); p.Add("context", ctx.GetString()); }
await conn.ExecuteAsync($"UPDATE sessions SET {string.Join(", ", sets)} WHERE session_id = @sessionId", p);
}
-14
View File
@@ -1,14 +0,0 @@
#!/bin/bash
hostname
echo ""
GIT="git -c safe.directory=*"
echo "Uncommited Files:"
$GIT status --porcelain
echo ""
echo -n "Outgoing Changes: "
$GIT rev-list --count origin/$($GIT rev-parse --abbrev-ref HEAD)..HEAD
echo ""
+2
View File
@@ -66,6 +66,8 @@
<textarea id="sessionDescription" rows="3" placeholder="Beschreibung (optional)"></textarea>
<label>Agent</label>
<select id="agentSelect"></select>
<label>Kontext</label>
<textarea id="sessionContext" rows="4" placeholder="Zusätzlicher Kontext für den System-Prompt (optional)"></textarea>
<label>Workspace</label>
<input type="text" id="sessionWorkspace" placeholder="Absoluter Pfad zum Arbeitsverzeichnis (optional)">
<div class="agent-form-actions">
+3
View File
@@ -16,6 +16,7 @@ registerPage('session', {
const titleEl = document.getElementById('sessionPageTitle');
const nameEl = document.getElementById('sessionName');
const descEl = document.getElementById('sessionDescription');
const contextEl = document.getElementById('sessionContext');
const workspaceEl = document.getElementById('sessionWorkspace');
const agentSelect = document.getElementById('agentSelect');
const imagePreview = document.getElementById('sessionImagePreview');
@@ -33,6 +34,7 @@ registerPage('session', {
titleEl.textContent = session.name || 'Unbenannt';
nameEl.value = session.name || '';
descEl.value = session.description || '';
contextEl.value = session.context || '';
workspaceEl.value = session.workspace || '';
_sessionImageData = session.image || null;
deleteBtn.hidden = false;
@@ -84,6 +86,7 @@ registerPage('session', {
description: descEl.value.trim(),
image: _sessionImageData,
agentId: agentSelect.value || null,
context: contextEl.value || null,
workspace: workspaceEl.value.trim() || null
};