- PATCH /aliases/:id støtter nå rename (alias-felt) - Alias-raden har «Rediger»-knapp → inline-redigering av navn + beskrivelse - Tokenforbruk viser model_actual og estimert dollarkostnad per rad - Dollarkostnad beregnes fra OpenRouter-katalogpriser (krever lastet katalog) - Tokenforbruk-tabellen bruker auto-kolonnebredde (fikser overflow) - «Kompl.» i stedet for «Completion» i header Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import type { PageServerLoad } from './$types';
|
|
import { sql } from '$lib/server/db';
|
|
|
|
export const load: PageServerLoad = async () => {
|
|
const aliases = await sql`
|
|
SELECT id, alias, description, is_active, created_at
|
|
FROM ai_model_aliases
|
|
ORDER BY alias
|
|
`;
|
|
|
|
const providers = await sql`
|
|
SELECT id, alias_id, priority, litellm_model, api_key_env, is_active
|
|
FROM ai_model_providers
|
|
ORDER BY alias_id, priority
|
|
`;
|
|
|
|
const routing = await sql`
|
|
SELECT r.job_type, r.alias_id, r.description, a.alias
|
|
FROM ai_job_routing r
|
|
JOIN ai_model_aliases a ON a.id = r.alias_id
|
|
ORDER BY r.job_type
|
|
`;
|
|
|
|
const prompts = await sql`
|
|
SELECT action, system_prompt, description, updated_at
|
|
FROM ai_prompts
|
|
ORDER BY action
|
|
`;
|
|
|
|
const usage = await sql`
|
|
SELECT
|
|
model_alias,
|
|
model_actual,
|
|
count(*)::int AS call_count,
|
|
sum(prompt_tokens)::int AS prompt_tokens,
|
|
sum(completion_tokens)::int AS completion_tokens,
|
|
sum(total_tokens)::int AS total_tokens
|
|
FROM ai_usage_log
|
|
WHERE created_at > now() - interval '30 days'
|
|
GROUP BY model_alias, model_actual
|
|
ORDER BY total_tokens DESC
|
|
`;
|
|
|
|
return { aliases, providers, routing, prompts, usage };
|
|
};
|