Zwei neue Agent-Einstellungen (Frontend, DB-Migration additiv): - MaxOutputTokens: hartes Ausgabelimit. CLI: CLAUDE_CODE_MAX_OUTPUT_TOKENS, API: max_tokens (statt hart 16384). 0 = aus. - DisableThinking: CLI: CLAUDE_CODE_DISABLE_THINKING=1 + MAX_THINKING_TOKENS=0; entfernt CLAUDE_CODE_EFFORT_LEVEL (Explizit-Aus schlaegt Effort). API-Pfad ohne Aequivalent (Hint im UI). Die einzigen zwei Parameter, die z.ai/GLM nachweislich honoriert (Sampling-Parameter wie temperature/top_p werden dort still verworfen). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
123 lines
5.5 KiB
C#
123 lines
5.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Dapper;
|
|
using Gott.Models;
|
|
|
|
namespace Gott.Services;
|
|
|
|
public partial class DatabaseService
|
|
{
|
|
// ── Agents ──
|
|
|
|
public async Task<AgentRecord> CreateAgent(AgentRecord agent)
|
|
{
|
|
using var conn = CreateConnection();
|
|
var now = DateTime.UtcNow.ToString("o");
|
|
agent.AgentId = Guid.NewGuid().ToString("N");
|
|
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_github_search, use_serper_search, use_web_search, web_search_version, allow_user_choice, task_instruction, effort, max_output_tokens, disable_thinking, avatar_scale, avatar_offset_x, avatar_offset_y, is_public, is_deleted, created_at, updated_at)
|
|
VALUES (@AgentId, @UserId, @Name, @Avatar, @AvatarSmall, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, @UseSoul, @UseIdentity, @UseUserInfo, @UseMemory, @UseAutoContext, @UseGitHubSearch, @UseSerperSearch, @UseWebSearch, @WebSearchVersion, @AllowUserChoice, @TaskInstruction, @Effort, @MaxOutputTokens, @DisableThinking, @AvatarScale, @AvatarOffsetX, @AvatarOffsetY, @IsPublic, 0, @CreatedAt, @UpdatedAt)
|
|
", agent);
|
|
return agent;
|
|
}
|
|
|
|
public async Task<IEnumerable<AgentRecord>> GetAgents(string userId)
|
|
{
|
|
using var conn = CreateConnection();
|
|
return await conn.QueryAsync<AgentRecord>(
|
|
"SELECT * FROM agents WHERE user_id = @userId AND is_deleted = 0 ORDER BY name", new { userId });
|
|
}
|
|
|
|
public async Task<IEnumerable<AgentRecord>> GetAvailableAgents(string userId)
|
|
{
|
|
using var conn = CreateConnection();
|
|
return await conn.QueryAsync<AgentRecord>(
|
|
"SELECT * FROM agents WHERE (user_id = @userId OR is_public = 1) AND is_deleted = 0 ORDER BY name", new { userId });
|
|
}
|
|
|
|
public async Task<AgentRecord> GetAgent(string agentId)
|
|
{
|
|
using var conn = CreateConnection();
|
|
return await conn.QuerySingleOrDefaultAsync<AgentRecord>(
|
|
"SELECT * FROM agents WHERE agent_id = @agentId AND is_deleted = 0", new { agentId });
|
|
}
|
|
|
|
public async Task UpdateAgent(AgentRecord agent)
|
|
{
|
|
using var conn = CreateConnection();
|
|
agent.UpdatedAt = DateTime.UtcNow.ToString("o");
|
|
await conn.ExecuteAsync(@"
|
|
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_github_search = @UseGitHubSearch, use_serper_search = @UseSerperSearch, use_web_search = @UseWebSearch, web_search_version = @WebSearchVersion,
|
|
allow_user_choice = @AllowUserChoice, task_instruction = @TaskInstruction, effort = @Effort,
|
|
max_output_tokens = @MaxOutputTokens, disable_thinking = @DisableThinking,
|
|
avatar_scale = @AvatarScale, avatar_offset_x = @AvatarOffsetX, avatar_offset_y = @AvatarOffsetY,
|
|
is_public = @IsPublic, updated_at = @UpdatedAt
|
|
WHERE agent_id = @AgentId AND user_id = @UserId
|
|
", agent);
|
|
}
|
|
|
|
public async Task DeleteAgent(string agentId, string userId)
|
|
{
|
|
using var conn = CreateConnection();
|
|
await conn.ExecuteAsync(
|
|
"UPDATE agents SET is_deleted = 1, updated_at = @now WHERE agent_id = @agentId AND user_id = @userId",
|
|
new { agentId, userId, now = DateTime.UtcNow.ToString("o") });
|
|
}
|
|
|
|
|
|
// ── Agent Skills ──
|
|
|
|
public async Task<IEnumerable<string>> GetAgentSkills(string agentId)
|
|
{
|
|
using var conn = CreateConnection();
|
|
return await conn.QueryAsync<string>(
|
|
"SELECT skill_slug FROM agent_skills WHERE agent_id = @agentId ORDER BY skill_slug",
|
|
new { agentId });
|
|
}
|
|
|
|
public async Task SetAgentSkills(string agentId, IEnumerable<string> skillSlugs)
|
|
{
|
|
using var conn = CreateConnection();
|
|
using var tx = conn.BeginTransaction();
|
|
|
|
await conn.ExecuteAsync("DELETE FROM agent_skills WHERE agent_id = @agentId", new { agentId }, tx);
|
|
|
|
var now = DateTime.UtcNow.ToString("o");
|
|
foreach (var slug in skillSlugs)
|
|
{
|
|
await conn.ExecuteAsync(@"
|
|
INSERT INTO agent_skills (agent_id, skill_slug, created_at)
|
|
VALUES (@agentId, @slug, @now)",
|
|
new { agentId, slug, now }, tx);
|
|
}
|
|
|
|
tx.Commit();
|
|
}
|
|
|
|
public async Task AddAgentSkill(string agentId, string skillSlug)
|
|
{
|
|
using var conn = CreateConnection();
|
|
var now = DateTime.UtcNow.ToString("o");
|
|
await conn.ExecuteAsync(@"
|
|
INSERT OR IGNORE INTO agent_skills (agent_id, skill_slug, created_at)
|
|
VALUES (@agentId, @skillSlug, @now)",
|
|
new { agentId, skillSlug, now });
|
|
}
|
|
|
|
public async Task RemoveAgentSkill(string agentId, string skillSlug)
|
|
{
|
|
using var conn = CreateConnection();
|
|
await conn.ExecuteAsync(
|
|
"DELETE FROM agent_skills WHERE agent_id = @agentId AND skill_slug = @skillSlug",
|
|
new { agentId, skillSlug });
|
|
}
|
|
|
|
}
|