Web-Suche (Agent-Toggle mit Versionswahl), Admin-only Backup, Haiku 4.5
- Agent: Web-Suche als Dropdown (Deaktiviert / 2025 / 2026) statt bool - AnthropicService: web_search Tool dynamisch nach Version einfügen - Stream: server_tool_use + web_search_tool_result Events verarbeiten - Chat-Frontend: web_search_start/end Events mit Suchindikator - Dashboard: Badge zeigt Web-Suche mit Jahresversion - UserRecord: IsAdmin Feld, DB-Migration is_admin Spalte - AuthMiddleware: IsAdmin aus DB laden und in Context setzen - BackupEndpoint: Admin-Check (403 für Nicht-Admins) - AuthEndpoint: isAdmin in Login/Me Response - Frontend: Backup-Section nur für Admins sichtbar - Haiku 4.5 als Model-Option (Agent-Dropdown + ChatEndpoint) - TODO: Cronjobs, Haiku ergänzt
This commit is contained in:
1 parent
485f47b29a
commit
8039b47dec
19 files changed
+155
-20
No files matched your search
@@ -62,7 +62,9 @@ public static class AgentEndpoint
|
||||
UseSoul = !body.TryGetProperty("useSoul", out var us) || us.GetBoolean(),
|
||||
UseIdentity = !body.TryGetProperty("useIdentity", out var ui) || ui.GetBoolean(),
|
||||
UseUserInfo = !body.TryGetProperty("useUserInfo", out var uu) || uu.GetBoolean(),
|
||||
UseMemory = !body.TryGetProperty("useMemory", out var um) || um.GetBoolean()
|
||||
UseMemory = !body.TryGetProperty("useMemory", out var um) || um.GetBoolean(),
|
||||
UseWebSearch = body.TryGetProperty("webSearchVersion", out var wsv) && !string.IsNullOrEmpty(wsv.GetString()),
|
||||
WebSearchVersion = body.TryGetProperty("webSearchVersion", out var wsv2) ? wsv2.GetString() ?? "" : ""
|
||||
};
|
||||
|
||||
agent = await db.CreateAgent(agent);
|
||||
@@ -93,6 +95,11 @@ public static class AgentEndpoint
|
||||
if (body.TryGetProperty("useIdentity", out var ui)) agent.UseIdentity = ui.GetBoolean();
|
||||
if (body.TryGetProperty("useUserInfo", out var uu)) agent.UseUserInfo = uu.GetBoolean();
|
||||
if (body.TryGetProperty("useMemory", out var um)) agent.UseMemory = um.GetBoolean();
|
||||
if (body.TryGetProperty("webSearchVersion", out var wsv))
|
||||
{
|
||||
agent.WebSearchVersion = wsv.GetString() ?? "";
|
||||
agent.UseWebSearch = !string.IsNullOrEmpty(agent.WebSearchVersion);
|
||||
}
|
||||
|
||||
await db.UpdateAgent(agent);
|
||||
memoryService.InitializeAgentFiles(agentId, agent.Name);
|
||||
|
||||
@@ -50,7 +50,8 @@ public static class AuthEndpoint
|
||||
{
|
||||
userId = user.UserId,
|
||||
username = user.Username,
|
||||
displayName = user.DisplayName
|
||||
displayName = user.DisplayName,
|
||||
isAdmin = user.IsAdmin
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,7 +92,8 @@ public static class AuthEndpoint
|
||||
{
|
||||
userId = user.UserId,
|
||||
username = user.Username,
|
||||
displayName = user.DisplayName
|
||||
displayName = user.DisplayName,
|
||||
isAdmin = user.IsAdmin
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Gott.Extensions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
@@ -15,8 +16,10 @@ public static class BackupEndpoint
|
||||
app.MapPost("/api/backup", HandleBackup);
|
||||
}
|
||||
|
||||
private static async System.Threading.Tasks.Task<IResult> HandleBackup()
|
||||
private static async System.Threading.Tasks.Task<IResult> HandleBackup(HttpContext ctx)
|
||||
{
|
||||
if (!ctx.IsAdmin())
|
||||
return Results.Forbid();
|
||||
var dataDir = Path.Combine(AppContext.BaseDirectory, "data");
|
||||
|
||||
if (!Directory.Exists(dataDir))
|
||||
|
||||
@@ -72,6 +72,7 @@ public static class ChatEndpoint
|
||||
{
|
||||
"opus" => "claude-opus-4-6",
|
||||
"sonnet" => "claude-sonnet-4-6",
|
||||
"haiku" => "claude-haiku-4-5",
|
||||
_ => "claude-sonnet-4-6"
|
||||
};
|
||||
|
||||
@@ -185,7 +186,7 @@ public static class ChatEndpoint
|
||||
streamingTracker.Start(sessionId, chainId);
|
||||
try
|
||||
{
|
||||
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace, sessionId, agentId: agent.AgentId, useMemory: agent.UseMemory, maxIterations: maxIterations, toolChoice: toolChoice, cancellationToken: cancellationToken);
|
||||
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace, sessionId, agentId: agent.AgentId, useMemory: agent.UseMemory, webSearchVersion: agent.WebSearchVersion, maxIterations: maxIterations, toolChoice: toolChoice, cancellationToken: cancellationToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user