AI-admin: alias-rename, dollarkostnad, fikset kolonnebredder
- 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>
This commit is contained in:
parent
177e4b6b66
commit
21683bd660
3 changed files with 1512 additions and 1377 deletions
|
|
@ -7,12 +7,10 @@ export const PATCH: RequestHandler = async ({ params, request, locals }) => {
|
|||
if (!locals.workspace || !locals.user) error(401);
|
||||
|
||||
const body = await request.json();
|
||||
const updates: Record<string, unknown> = {};
|
||||
if ('description' in body) updates.description = body.description;
|
||||
if ('is_active' in body) updates.is_active = body.is_active;
|
||||
|
||||
const [row] = await sql`
|
||||
UPDATE ai_model_aliases SET
|
||||
alias = COALESCE(${body.alias ?? null}, alias),
|
||||
description = COALESCE(${body.description ?? null}, description),
|
||||
is_active = COALESCE(${body.is_active ?? null}, is_active),
|
||||
updated_at = now()
|
||||
|
|
|
|||
|
|
@ -30,13 +30,14 @@ export const load: PageServerLoad = async () => {
|
|||
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
|
||||
GROUP BY model_alias, model_actual
|
||||
ORDER BY total_tokens DESC
|
||||
`;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue