feat: GitHub Code Search als Agent-Tool + Dashboard-Badges
- UseGitHubSearch Property im AgentRecord (Default: false) - DB-Migration: use_github_search Spalte in agents - Checkbox im Agent-Formular (Standard: unchecked) - Tool nur aktiv wenn Agent-Checkbox UND GitHubToken konfiguriert - includeGitHubSearch Parameter durch StreamChat/AddToolsToPayload - Dashboard-Badges: 🔮 Auto-Kontext + 🐙 GitHub Search
This commit is contained in:
1 parent
bca5e5145a
commit
89122e2170
10 files changed
+22
-8
No files matched your search
@@ -65,6 +65,7 @@ public static class AgentEndpoint
|
||||
a.UseUserInfo,
|
||||
a.UseMemory,
|
||||
a.UseAutoContext,
|
||||
a.UseGitHubSearch,
|
||||
a.UseWebSearch,
|
||||
a.WebSearchVersion,
|
||||
a.AllowUserChoice,
|
||||
@@ -121,6 +122,7 @@ public static class AgentEndpoint
|
||||
UseUserInfo = !body.TryGetProperty("useUserInfo", out var uu) || uu.GetBoolean(),
|
||||
UseMemory = !body.TryGetProperty("useMemory", out var um) || um.GetBoolean(),
|
||||
UseAutoContext = !body.TryGetProperty("useAutoContext", out var uac) || uac.GetBoolean(),
|
||||
UseGitHubSearch = body.TryGetProperty("useGitHubSearch", out var ughs) && ughs.GetBoolean(),
|
||||
UseWebSearch = body.TryGetProperty("webSearchVersion", out var wsv) && !string.IsNullOrEmpty(wsv.GetString()),
|
||||
WebSearchVersion = body.TryGetProperty("webSearchVersion", out var wsv2) ? wsv2.GetString() ?? "" : "",
|
||||
AllowUserChoice = !body.TryGetProperty("allowUserChoice", out var auc) || auc.GetBoolean(),
|
||||
@@ -163,6 +165,7 @@ public static class AgentEndpoint
|
||||
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("useAutoContext", out var uac)) agent.UseAutoContext = uac.GetBoolean();
|
||||
if (body.TryGetProperty("useGitHubSearch", out var ughs)) agent.UseGitHubSearch = ughs.GetBoolean();
|
||||
if (body.TryGetProperty("webSearchVersion", out var wsv))
|
||||
{
|
||||
agent.WebSearchVersion = wsv.GetString() ?? "";
|
||||
|
||||
@@ -216,7 +216,7 @@ public static class ChatEndpoint
|
||||
else
|
||||
{
|
||||
// Standard: Anthropic
|
||||
await anthropic.StreamChat(res, ctx.ModelId, ctx.SystemPrompt, messages, ctx.ChainId, ctx.Workspace, sessionId, agentId: ctx.AgentId, userId: userId, useMemory: ctx.UseMemory, webSearchVersion: ctx.WebSearchVersion, maxIterations: ctx.MaxIterations, toolChoice: effectiveToolChoice, review: ctx.Review, finalizer: ctx.Finalizer, allowUserChoice: ctx.Agent?.AllowUserChoice ?? true, planMode: ctx.PlanMode, useAutoContext: ctx.Agent?.UseAutoContext ?? true, workCt: workCt, hardCt: hardCt, sseCt: sseCt, remoteMgr: remoteMgr);
|
||||
await anthropic.StreamChat(res, ctx.ModelId, ctx.SystemPrompt, messages, ctx.ChainId, ctx.Workspace, sessionId, agentId: ctx.AgentId, userId: userId, useMemory: ctx.UseMemory, webSearchVersion: ctx.WebSearchVersion, maxIterations: ctx.MaxIterations, toolChoice: effectiveToolChoice, review: ctx.Review, finalizer: ctx.Finalizer, allowUserChoice: ctx.Agent?.AllowUserChoice ?? true, planMode: ctx.PlanMode, useAutoContext: ctx.Agent?.UseAutoContext ?? true, useGitHubSearch: ctx.Agent?.UseGitHubSearch ?? false, workCt: workCt, hardCt: hardCt, sseCt: sseCt, remoteMgr: remoteMgr);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -17,6 +17,7 @@ public class AgentRecord
|
||||
public bool UseUserInfo { get; set; } = true;
|
||||
public bool UseMemory { get; set; } = true;
|
||||
public bool UseAutoContext { get; set; } = true;
|
||||
public bool UseGitHubSearch { get; set; }
|
||||
public bool UseWebSearch { get; set; }
|
||||
public string WebSearchVersion { get; set; } = "";
|
||||
public bool AllowUserChoice { get; set; } = true;
|
||||
|
||||
@@ -96,6 +96,7 @@ public class AnthropicService
|
||||
bool allowUserChoice = true,
|
||||
bool planMode = false,
|
||||
bool useAutoContext = true,
|
||||
bool useGitHubSearch = false,
|
||||
CancellationToken workCt = default,
|
||||
CancellationToken hardCt = default,
|
||||
CancellationToken sseCt = default,
|
||||
@@ -177,7 +178,7 @@ public class AnthropicService
|
||||
payload["system"] = systemPrompt;
|
||||
|
||||
var hasRemote = remoteMgr?.GetBySessionId(sessionId) != null;
|
||||
AddToolsToPayload(payload, workspace, agentId, useMemory, webSearchVersion, toolChoice, iterations, allowUserChoice, planMode, includeRemote: hasRemote);
|
||||
AddToolsToPayload(payload, workspace, agentId, useMemory, webSearchVersion, toolChoice, iterations, allowUserChoice, planMode, includeRemote: hasRemote, includeGitHubSearch: useGitHubSearch && _toolService.HasGitHubToken);
|
||||
|
||||
var client = CreateClient();
|
||||
var json = JsonSerializer.Serialize(payload, new JsonSerializerOptions { WriteIndented = true });
|
||||
@@ -1619,13 +1620,12 @@ public class AnthropicService
|
||||
/// <summary>
|
||||
/// Fügt Tool-Definitionen und WebSearch zum Payload hinzu.
|
||||
/// </summary>
|
||||
private void AddToolsToPayload(Dictionary<string, object> payload, string workspace, string agentId, bool useMemory, string webSearchVersion, string toolChoice, int iteration, bool allowUserChoice = false, bool planMode = false, bool includeRemote = false)
|
||||
private void AddToolsToPayload(Dictionary<string, object> payload, string workspace, string agentId, bool useMemory, string webSearchVersion, string toolChoice, int iteration, bool allowUserChoice = false, bool planMode = false, bool includeRemote = false, bool includeGitHubSearch = false)
|
||||
{
|
||||
var hasWorkspace = !string.IsNullOrEmpty(workspace);
|
||||
var includeMemory = useMemory && _memoryService != null && !string.IsNullOrEmpty(agentId);
|
||||
var includeMemorySearch = _vectorSearch != null && _vectorSearch.GetEmbeddingCount() > 0;
|
||||
var includeSendToSession = _db != null && _chatService != null;
|
||||
var includeGitHubSearch = _toolService.HasGitHubToken;
|
||||
var hasTools = hasWorkspace || includeMemory || includeRemote || includeMemorySearch || includeSendToSession || includeGitHubSearch;
|
||||
var hasWebSearch = !string.IsNullOrEmpty(webSearchVersion);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ChatService
|
||||
|
||||
var hasWorkspace = !string.IsNullOrEmpty(workspace);
|
||||
var includeMemory = agent.UseMemory && !string.IsNullOrEmpty(agent.AgentId);
|
||||
var includeGitHubSearch = _toolService.HasGitHubToken;
|
||||
var includeGitHubSearch = agent.UseGitHubSearch && _toolService.HasGitHubToken;
|
||||
var hasTools = hasWorkspace || includeMemory || includeGitHubSearch;
|
||||
var toolChoice = hasTools ? "any" : null;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ public partial class DatabaseService
|
||||
agent.CreatedAt = now;
|
||||
agent.UpdatedAt = now;
|
||||
await conn.ExecuteAsync(@"
|
||||
INSERT INTO agents (agent_id, user_id, name, avatar, avatar_small, description, model, tool_choice, custom_commands, auto_commit, use_soul, use_identity, use_user_info, use_memory, use_auto_context, use_web_search, web_search_version, allow_user_choice, task_instruction, avatar_scale, avatar_offset_x, avatar_offset_y, is_deleted, created_at, updated_at)
|
||||
VALUES (@AgentId, @UserId, @Name, @Avatar, @AvatarSmall, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, @UseSoul, @UseIdentity, @UseUserInfo, @UseMemory, @UseAutoContext, @UseWebSearch, @WebSearchVersion, @AllowUserChoice, @TaskInstruction, @AvatarScale, @AvatarOffsetX, @AvatarOffsetY, 0, @CreatedAt, @UpdatedAt)
|
||||
INSERT INTO agents (agent_id, user_id, name, avatar, avatar_small, description, model, tool_choice, custom_commands, auto_commit, use_soul, use_identity, use_user_info, use_memory, use_auto_context, use_github_search, use_web_search, web_search_version, allow_user_choice, task_instruction, avatar_scale, avatar_offset_x, avatar_offset_y, is_deleted, created_at, updated_at)
|
||||
VALUES (@AgentId, @UserId, @Name, @Avatar, @AvatarSmall, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, @UseSoul, @UseIdentity, @UseUserInfo, @UseMemory, @UseAutoContext, @UseGitHubSearch, @UseWebSearch, @WebSearchVersion, @AllowUserChoice, @TaskInstruction, @AvatarScale, @AvatarOffsetX, @AvatarOffsetY, 0, @CreatedAt, @UpdatedAt)
|
||||
", agent);
|
||||
return agent;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public partial class DatabaseService
|
||||
UPDATE agents SET name = @Name, avatar = @Avatar, avatar_small = @AvatarSmall, description = @Description,
|
||||
model = @Model, tool_choice = @ToolChoice,
|
||||
custom_commands = @CustomCommands, auto_commit = @AutoCommit,
|
||||
use_soul = @UseSoul, use_identity = @UseIdentity, use_user_info = @UseUserInfo, use_memory = @UseMemory, use_auto_context = @UseAutoContext, use_web_search = @UseWebSearch, web_search_version = @WebSearchVersion,
|
||||
use_soul = @UseSoul, use_identity = @UseIdentity, use_user_info = @UseUserInfo, use_memory = @UseMemory, use_auto_context = @UseAutoContext, use_github_search = @UseGitHubSearch, use_web_search = @UseWebSearch, web_search_version = @WebSearchVersion,
|
||||
allow_user_choice = @AllowUserChoice, task_instruction = @TaskInstruction,
|
||||
avatar_scale = @AvatarScale, avatar_offset_x = @AvatarOffsetX, avatar_offset_y = @AvatarOffsetY,
|
||||
is_public = @IsPublic, updated_at = @UpdatedAt
|
||||
|
||||
@@ -151,6 +151,7 @@ public partial class DatabaseService
|
||||
TryAddColumn(conn, "agents", "use_user_info", "INTEGER NOT NULL DEFAULT 1");
|
||||
TryAddColumn(conn, "agents", "use_memory", "INTEGER NOT NULL DEFAULT 1");
|
||||
TryAddColumn(conn, "agents", "use_auto_context", "INTEGER NOT NULL DEFAULT 1");
|
||||
TryAddColumn(conn, "agents", "use_github_search", "INTEGER NOT NULL DEFAULT 0");
|
||||
|
||||
TryAddColumn(conn, "messages", "deleted_on", "TEXT");
|
||||
TryAddColumn(conn, "agents", "use_web_search", "INTEGER NOT NULL DEFAULT 0");
|
||||
|
||||
@@ -241,6 +241,10 @@
|
||||
<input type="checkbox" id="agentUseAutoContext" checked>
|
||||
Automatischer Kontext <span class="checkbox-hint">(Relevante Erinnerungen werden automatisch abgerufen)</span>
|
||||
</label>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="agentUseGitHubSearch">
|
||||
GitHub Code Search <span class="checkbox-hint">(Öffentlichen Code auf GitHub durchsuchen)</span>
|
||||
</label>
|
||||
<label>Web-Suche</label>
|
||||
<select id="agentWebSearchVersion">
|
||||
<option value="">Deaktiviert</option>
|
||||
|
||||
@@ -107,6 +107,8 @@ function buildAgentCard(agent, skills) {
|
||||
if (agent.useIdentity) badges.push('<span class="badge badge-feature" title="Hat eine Identität (IDENTITY.md)"><i class="fa fa-id-badge"></i> Ich</span>');
|
||||
if (agent.useUserInfo) badges.push('<span class="badge badge-feature" title="Kennt sein Gegenüber (Benutzer-Persona)"><i class="fa fa-user"></i> Du</span>');
|
||||
if (agent.useMemory) badges.push('<span class="badge badge-feature" title="Zugriff auf Erinnerungen (Memory-Tools)"><i class="fa fa-database"></i> Erinnerungen</span>');
|
||||
if (agent.useAutoContext) badges.push('<span class="badge badge-feature" title="Relevante Erinnerungen werden automatisch abgerufen"><i class="fa fa-magic"></i> Auto-Kontext</span>');
|
||||
if (agent.useGitHubSearch) badges.push('<span class="badge badge-feature" title="Öffentlichen Code auf GitHub durchsuchen"><i class="fa fa-github"></i> GitHub Search</span>');
|
||||
if (agent.webSearchVersion) {
|
||||
const wsYear = agent.webSearchVersion.includes('2025') ? 'Version 2025' : 'v2026';
|
||||
badges.push(`<span class="badge badge-feature" title="Web-Suche - ${wsYear}"><i class="fa fa-search"></i> Web-Suche</span>`);
|
||||
|
||||
@@ -53,6 +53,7 @@ registerPage('agent', {
|
||||
const useUserInfoEl = document.getElementById('agentUseUserInfo');
|
||||
const useMemoryEl = document.getElementById('agentUseMemory');
|
||||
const useAutoContextEl = document.getElementById('agentUseAutoContext');
|
||||
const useGitHubSearchEl = document.getElementById('agentUseGitHubSearch');
|
||||
const webSearchVersionEl = document.getElementById('agentWebSearchVersion');
|
||||
const avatarPreview = document.getElementById('avatarPreview');
|
||||
const saveBtn = document.getElementById('agentSaveBtn');
|
||||
@@ -94,6 +95,7 @@ registerPage('agent', {
|
||||
useUserInfoEl.checked = agent.useUserInfo !== false;
|
||||
useMemoryEl.checked = agent.useMemory !== false;
|
||||
useAutoContextEl.checked = agent.useAutoContext !== false;
|
||||
useGitHubSearchEl.checked = agent.useGitHubSearch || false;
|
||||
webSearchVersionEl.value = agent.webSearchVersion || '';
|
||||
isPublicEl.checked = agent.isPublic || false;
|
||||
deleteBtn.hidden = false;
|
||||
@@ -136,6 +138,7 @@ registerPage('agent', {
|
||||
useUserInfo: useUserInfoEl.checked,
|
||||
useMemory: useMemoryEl.checked,
|
||||
useAutoContext: useAutoContextEl.checked,
|
||||
useGitHubSearch: useGitHubSearchEl.checked,
|
||||
webSearchVersion: webSearchVersionEl.value,
|
||||
avatar: _agentAvatarEditor.getImage(),
|
||||
avatarScale: _agentAvatarEditor.getScale(),
|
||||
|
||||
Reference in new issue
Block a user