Session-Kontext: Textarea für System-Prompt pro Session
This commit is contained in:
1 parent
b752c99a64
commit
48be82905e
7 files changed
+17
-18
No files matched your search
@@ -83,6 +83,9 @@ public static class ChatEndpoint
|
|||||||
if (!string.IsNullOrWhiteSpace(agent.Instructions))
|
if (!string.IsNullOrWhiteSpace(agent.Instructions))
|
||||||
promptParts.Add($"## Instructions\n{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 systemPromptText = string.Join("\n\n", promptParts);
|
||||||
|
|
||||||
var chainId = Guid.NewGuid().ToString("N");
|
var chainId = Guid.NewGuid().ToString("N");
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ public static class SessionEndpoint
|
|||||||
var image = body.TryGetProperty("image", out var img) ? img.GetString() : null;
|
var image = body.TryGetProperty("image", out var img) ? img.GetString() : null;
|
||||||
var agentId = body.TryGetProperty("agentId", out var a) ? a.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 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);
|
await ctx.Response.WriteAsJsonAsync(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class SessionRecord
|
|||||||
public string Image { get; set; }
|
public string Image { get; set; }
|
||||||
public string AgentId { get; set; }
|
public string AgentId { get; set; }
|
||||||
public string Workspace { get; set; }
|
public string Workspace { get; set; }
|
||||||
|
public string Context { get; set; }
|
||||||
public bool IsDeleted { get; set; }
|
public bool IsDeleted { get; set; }
|
||||||
public string CreatedAt { get; set; }
|
public string CreatedAt { get; set; }
|
||||||
public string UpdatedAt { get; set; }
|
public string UpdatedAt { get; set; }
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class DatabaseService
|
|||||||
TryAddColumn(conn, "sessions", "description", "TEXT");
|
TryAddColumn(conn, "sessions", "description", "TEXT");
|
||||||
TryAddColumn(conn, "sessions", "image", "TEXT");
|
TryAddColumn(conn, "sessions", "image", "TEXT");
|
||||||
TryAddColumn(conn, "sessions", "workspace", "TEXT");
|
TryAddColumn(conn, "sessions", "workspace", "TEXT");
|
||||||
|
TryAddColumn(conn, "sessions", "context", "TEXT");
|
||||||
TryAddColumn(conn, "sessions", "is_deleted", "INTEGER NOT NULL DEFAULT 0");
|
TryAddColumn(conn, "sessions", "is_deleted", "INTEGER NOT NULL DEFAULT 0");
|
||||||
TryAddColumn(conn, "chains", "agent_id", "TEXT");
|
TryAddColumn(conn, "chains", "agent_id", "TEXT");
|
||||||
}
|
}
|
||||||
@@ -163,7 +164,7 @@ public class DatabaseService
|
|||||||
|
|
||||||
// ── Sessions ──
|
// ── 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();
|
using var conn = CreateConnection();
|
||||||
var now = DateTime.UtcNow.ToString("o");
|
var now = DateTime.UtcNow.ToString("o");
|
||||||
@@ -175,12 +176,13 @@ public class DatabaseService
|
|||||||
Image = image,
|
Image = image,
|
||||||
AgentId = agentId,
|
AgentId = agentId,
|
||||||
Workspace = workspace,
|
Workspace = workspace,
|
||||||
|
Context = context,
|
||||||
CreatedAt = now,
|
CreatedAt = now,
|
||||||
UpdatedAt = now
|
UpdatedAt = now
|
||||||
};
|
};
|
||||||
await conn.ExecuteAsync(@"
|
await conn.ExecuteAsync(@"
|
||||||
INSERT INTO sessions (session_id, name, description, image, agent_id, workspace, created_at, updated_at)
|
INSERT INTO sessions (session_id, name, description, image, agent_id, workspace, context, created_at, updated_at)
|
||||||
VALUES (@SessionId, @Name, @Description, @Image, @AgentId, @Workspace, @CreatedAt, @UpdatedAt)
|
VALUES (@SessionId, @Name, @Description, @Image, @AgentId, @Workspace, @Context, @CreatedAt, @UpdatedAt)
|
||||||
", session);
|
", session);
|
||||||
return 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("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("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("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);
|
await conn.ExecuteAsync($"UPDATE sessions SET {string.Join(", ", sets)} WHERE session_id = @sessionId", p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ""
|
|
||||||
@@ -66,6 +66,8 @@
|
|||||||
<textarea id="sessionDescription" rows="3" placeholder="Beschreibung (optional)"></textarea>
|
<textarea id="sessionDescription" rows="3" placeholder="Beschreibung (optional)"></textarea>
|
||||||
<label>Agent</label>
|
<label>Agent</label>
|
||||||
<select id="agentSelect"></select>
|
<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>
|
<label>Workspace</label>
|
||||||
<input type="text" id="sessionWorkspace" placeholder="Absoluter Pfad zum Arbeitsverzeichnis (optional)">
|
<input type="text" id="sessionWorkspace" placeholder="Absoluter Pfad zum Arbeitsverzeichnis (optional)">
|
||||||
<div class="agent-form-actions">
|
<div class="agent-form-actions">
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ registerPage('session', {
|
|||||||
const titleEl = document.getElementById('sessionPageTitle');
|
const titleEl = document.getElementById('sessionPageTitle');
|
||||||
const nameEl = document.getElementById('sessionName');
|
const nameEl = document.getElementById('sessionName');
|
||||||
const descEl = document.getElementById('sessionDescription');
|
const descEl = document.getElementById('sessionDescription');
|
||||||
|
const contextEl = document.getElementById('sessionContext');
|
||||||
const workspaceEl = document.getElementById('sessionWorkspace');
|
const workspaceEl = document.getElementById('sessionWorkspace');
|
||||||
const agentSelect = document.getElementById('agentSelect');
|
const agentSelect = document.getElementById('agentSelect');
|
||||||
const imagePreview = document.getElementById('sessionImagePreview');
|
const imagePreview = document.getElementById('sessionImagePreview');
|
||||||
@@ -33,6 +34,7 @@ registerPage('session', {
|
|||||||
titleEl.textContent = session.name || 'Unbenannt';
|
titleEl.textContent = session.name || 'Unbenannt';
|
||||||
nameEl.value = session.name || '';
|
nameEl.value = session.name || '';
|
||||||
descEl.value = session.description || '';
|
descEl.value = session.description || '';
|
||||||
|
contextEl.value = session.context || '';
|
||||||
workspaceEl.value = session.workspace || '';
|
workspaceEl.value = session.workspace || '';
|
||||||
_sessionImageData = session.image || null;
|
_sessionImageData = session.image || null;
|
||||||
deleteBtn.hidden = false;
|
deleteBtn.hidden = false;
|
||||||
@@ -84,6 +86,7 @@ registerPage('session', {
|
|||||||
description: descEl.value.trim(),
|
description: descEl.value.trim(),
|
||||||
image: _sessionImageData,
|
image: _sessionImageData,
|
||||||
agentId: agentSelect.value || null,
|
agentId: agentSelect.value || null,
|
||||||
|
context: contextEl.value || null,
|
||||||
workspace: workspaceEl.value.trim() || null
|
workspace: workspaceEl.value.trim() || null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user