AI-admin: vis gjeldende modell per alias, migrer alt til OpenRouter
- Viser primærmodell (høyest prioritet, aktiv) under hvert alias-navn - Migrerer alle gemini/-providers til openrouter/google/-ekvivalenter - Endrer standard API-nøkkel i ny-provider-skjema til OPENROUTER_API_KEY Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
35c76a7038
commit
f98675a72e
2 changed files with 34 additions and 2 deletions
18
migrations/0010_openrouter_only.sql
Normal file
18
migrations/0010_openrouter_only.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
-- 0010_openrouter_only.sql
|
||||||
|
-- Migrer alle direkte Gemini-kall til OpenRouter.
|
||||||
|
-- All trafikk skal gå via OpenRouter for enhetlig kostnadssporing og routing.
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- Oppdater gemini/ providers til openrouter/google/ ekvivalenter
|
||||||
|
UPDATE ai_model_providers
|
||||||
|
SET litellm_model = CASE
|
||||||
|
WHEN litellm_model = 'gemini/gemini-2.5-flash-lite' THEN 'openrouter/google/gemini-2.5-flash-lite-preview'
|
||||||
|
WHEN litellm_model = 'gemini/gemini-2.5-flash' THEN 'openrouter/google/gemini-2.5-flash-preview'
|
||||||
|
ELSE REPLACE(litellm_model, 'gemini/', 'openrouter/google/')
|
||||||
|
END,
|
||||||
|
api_key_env = 'OPENROUTER_API_KEY',
|
||||||
|
updated_at = now()
|
||||||
|
WHERE litellm_model LIKE 'gemini/%';
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
let newProvider = $state<{ alias_id: string; litellm_model: string; api_key_env: string }>({
|
let newProvider = $state<{ alias_id: string; litellm_model: string; api_key_env: string }>({
|
||||||
alias_id: '',
|
alias_id: '',
|
||||||
litellm_model: '',
|
litellm_model: '',
|
||||||
api_key_env: 'GEMINI_API_KEY'
|
api_key_env: 'OPENROUTER_API_KEY'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ny alias-form
|
// Ny alias-form
|
||||||
|
|
@ -416,7 +416,7 @@
|
||||||
if (!res.ok) throw new Error('Feil ved opprettelse');
|
if (!res.ok) throw new Error('Feil ved opprettelse');
|
||||||
const row = await res.json();
|
const row = await res.json();
|
||||||
providers = [...providers, row];
|
providers = [...providers, row];
|
||||||
newProvider = { alias_id: '', litellm_model: '', api_key_env: 'GEMINI_API_KEY' };
|
newProvider = { alias_id: '', litellm_model: '', api_key_env: 'OPENROUTER_API_KEY' };
|
||||||
} catch {
|
} catch {
|
||||||
errorMsg = 'Kunne ikke legge til provider';
|
errorMsg = 'Kunne ikke legge til provider';
|
||||||
}
|
}
|
||||||
|
|
@ -667,6 +667,7 @@
|
||||||
|
|
||||||
{#each sortedAliases as alias (alias.id)}
|
{#each sortedAliases as alias (alias.id)}
|
||||||
{@const ap = providersForAlias(alias.id)}
|
{@const ap = providersForAlias(alias.id)}
|
||||||
|
{@const primaryModel = ap.find(p => p.is_active)?.litellm_model}
|
||||||
{#if editingAlias === alias.id}
|
{#if editingAlias === alias.id}
|
||||||
<div class="table-row alias-edit-row">
|
<div class="table-row alias-edit-row">
|
||||||
<input type="text" class="alias-edit-input" bind:value={editAliasName} placeholder="Alias-navn" />
|
<input type="text" class="alias-edit-input" bind:value={editAliasName} placeholder="Alias-navn" />
|
||||||
|
|
@ -689,6 +690,9 @@
|
||||||
onclick={() => (expandedAlias = expandedAlias === alias.id ? null : alias.id)}
|
onclick={() => (expandedAlias = expandedAlias === alias.id ? null : alias.id)}
|
||||||
>
|
>
|
||||||
{alias.alias}
|
{alias.alias}
|
||||||
|
{#if primaryModel}
|
||||||
|
<span class="alias-model">{primaryModel.replace('openrouter/', '')}</span>
|
||||||
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
<span class="col-desc">{alias.description ?? '\u2014'}</span>
|
<span class="col-desc">{alias.description ?? '\u2014'}</span>
|
||||||
<span class="col-providers">{ap.length}</span>
|
<span class="col-providers">{ap.length}</span>
|
||||||
|
|
@ -1209,6 +1213,16 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alias-model {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.75em;
|
||||||
|
color: #8b92a5;
|
||||||
|
font-weight: normal;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.clickable {
|
.clickable {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue