diff --git a/config/litellm/config.yaml b/config/litellm/config.yaml index a262017..2cef0b9 100644 --- a/config/litellm/config.yaml +++ b/config/litellm/config.yaml @@ -20,6 +20,15 @@ model_list: model: "gemini/gemini-flash-latest" api_key: "os.environ/GEMINI_API_KEY" + - model_name: "resonering" + litellm_params: + model: "openrouter/anthropic/claude-sonnet-4" + api_key: "os.environ/OPENROUTER_API_KEY" + - model_name: "resonering" + litellm_params: + model: "openrouter/google/gemini-2.5-flash" + api_key: "os.environ/OPENROUTER_API_KEY" + router_settings: routing_strategy: "simple-shuffle" num_retries: 2 diff --git a/frontend/src/routes/chat/[id]/+page.svelte b/frontend/src/routes/chat/[id]/+page.svelte index b605db6..e4deb27 100644 --- a/frontend/src/routes/chat/[id]/+page.svelte +++ b/frontend/src/routes/chat/[id]/+page.svelte @@ -133,6 +133,13 @@ return sender?.title || sender?.nodeKind || 'Ukjent'; } + /** Check if message sender is an agent (bot) */ + function isAgentMessage(node: Node): boolean { + if (!node.createdBy) return false; + const sender = nodeStore.get(node.createdBy); + return sender?.nodeKind === 'agent'; + } + /** Check if this message is from the current user */ function isOwnMessage(node: Node): boolean { return !!nodeId && node.createdBy === nodeId; @@ -227,11 +234,12 @@ {#each messages as msg (msg.id)} {@const own = isOwnMessage(msg)} {@const audio = isAudioNode(msg)} + {@const bot = isAgentMessage(msg)}
- {senderName(msg)} +
+ {#if bot}🤖 {/if}{senderName(msg)}
{/if} {#if audio} diff --git a/maskinrommet/src/agent.rs b/maskinrommet/src/agent.rs new file mode 100644 index 0000000..4b9bdf8 --- /dev/null +++ b/maskinrommet/src/agent.rs @@ -0,0 +1,242 @@ +// Agent — Claude som chat-deltaker. +// +// Håndterer `agent_respond`-jobber fra jobbkøen. +// Kaller `claude -p` direkte som subprocess — maskinrommet kjører +// på hosten (ikke i Docker) og har tilgang til claude CLI. + +use sqlx::PgPool; +use uuid::Uuid; + +use crate::jobs::JobRow; +use crate::stdb::StdbClient; + +#[derive(Debug)] +struct AgentConfig { + max_context_messages: i64, + max_consecutive_agent_messages: i64, + rate_limit_per_hour: i64, +} + +#[derive(sqlx::FromRow, Debug)] +struct MessageRow { + #[allow(dead_code)] + id: Uuid, + content: Option