Add SessionEndpoint, update ChatEndpoint, update deploy script and project file, remove DEVY.md
This commit is contained in:
1 parent
a927d6da33
commit
882d4ec21d
5 files changed
+56
-26
No files matched your search
@@ -83,6 +83,8 @@ public static class ChatEndpoint
|
||||
if (!string.IsNullOrWhiteSpace(agent.Instructions))
|
||||
promptParts.Add($"## Instructions\n{agent.Instructions}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(session.Workspace))
|
||||
promptParts.Add($"## Workspace\n{session.Workspace}");
|
||||
if (!string.IsNullOrWhiteSpace(session.Context))
|
||||
promptParts.Add($"## Kontext\n{session.Context}");
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
@@ -17,6 +18,7 @@ public static class SessionEndpoint
|
||||
app.MapPost("/api/sessions", HandleCreate);
|
||||
app.MapPut("/api/sessions/{sessionId}", HandleUpdate);
|
||||
app.MapDelete("/api/sessions/{sessionId}", HandleDelete);
|
||||
app.MapGet("/api/sessions/{sessionId}/system-prompt", HandleSystemPrompt);
|
||||
}
|
||||
|
||||
private static async Task HandleList(HttpContext ctx, DatabaseService db)
|
||||
@@ -81,4 +83,52 @@ public static class SessionEndpoint
|
||||
await db.DeleteSession(sessionId);
|
||||
ctx.Response.StatusCode = 204;
|
||||
}
|
||||
|
||||
private static async Task HandleSystemPrompt(HttpContext ctx, DatabaseService db)
|
||||
{
|
||||
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 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}");
|
||||
if (!string.IsNullOrWhiteSpace(session.Workspace))
|
||||
promptParts.Add($"## Workspace\n{session.Workspace}");
|
||||
if (!string.IsNullOrWhiteSpace(session.Context))
|
||||
promptParts.Add($"## Kontext\n{session.Context}");
|
||||
|
||||
var systemPrompt = string.Join("\n\n", promptParts);
|
||||
|
||||
ctx.Response.ContentType = "text/plain; charset=utf-8";
|
||||
await ctx.Response.WriteAsync(systemPrompt);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user