Settings: server-side LLM configurations + 30d spend roll-up

Replaces the localStorage-only LLM settings with a persisted catalogue
backed by /api/v1/admin/llm-configurations. The Settings → LLM screen
now has two cards:

- "Saved configurations" — full CRUD against the server. Each row shows
  provider/model/secret/published per-1M-token costs. Add wizard
  auto-fills costs from the curated catalog. One-click "Import local"
  button promotes any pre-existing localStorage settings into a server
  row, then clears the local store.
- "Active LLM (this session)" — the existing LLMProvidersSettingsCard,
  scoped down to "what does the Assistant use right now" (still
  localStorage; per-operator).

Spend (30d) tile in the configurations card header reads
/api/v1/ai/llm/usage/summary and surfaces total cost / requests /
tokens. First visible cost roll-up in the admin UI.

New module app/lib/arcadia/llm-configs.ts: typed CRUD client,
catalog lookup, computeCostCents helper (mirrors the server's
LlmConfiguration.compute_cost_cents/3), and getUsageSummary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
jules
2026-05-02 18:06:29 +10:00
parent 29030c9e72
commit baf42c4cec
3 changed files with 520 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ import {
import { useArcadiaClient } from "@crema/arcadia-client"
import { probeProxy, type LLMProxyProvider } from "~/lib/arcadia/llm-proxy"
import { LlmConfigurationsPanel } from "~/components/settings/llm-configurations-panel"
import { AppShell } from "~/components/layout/app-shell"
import { Button } from "~/components/ui/button"
import {
@@ -212,12 +213,15 @@ export default function SettingsRoute() {
<div className="min-w-0">
{section === "llm" && (
<div className="flex flex-col gap-4">
<LlmConfigurationsPanel />
<Card>
<CardHeader>
<CardTitle>LLM</CardTitle>
<CardTitle>Active LLM (this session)</CardTitle>
<CardDescription>
Pick a provider, model, and the arcadia-vault secret holding the API key. Settings
auto-save as you type. The Assistant picks them up on the next message.
The Assistant uses this provider/model on the next message. For
persistent setups shared across operators, use the Saved
configurations card above.
</CardDescription>
</CardHeader>
<CardContent>