feat: API Key pro Agent statt pro User
- Neue Tabelle agent_api_keys (user_id, agent_id, key_id) - Migration: bestehende selected_api_key_id auf alle Agents verteilt - Backend: GetAgentApiKeyRecord(userId, agentId) in Chat, Telegram, Cronjobs - Endpoints: select/selected mit ?agentId Query-Parameter - Frontend: currentAgentId aus Session, alle Key-Calls agent-aware - DeleteApiKey bereinigt agent_api_keys statt users.selected_api_key_id
This commit is contained in:
1 parent
b04b1a2cf9
commit
1effc6d00f
10 files changed
+128
-43
No files matched your search
@@ -51,15 +51,6 @@ public static class ChatEndpoint
|
||||
|
||||
var userId = req.HttpContext.GetUserId();
|
||||
|
||||
// API-Key des Users auflösen
|
||||
var userApiKey = await db.GetUserSelectedApiKey(userId);
|
||||
if (userApiKey == null)
|
||||
{
|
||||
res.StatusCode = 400;
|
||||
await res.WriteAsJsonAsync(new { error = "Kein API-Key ausgewählt. Bitte wähle einen Key aus." });
|
||||
return;
|
||||
}
|
||||
|
||||
var maxIterations = settings.GetInt("MaxIterations", 100);
|
||||
|
||||
var hasRemote = remoteMgr.GetBySessionId(sessionId) != null;
|
||||
@@ -71,6 +62,15 @@ public static class ChatEndpoint
|
||||
return;
|
||||
}
|
||||
|
||||
// API-Key des Users für diesen Agent auflösen
|
||||
var userApiKey = await db.GetAgentApiKeyRecord(userId, ctx.AgentId);
|
||||
if (userApiKey == null)
|
||||
{
|
||||
res.StatusCode = 400;
|
||||
await res.WriteAsJsonAsync(new { error = "Kein API-Key für diesen Agent zugewiesen. Bitte weise einen Key zu." });
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChoiceResponse)
|
||||
{
|
||||
// Choice-Antwort: tool_result in die VORHERIGE Chain speichern (wo der tool_use liegt)
|
||||
|
||||
Reference in new issue
Block a user