Settings/LLM: unified panel with per-row active toggle, edit, spend
Reworks the LLM settings surface based on UX feedback. Drops the separate "Active LLM (this session)" card — its functionality is now inline on each saved config as a star toggle (writes the same localStorage key the Assistant reads via @crema/llm-providers-ui's saveSettings, so the existing assistant code picks the change up without any plumbing). Per-row controls now include: - Star: make this config active for the current browser - Switch: enable/disable server-side - Pencil: edit (modal, not inline-expand) - Trash: delete (with confirm) - Spend (30d): cost + request count, sourced from /api/v1/ai/llm/usage/by-model and matched on (provider, model) Other improvements: - Add wizard moved to a Dialog modal instead of pushing the list around. Same form handles edit. - Empty state: "Seed from catalog" button creates a curated starter set (GPT-4o mini/4o, Sonnet 4.6, Haiku 4.5, DeepSeek V4 Flash, LM Studio) so first-time operators don't face a blank panel. - Catalog dropdown picks now auto-fill input/output costs as you switch models, so the rates always reflect the chosen model unless manually overridden. - The lib's full settings card (system prompt, transport, context budget) is still reachable for advanced cases — collapsed into a <details> below the panel. Adds llm-configs.ts: getUsageByModel + findSpend helper for the per-row spend lookup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -153,3 +153,32 @@ export async function getUsageSummary(
|
||||
)
|
||||
return "data" in (res as object) ? (res as { data: LlmUsageSummary }).data : (res as LlmUsageSummary)
|
||||
}
|
||||
|
||||
export interface UsageByModelRow {
|
||||
provider: string
|
||||
model: string
|
||||
requests: number
|
||||
total_tokens: number
|
||||
cost_cents: number
|
||||
}
|
||||
|
||||
export async function getUsageByModel(
|
||||
arcadia: ArcadiaClient,
|
||||
opts: { days?: number } = {},
|
||||
): Promise<UsageByModelRow[]> {
|
||||
const params: Record<string, string | number | boolean | null | undefined> = {}
|
||||
if (opts.days != null) params.days = opts.days
|
||||
const res = await arcadia.GET<{ data: UsageByModelRow[] } | UsageByModelRow[]>(
|
||||
"/api/v1/ai/llm/usage/by-model",
|
||||
{ params },
|
||||
)
|
||||
return "data" in (res as object) ? (res as { data: UsageByModelRow[] }).data : (res as UsageByModelRow[])
|
||||
}
|
||||
|
||||
/** Find the spend row matching a given config's (provider, model). */
|
||||
export function findSpend(
|
||||
rows: UsageByModelRow[],
|
||||
config: Pick<LlmConfiguration, "provider" | "model">,
|
||||
): UsageByModelRow | undefined {
|
||||
return rows.find((r) => r.provider === config.provider && r.model === config.model)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user