tuxevil-rotator 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +8 -1
- package/package.json +1 -1
- package/src/audio-transcription.ts +44 -4
- package/src/compat.ts +196 -222
- package/src/config-defaults.ts +5 -0
- package/src/config-overrides.ts +16 -0
- package/src/dashboard-live.ts +10 -8
- package/src/dashboard-types.ts +94 -1
- package/src/dashboard.ts +194 -1
- package/src/effort-levels.ts +43 -0
- package/src/effort-routing.ts +304 -0
- package/src/index.ts +2 -5
- package/src/model-catalog-revision.ts +20 -0
- package/src/model-catalog.ts +304 -0
- package/src/providers/adapter.ts +18 -0
- package/src/providers/google-antigravity/catalog.ts +190 -1
- package/src/providers/google-antigravity/forward.ts +2 -0
- package/src/providers/google-antigravity/index.ts +11 -0
- package/src/providers/google-antigravity/translators.ts +67 -14
- package/src/providers/ollama/index.ts +11 -1
- package/src/providers/ollama/quota-poll-store.ts +22 -1
- package/src/providers/ollama/quota.ts +95 -23
- package/src/providers/openai-codex/catalog.ts +9 -4
- package/src/providers/openai-codex/index.ts +18 -2
- package/src/providers/opencode-zen/index.ts +11 -2
- package/src/proxy.ts +143 -28
- package/src/rotator.ts +296 -21
- package/src/settings-repository.ts +36 -5
- package/src/types.ts +72 -26
- package/src/validators.ts +37 -1
- package/src/web/app.tsx +6 -1
- package/src/web/components/icons.tsx +29 -0
- package/src/web/components/overlays.tsx +13 -1
- package/src/web/components/ui.tsx +6 -1
- package/src/web/lib/accounts.ts +1 -0
- package/src/web/lib/attention.ts +12 -0
- package/src/web/lib/effort.ts +407 -0
- package/src/web/lib/models.ts +284 -0
- package/src/web/lib/pools.ts +53 -9
- package/src/web/lib/status.ts +13 -3
- package/src/web/nav.ts +1 -0
- package/src/web/pages/AccountDetail.tsx +16 -2
- package/src/web/pages/EffortRouting.tsx +1130 -0
- package/src/web/pages/Models.tsx +888 -0
- package/src/web/pages/Overview.tsx +31 -15
- package/src/web/pages/Usage.tsx +3 -3
- package/src/web/state/api.ts +31 -0
- package/src/web/state/model-catalog.ts +103 -0
- package/src/web/state/router.ts +150 -19
- package/src/web/state/store.ts +6 -6
- package/src/web/styles/app.css +854 -0
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
// Models: which providers serve traffic, in what order, and which models
|
|
2
|
+
// clients can call. The provider drawer lives at /dashboard/models/<provider>.
|
|
3
|
+
|
|
4
|
+
import type { JSX } from "preact";
|
|
5
|
+
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
6
|
+
import type { CatalogModelEntry, ModelCatalogResponse } from "../../dashboard-types.js";
|
|
7
|
+
import { pluralize } from "../lib/format.js";
|
|
8
|
+
import {
|
|
9
|
+
buildModelRows,
|
|
10
|
+
canServeProvider,
|
|
11
|
+
filterModelRows,
|
|
12
|
+
formatContextWindow,
|
|
13
|
+
isModelFilter,
|
|
14
|
+
isServed,
|
|
15
|
+
isTurnedOffForAccount,
|
|
16
|
+
MODEL_FILTERS,
|
|
17
|
+
moveProvider,
|
|
18
|
+
offeringKey,
|
|
19
|
+
placeProvider,
|
|
20
|
+
providerMark,
|
|
21
|
+
providerQuotaRows,
|
|
22
|
+
quotaPoolLabel,
|
|
23
|
+
sortModelRows,
|
|
24
|
+
summarizeProviders,
|
|
25
|
+
type ModelRow,
|
|
26
|
+
type ModelSort,
|
|
27
|
+
type ProviderState,
|
|
28
|
+
type ProviderSummary,
|
|
29
|
+
} from "../lib/models.js";
|
|
30
|
+
import { providerLabel, type Tone } from "../lib/status.js";
|
|
31
|
+
import { run } from "../state/actions.js";
|
|
32
|
+
import { api } from "../state/api.js";
|
|
33
|
+
import { createModelCatalogState } from "../state/model-catalog.js";
|
|
34
|
+
import { accountPath, BASE, effortPath, navigate, providerPath, query, route, setQuery } from "../state/router.js";
|
|
35
|
+
import { masker, now, overview } from "../state/store.js";
|
|
36
|
+
import { Icon } from "../components/icons.js";
|
|
37
|
+
import { Drawer, Menu } from "../components/overlays.js";
|
|
38
|
+
import {
|
|
39
|
+
AsyncButton,
|
|
40
|
+
Button,
|
|
41
|
+
EmptyState,
|
|
42
|
+
Link,
|
|
43
|
+
Meter,
|
|
44
|
+
PageHeader,
|
|
45
|
+
Panel,
|
|
46
|
+
Pill,
|
|
47
|
+
SearchInput,
|
|
48
|
+
Spinner,
|
|
49
|
+
Stat,
|
|
50
|
+
StatusPill,
|
|
51
|
+
Switch,
|
|
52
|
+
} from "../components/ui.js";
|
|
53
|
+
import { EffortRouteDrawer, EffortRoutingPanel } from "./EffortRouting.js";
|
|
54
|
+
import { openAddAccount } from "./shared.js";
|
|
55
|
+
|
|
56
|
+
const catalogState = createModelCatalogState(() => api.catalog());
|
|
57
|
+
const { catalog, catalogError, loadCatalog } = catalogState;
|
|
58
|
+
|
|
59
|
+
/** Apply a change, show its outcome, and keep the returned catalog. */
|
|
60
|
+
async function change(
|
|
61
|
+
fn: () => Promise<ModelCatalogResponse>,
|
|
62
|
+
messages: { success?: string; failure: string },
|
|
63
|
+
): Promise<void> {
|
|
64
|
+
await catalogState.change(() => run(fn, messages));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const PROVIDER_STATE: Record<ProviderState, { label: string; tone: Tone }> = {
|
|
68
|
+
off: { label: "Off", tone: "muted" },
|
|
69
|
+
"not-connected": { label: "Not connected", tone: "muted" },
|
|
70
|
+
"needs-sign-in": { label: "Needs sign-in", tone: "warn" },
|
|
71
|
+
unavailable: { label: "No account can serve", tone: "warn" },
|
|
72
|
+
healthy: { label: "Healthy", tone: "ok" },
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const OFF_REASON: Record<NonNullable<CatalogModelEntry["offReason"]>, string> = {
|
|
76
|
+
provider: "Provider is off",
|
|
77
|
+
model: "Turned off",
|
|
78
|
+
review: "Waiting for review",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function ProviderMark({ id, size = "md" }: { id: string; size?: "sm" | "md" | "lg" }): JSX.Element {
|
|
82
|
+
const mark = providerMark(id);
|
|
83
|
+
return (
|
|
84
|
+
<span class={`provider-mark provider-mark-${size}`} style={{ "--hue": String(mark.hue) }} aria-hidden="true">
|
|
85
|
+
{mark.mark}
|
|
86
|
+
</span>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function authLabel(kind: "oauth" | "api-key"): string {
|
|
91
|
+
return kind === "oauth" ? "Sign-in" : "API key";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function ModelsPage(): JSX.Element {
|
|
95
|
+
useEffect(() => catalogState.watchRouting(overview, window), []);
|
|
96
|
+
|
|
97
|
+
const data = overview.value!;
|
|
98
|
+
const state = catalog.value;
|
|
99
|
+
const drawerId = route.value.provider;
|
|
100
|
+
|
|
101
|
+
const providers = useMemo(
|
|
102
|
+
() => (state ? summarizeProviders(state, data, now.value) : []),
|
|
103
|
+
[state, data, Math.floor(now.value / 30_000)],
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const header = (
|
|
107
|
+
<PageHeader
|
|
108
|
+
title="Models"
|
|
109
|
+
description="Choose which providers serve traffic and which models clients can call."
|
|
110
|
+
actions={
|
|
111
|
+
<>
|
|
112
|
+
<AsyncButton
|
|
113
|
+
icon="refresh"
|
|
114
|
+
onClick={() => change(() => api.refreshCatalog(), { success: "Model lists refreshed", failure: "Could not refresh the model lists" })}
|
|
115
|
+
>
|
|
116
|
+
Refresh model lists
|
|
117
|
+
</AsyncButton>
|
|
118
|
+
<Button variant="primary" icon="plus" onClick={openAddAccount}>
|
|
119
|
+
Add account
|
|
120
|
+
</Button>
|
|
121
|
+
</>
|
|
122
|
+
}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
if (!state) {
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
{header}
|
|
130
|
+
<div class="panel">
|
|
131
|
+
{catalogError.value ? (
|
|
132
|
+
<EmptyState icon="critical" title="Could not load the model catalog" action={<Button onClick={() => void loadCatalog()}>Try again</Button>}>
|
|
133
|
+
{catalogError.value}
|
|
134
|
+
</EmptyState>
|
|
135
|
+
) : (
|
|
136
|
+
<div class="panel-loading">
|
|
137
|
+
<Spinner />
|
|
138
|
+
</div>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const closeDrawer = () => {
|
|
146
|
+
const params = new URLSearchParams(query.value);
|
|
147
|
+
params.delete("from");
|
|
148
|
+
const back = params.toString();
|
|
149
|
+
navigate(`${BASE}/models${back ? `?${back}` : ""}`);
|
|
150
|
+
};
|
|
151
|
+
const drawerSummary = providers.find((summary) => summary.provider.id === drawerId) ?? null;
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<>
|
|
155
|
+
{header}
|
|
156
|
+
<ModelStats state={state} providers={providers} />
|
|
157
|
+
<ProvidersPanel state={state} providers={providers} />
|
|
158
|
+
<EffortRoutingPanel state={state} change={change} />
|
|
159
|
+
<ModelsPanel state={state} />
|
|
160
|
+
<Drawer open={Boolean(drawerId)} onClose={closeDrawer} label="Provider details">
|
|
161
|
+
{drawerId &&
|
|
162
|
+
(drawerSummary ? (
|
|
163
|
+
<ProviderDetail summary={drawerSummary} state={state} onClose={closeDrawer} />
|
|
164
|
+
) : (
|
|
165
|
+
<div class="drawer-empty">
|
|
166
|
+
<div class="drawer-head">
|
|
167
|
+
<h2>Provider not found</h2>
|
|
168
|
+
<Button variant="ghost" icon="x" iconOnly onClick={closeDrawer}>
|
|
169
|
+
Close
|
|
170
|
+
</Button>
|
|
171
|
+
</div>
|
|
172
|
+
<p class="muted">There is no provider called “{drawerId}”.</p>
|
|
173
|
+
</div>
|
|
174
|
+
))}
|
|
175
|
+
</Drawer>
|
|
176
|
+
<EffortRouteDrawer
|
|
177
|
+
state={state}
|
|
178
|
+
match={route.value.effort}
|
|
179
|
+
change={change}
|
|
180
|
+
commit={(fn) => catalogState.change(fn)}
|
|
181
|
+
onClose={closeDrawer}
|
|
182
|
+
/>
|
|
183
|
+
</>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function ModelStats({ state, providers }: { state: ModelCatalogResponse; providers: ProviderSummary[] }): JSX.Element {
|
|
188
|
+
const rows = buildModelRows(state, {});
|
|
189
|
+
const on = rows.filter((row) => row.on).length;
|
|
190
|
+
const shared = rows.filter((row) => row.shared).length;
|
|
191
|
+
const waiting = rows.filter((row) => row.waiting).length;
|
|
192
|
+
const connected = providers.filter((summary) => summary.accounts.length > 0);
|
|
193
|
+
const routing = connected.filter((summary) => summary.provider.enabled).length;
|
|
194
|
+
return (
|
|
195
|
+
<div class="stats stats-card">
|
|
196
|
+
<Stat
|
|
197
|
+
label="Providers"
|
|
198
|
+
value={
|
|
199
|
+
<>
|
|
200
|
+
{routing}
|
|
201
|
+
<span class="stat-of"> of {connected.length}</span>
|
|
202
|
+
</>
|
|
203
|
+
}
|
|
204
|
+
sub="connected providers routing traffic"
|
|
205
|
+
/>
|
|
206
|
+
<Stat
|
|
207
|
+
label="Models on"
|
|
208
|
+
value={
|
|
209
|
+
<>
|
|
210
|
+
{on}
|
|
211
|
+
<span class="stat-of"> of {rows.length}</span>
|
|
212
|
+
</>
|
|
213
|
+
}
|
|
214
|
+
sub={rows.length - on > 0 ? `${rows.length - on} off` : "every model is on"}
|
|
215
|
+
/>
|
|
216
|
+
<Stat label="Shared" value={shared} sub={shared === 1 ? "model listed by two providers" : "models listed by more than one provider"} />
|
|
217
|
+
{!state.autoEnableNewModels && (
|
|
218
|
+
<Stat label="Waiting for review" value={waiting} sub="new models stay off until you turn them on" tone={waiting > 0 ? "warn" : undefined} />
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ── Providers ───────────────────────────────────────────────────────────
|
|
225
|
+
|
|
226
|
+
function ProvidersPanel({ state, providers }: { state: ModelCatalogResponse; providers: ProviderSummary[] }): JSX.Element {
|
|
227
|
+
const order = state.providers.map((provider) => provider.id);
|
|
228
|
+
const [dragging, setDragging] = useState<string | null>(null);
|
|
229
|
+
const [drop, setDrop] = useState<{ id: string; after: boolean } | null>(null);
|
|
230
|
+
|
|
231
|
+
const reorder = (next: string[]) => {
|
|
232
|
+
if (next.join() === order.join()) return;
|
|
233
|
+
void change(() => api.setProviderOrder(next), { success: "Provider order saved", failure: "Could not save the provider order" });
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<Panel
|
|
238
|
+
flush
|
|
239
|
+
class="providers-panel"
|
|
240
|
+
title="Providers"
|
|
241
|
+
subtitle="When more than one provider lists the same model, the one higher in this list gets the request. Drag a provider to change the order."
|
|
242
|
+
>
|
|
243
|
+
<div class="table-scroll">
|
|
244
|
+
<table class="table providers-table">
|
|
245
|
+
<thead>
|
|
246
|
+
<tr>
|
|
247
|
+
<th scope="col">
|
|
248
|
+
<span class="sr-only">Order</span>
|
|
249
|
+
</th>
|
|
250
|
+
<th scope="col">Provider</th>
|
|
251
|
+
<th scope="col" class="hide-sm">
|
|
252
|
+
Accounts
|
|
253
|
+
</th>
|
|
254
|
+
<th scope="col" class="hide-sm">
|
|
255
|
+
Models
|
|
256
|
+
</th>
|
|
257
|
+
<th scope="col" class="hide-sm">
|
|
258
|
+
Quota
|
|
259
|
+
</th>
|
|
260
|
+
<th scope="col">Status</th>
|
|
261
|
+
<th scope="col">Routing</th>
|
|
262
|
+
<th scope="col">
|
|
263
|
+
<span class="sr-only">Actions</span>
|
|
264
|
+
</th>
|
|
265
|
+
</tr>
|
|
266
|
+
</thead>
|
|
267
|
+
<tbody>
|
|
268
|
+
{providers.map((summary) => {
|
|
269
|
+
const { provider } = summary;
|
|
270
|
+
const meta = PROVIDER_STATE[summary.state];
|
|
271
|
+
const dropClass = drop?.id === provider.id && dragging !== provider.id ? (drop.after ? " drop-after" : " drop-before") : "";
|
|
272
|
+
return (
|
|
273
|
+
<tr
|
|
274
|
+
key={provider.id}
|
|
275
|
+
class={`provider-row${provider.enabled ? "" : " is-off"}${dragging === provider.id ? " is-dragging" : ""}${dropClass}`}
|
|
276
|
+
draggable
|
|
277
|
+
onDragStart={(event) => {
|
|
278
|
+
setDragging(provider.id);
|
|
279
|
+
if (event.dataTransfer) {
|
|
280
|
+
event.dataTransfer.effectAllowed = "move";
|
|
281
|
+
event.dataTransfer.setData("text/plain", provider.id);
|
|
282
|
+
}
|
|
283
|
+
}}
|
|
284
|
+
onDragEnd={() => {
|
|
285
|
+
setDragging(null);
|
|
286
|
+
setDrop(null);
|
|
287
|
+
}}
|
|
288
|
+
onDragOver={(event) => {
|
|
289
|
+
if (!dragging) return;
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
|
292
|
+
setDrop({ id: provider.id, after: event.clientY > rect.top + rect.height / 2 });
|
|
293
|
+
}}
|
|
294
|
+
onDrop={(event) => {
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
if (dragging && drop) reorder(placeProvider(order, dragging, drop.id, drop.after));
|
|
297
|
+
setDragging(null);
|
|
298
|
+
setDrop(null);
|
|
299
|
+
}}
|
|
300
|
+
onClick={(event) => {
|
|
301
|
+
if ((event.target as HTMLElement).closest("button, a, .switch-field")) return;
|
|
302
|
+
navigate(providerPath(provider.id));
|
|
303
|
+
}}
|
|
304
|
+
>
|
|
305
|
+
<td class="rank-cell">
|
|
306
|
+
<span class="rank">
|
|
307
|
+
<span class="grip" title="Drag to reorder" aria-hidden="true">
|
|
308
|
+
<Icon name="grip" size={15} />
|
|
309
|
+
</span>
|
|
310
|
+
<span class="rank-num num">{summary.rank + 1}</span>
|
|
311
|
+
</span>
|
|
312
|
+
</td>
|
|
313
|
+
<th scope="row">
|
|
314
|
+
<div class="provider-cell">
|
|
315
|
+
<ProviderMark id={provider.id} />
|
|
316
|
+
<div>
|
|
317
|
+
<Link href={providerPath(provider.id)} class="provider-name">
|
|
318
|
+
{provider.name}
|
|
319
|
+
</Link>
|
|
320
|
+
<div class="cell-sub">{authLabel(provider.credentialKind)}</div>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</th>
|
|
324
|
+
<td class="hide-sm">
|
|
325
|
+
{summary.accounts.length === 0 ? (
|
|
326
|
+
<span class="muted">None</span>
|
|
327
|
+
) : (
|
|
328
|
+
<>
|
|
329
|
+
<span class="num">{summary.accounts.length}</span>
|
|
330
|
+
<span class="muted"> · {summary.canServe} can serve</span>
|
|
331
|
+
</>
|
|
332
|
+
)}
|
|
333
|
+
</td>
|
|
334
|
+
<td class="hide-sm">
|
|
335
|
+
<span class="num">{summary.modelsOn}</span>
|
|
336
|
+
<span class="muted"> of {summary.models} on</span>
|
|
337
|
+
</td>
|
|
338
|
+
<td class="hide-sm">
|
|
339
|
+
<QuotaList quotas={summary.quotas} />
|
|
340
|
+
</td>
|
|
341
|
+
<td>
|
|
342
|
+
<Pill tone={meta.tone}>{meta.label}</Pill>
|
|
343
|
+
{summary.state === "needs-sign-in" && (
|
|
344
|
+
<div class="cell-sub">
|
|
345
|
+
{summary.rejected.length} of {pluralize(summary.accounts.length, "credential")} rejected
|
|
346
|
+
</div>
|
|
347
|
+
)}
|
|
348
|
+
</td>
|
|
349
|
+
<td class="cell-switch">
|
|
350
|
+
<Switch
|
|
351
|
+
label={provider.enabled ? "On" : "Off"}
|
|
352
|
+
ariaLabel={`Route traffic to ${provider.name}`}
|
|
353
|
+
checked={provider.enabled}
|
|
354
|
+
onChange={(on) =>
|
|
355
|
+
change(() => api.setProviderEnabled(provider.id, on), {
|
|
356
|
+
success: on ? `${provider.name} is routing traffic again` : `${provider.name} turned off. Its accounts stay signed in.`,
|
|
357
|
+
failure: `Could not turn ${provider.name} ${on ? "on" : "off"}`,
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
/>
|
|
361
|
+
</td>
|
|
362
|
+
<td class="cell-action">
|
|
363
|
+
<Menu
|
|
364
|
+
label={`Actions for ${provider.name}`}
|
|
365
|
+
items={[
|
|
366
|
+
{ label: "Manage", icon: "settings", onSelect: () => navigate(providerPath(provider.id)) },
|
|
367
|
+
{ label: "Move up", icon: "arrowUp", disabled: summary.rank === 0, onSelect: () => reorder(moveProvider(order, provider.id, -1)) },
|
|
368
|
+
{ label: "Move down", icon: "arrowDown", disabled: summary.rank === order.length - 1, onSelect: () => reorder(moveProvider(order, provider.id, 1)) },
|
|
369
|
+
"separator",
|
|
370
|
+
{ label: "Add account", icon: "plus", onSelect: openAddAccount },
|
|
371
|
+
]}
|
|
372
|
+
/>
|
|
373
|
+
</td>
|
|
374
|
+
</tr>
|
|
375
|
+
);
|
|
376
|
+
})}
|
|
377
|
+
</tbody>
|
|
378
|
+
</table>
|
|
379
|
+
</div>
|
|
380
|
+
</Panel>
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function QuotaList({ quotas }: { quotas: ProviderSummary["quotas"] }): JSX.Element {
|
|
385
|
+
if (quotas.length === 0) return <span class="muted">—</span>;
|
|
386
|
+
return (
|
|
387
|
+
<div class="quota-mini">
|
|
388
|
+
{quotas.map((quota) => (
|
|
389
|
+
<div class="quota-mini-row" key={quota.key}>
|
|
390
|
+
<span class="truncate">{quota.name}</span>
|
|
391
|
+
<Meter value={quota.percent} label={`${quota.name} quota remaining`} size="sm" />
|
|
392
|
+
<span class="num">{Math.round(quota.percent)}%</span>
|
|
393
|
+
</div>
|
|
394
|
+
))}
|
|
395
|
+
</div>
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// ── Models ──────────────────────────────────────────────────────────────
|
|
400
|
+
|
|
401
|
+
function ModelsPanel({ state }: { state: ModelCatalogResponse }): JSX.Element {
|
|
402
|
+
const params = query.value;
|
|
403
|
+
const filterParam = params.get("filter");
|
|
404
|
+
const filter = isModelFilter(filterParam) ? filterParam : "all";
|
|
405
|
+
const provider = params.get("provider") ?? "";
|
|
406
|
+
const search = params.get("q") ?? "";
|
|
407
|
+
const sort: ModelSort = params.get("sort") === "name" ? "name" : "requests";
|
|
408
|
+
const [open, setOpen] = useState<Set<string>>(new Set());
|
|
409
|
+
const requests = overview.value?.recentRequestsByModel ?? {};
|
|
410
|
+
|
|
411
|
+
const rows = useMemo(() => buildModelRows(state, requests), [state, requests]);
|
|
412
|
+
const visible = useMemo(
|
|
413
|
+
() => sortModelRows(filterModelRows(rows, { filter, provider, query: search }), sort),
|
|
414
|
+
[rows, filter, provider, search, sort],
|
|
415
|
+
);
|
|
416
|
+
const counts = Object.fromEntries(MODEL_FILTERS.map((entry) => [entry.id, rows.filter(entry.match).length]));
|
|
417
|
+
const names = Object.fromEntries(state.providers.map((entry) => [entry.id, entry.name]));
|
|
418
|
+
|
|
419
|
+
const toggleOpen = (key: string) => {
|
|
420
|
+
const next = new Set(open);
|
|
421
|
+
if (next.has(key)) next.delete(key);
|
|
422
|
+
else next.add(key);
|
|
423
|
+
setOpen(next);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<Panel
|
|
428
|
+
flush
|
|
429
|
+
class="models-panel"
|
|
430
|
+
title="Models"
|
|
431
|
+
subtitle={
|
|
432
|
+
<>
|
|
433
|
+
Every model your providers can serve. Turning one off removes it from <code>/v1/models</code> and rejects requests for it.
|
|
434
|
+
</>
|
|
435
|
+
}
|
|
436
|
+
actions={
|
|
437
|
+
<label class="new-models">
|
|
438
|
+
New models
|
|
439
|
+
<select
|
|
440
|
+
class="select"
|
|
441
|
+
value={state.autoEnableNewModels ? "on" : "review"}
|
|
442
|
+
onChange={(event) => {
|
|
443
|
+
const on = (event.target as HTMLSelectElement).value === "on";
|
|
444
|
+
void change(() => api.setAutoEnableNewModels(on), {
|
|
445
|
+
success: on ? "New models now turn on as soon as a provider lists them" : "New models now stay off until you turn them on",
|
|
446
|
+
failure: "Could not change how new models are handled",
|
|
447
|
+
});
|
|
448
|
+
}}
|
|
449
|
+
>
|
|
450
|
+
<option value="on">Turn on automatically</option>
|
|
451
|
+
<option value="review">Wait for review</option>
|
|
452
|
+
</select>
|
|
453
|
+
</label>
|
|
454
|
+
}
|
|
455
|
+
>
|
|
456
|
+
<div class="toolbar panel-toolbar">
|
|
457
|
+
<div class="chips" role="group" aria-label="Filter models">
|
|
458
|
+
{MODEL_FILTERS.filter((entry) => entry.id === "all" || counts[entry.id] > 0 || filter === entry.id).map((entry) => (
|
|
459
|
+
<button
|
|
460
|
+
key={entry.id}
|
|
461
|
+
type="button"
|
|
462
|
+
class={`filter-chip${filter === entry.id ? " is-active" : ""}`}
|
|
463
|
+
aria-pressed={filter === entry.id}
|
|
464
|
+
onClick={() => setQuery({ filter: entry.id === "all" ? null : entry.id })}
|
|
465
|
+
>
|
|
466
|
+
{entry.label}
|
|
467
|
+
<span class="filter-count num">{counts[entry.id]}</span>
|
|
468
|
+
</button>
|
|
469
|
+
))}
|
|
470
|
+
</div>
|
|
471
|
+
<div class="toolbar-right">
|
|
472
|
+
<select class="select" aria-label="Filter by provider" value={provider} onChange={(event) => setQuery({ provider: (event.target as HTMLSelectElement).value || null })}>
|
|
473
|
+
<option value="">All providers</option>
|
|
474
|
+
{state.providers.map((entry) => (
|
|
475
|
+
<option key={entry.id} value={entry.id}>
|
|
476
|
+
{entry.name}
|
|
477
|
+
</option>
|
|
478
|
+
))}
|
|
479
|
+
</select>
|
|
480
|
+
<span data-page-search>
|
|
481
|
+
<SearchInput value={search} onInput={(value) => setQuery({ q: value || null })} placeholder="Model ID" label="Search models" shortcut="/" />
|
|
482
|
+
</span>
|
|
483
|
+
</div>
|
|
484
|
+
</div>
|
|
485
|
+
{visible.length === 0 ? (
|
|
486
|
+
<EmptyState icon="search" title={rows.length === 0 ? "No models yet" : "No models match"}>
|
|
487
|
+
{rows.length === 0 ? "Add an account so its provider can list the models it serves." : undefined}
|
|
488
|
+
</EmptyState>
|
|
489
|
+
) : (
|
|
490
|
+
<div class="table-scroll">
|
|
491
|
+
<table class="table models-table">
|
|
492
|
+
<thead>
|
|
493
|
+
<tr>
|
|
494
|
+
<th scope="col" aria-sort={sort === "name" ? "ascending" : "none"}>
|
|
495
|
+
<button type="button" class="th-sort" onClick={() => setQuery({ sort: "name" })}>
|
|
496
|
+
Model {sort === "name" && <Icon name="chevronDown" size={12} />}
|
|
497
|
+
</button>
|
|
498
|
+
</th>
|
|
499
|
+
<th scope="col">Served by</th>
|
|
500
|
+
<th scope="col" class="hide-sm">
|
|
501
|
+
Context
|
|
502
|
+
</th>
|
|
503
|
+
<th scope="col" class="hide-sm">
|
|
504
|
+
Quota
|
|
505
|
+
</th>
|
|
506
|
+
<th scope="col" class="num-col" aria-sort={sort === "requests" ? "descending" : "none"}>
|
|
507
|
+
<button type="button" class="th-sort" onClick={() => setQuery({ sort: null })} title="Requests in the last hour">
|
|
508
|
+
Last hour {sort === "requests" && <Icon name="chevronDown" size={12} />}
|
|
509
|
+
</button>
|
|
510
|
+
</th>
|
|
511
|
+
<th scope="col">Enabled</th>
|
|
512
|
+
<th scope="col">
|
|
513
|
+
<span class="sr-only">Providers</span>
|
|
514
|
+
</th>
|
|
515
|
+
</tr>
|
|
516
|
+
</thead>
|
|
517
|
+
<tbody>
|
|
518
|
+
{visible.map((row) => (
|
|
519
|
+
<ModelRows
|
|
520
|
+
key={row.key}
|
|
521
|
+
row={row}
|
|
522
|
+
names={names}
|
|
523
|
+
open={open.has(row.key)}
|
|
524
|
+
onToggleOpen={() => toggleOpen(row.key)}
|
|
525
|
+
effortListed={row.effortRoute ? state.effortRoutes.some((entry) => entry.alias === row.effortRoute!.alias && entry.listed) : false}
|
|
526
|
+
/>
|
|
527
|
+
))}
|
|
528
|
+
</tbody>
|
|
529
|
+
</table>
|
|
530
|
+
</div>
|
|
531
|
+
)}
|
|
532
|
+
</Panel>
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function ServedBy({ row, names }: { row: ModelRow; names: Record<string, string> }): JSX.Element {
|
|
537
|
+
return (
|
|
538
|
+
<span class="served-by">
|
|
539
|
+
{row.offerings.map((entry, index) => (
|
|
540
|
+
<span key={entry.providerId} class="served-by-item">
|
|
541
|
+
{index > 0 && <Icon name="chevronRight" size={12} class="served-by-sep" />}
|
|
542
|
+
<span
|
|
543
|
+
class={`provider-chip${isServed(entry) ? "" : " is-off"}${entry.routed && row.shared ? " is-routed" : ""}`}
|
|
544
|
+
title={`${names[entry.providerId] ?? entry.providerId}${isServed(entry) ? "" : ` (${OFF_REASON[entry.offReason!].toLowerCase()})`}`}
|
|
545
|
+
>
|
|
546
|
+
<ProviderMark id={entry.providerId} size="sm" />
|
|
547
|
+
{providerLabel(entry.providerId)}
|
|
548
|
+
</span>
|
|
549
|
+
</span>
|
|
550
|
+
))}
|
|
551
|
+
</span>
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function ModelRows({
|
|
556
|
+
row,
|
|
557
|
+
names,
|
|
558
|
+
open,
|
|
559
|
+
onToggleOpen,
|
|
560
|
+
effortListed = false,
|
|
561
|
+
}: {
|
|
562
|
+
row: ModelRow;
|
|
563
|
+
names: Record<string, string>;
|
|
564
|
+
open: boolean;
|
|
565
|
+
onToggleOpen: () => void;
|
|
566
|
+
/** The effort-routed ID that uses this model is listed, which hides the model from /v1/models. */
|
|
567
|
+
effortListed?: boolean;
|
|
568
|
+
}): JSX.Element {
|
|
569
|
+
// Offerings whose provider is on; the row switch acts on those.
|
|
570
|
+
const switchable = row.offerings.filter((entry) => entry.offReason !== "provider");
|
|
571
|
+
const contexts = [...new Set(row.offerings.map((entry) => formatContextWindow(entry.contextWindow)))];
|
|
572
|
+
const pools = [...new Set(row.offerings.map((entry) => quotaPoolLabel(entry.quotaPool)))];
|
|
573
|
+
const routed = row.offerings.find((entry) => entry.routed);
|
|
574
|
+
const only = row.offerings[0];
|
|
575
|
+
|
|
576
|
+
const setRow = (on: boolean) =>
|
|
577
|
+
change(() => api.setModelsEnabled(switchable.map(offeringKey), on), {
|
|
578
|
+
success: `${row.id} turned ${on ? "on" : "off"}`,
|
|
579
|
+
failure: `Could not turn ${row.id} ${on ? "on" : "off"}`,
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
let sub: string | null = null;
|
|
583
|
+
if (row.shared) sub = routed ? `Requests go to ${names[routed.providerId] ?? routed.providerId}` : "No provider is serving it";
|
|
584
|
+
else if (only.offReason === "provider") sub = `${names[only.providerId] ?? only.providerId} is off`;
|
|
585
|
+
else if (only.source === "discovered" && only.offReason !== "review") sub = "Found by the provider at runtime";
|
|
586
|
+
|
|
587
|
+
return (
|
|
588
|
+
<>
|
|
589
|
+
<tr class={`model-row${row.on ? "" : " is-off"}${open ? " is-open" : ""}`}>
|
|
590
|
+
<th scope="row">
|
|
591
|
+
<div class="model-name">
|
|
592
|
+
<span class="model-id">{row.id}</span>
|
|
593
|
+
{row.shared && <span class="tag tag-accent">Shared</span>}
|
|
594
|
+
{row.waiting && <span class="tag tag-info">Waiting for review</span>}
|
|
595
|
+
{row.effortRoute && <span class="tag tag-accent">Effort · {row.effortRoute.effort}</span>}
|
|
596
|
+
</div>
|
|
597
|
+
{sub && <div class="cell-sub">{sub}</div>}
|
|
598
|
+
{row.effortRoute && (
|
|
599
|
+
<div class="cell-sub">
|
|
600
|
+
Called as{" "}
|
|
601
|
+
<Link href={effortPath(row.effortRoute.alias)} class="effort-inline-link">
|
|
602
|
+
{row.effortRoute.alias}
|
|
603
|
+
</Link>
|
|
604
|
+
{effortListed && (
|
|
605
|
+
<>
|
|
606
|
+
{" "}
|
|
607
|
+
· hidden from <code>/v1/models</code>
|
|
608
|
+
</>
|
|
609
|
+
)}
|
|
610
|
+
</div>
|
|
611
|
+
)}
|
|
612
|
+
</th>
|
|
613
|
+
<td>
|
|
614
|
+
<ServedBy row={row} names={names} />
|
|
615
|
+
</td>
|
|
616
|
+
<td class="hide-sm num">{contexts.join(" / ")}</td>
|
|
617
|
+
<td class="hide-sm">{pools.join(" · ")}</td>
|
|
618
|
+
<td class="num-col num">{row.requests > 0 ? row.requests.toLocaleString() : <span class="muted">—</span>}</td>
|
|
619
|
+
<td class="cell-switch">
|
|
620
|
+
<Switch
|
|
621
|
+
label={row.shared ? `${row.offerings.filter(isServed).length} of ${row.offerings.length}` : ""}
|
|
622
|
+
ariaLabel={`Serve ${row.id}`}
|
|
623
|
+
checked={row.on}
|
|
624
|
+
disabled={switchable.length === 0}
|
|
625
|
+
onChange={setRow}
|
|
626
|
+
/>
|
|
627
|
+
</td>
|
|
628
|
+
<td class="cell-action">
|
|
629
|
+
{row.shared && (
|
|
630
|
+
<Button variant="ghost" size="sm" iconOnly icon={open ? "chevronDown" : "chevronRight"} aria-expanded={open} onClick={onToggleOpen}>
|
|
631
|
+
{open ? "Hide providers" : "Show providers"}
|
|
632
|
+
</Button>
|
|
633
|
+
)}
|
|
634
|
+
</td>
|
|
635
|
+
</tr>
|
|
636
|
+
{open &&
|
|
637
|
+
row.offerings.map((entry, index) => (
|
|
638
|
+
<tr key={entry.providerId} class={`model-subrow${isServed(entry) ? "" : " is-off"}`}>
|
|
639
|
+
<th scope="row">
|
|
640
|
+
<div class="model-subrow-provider">
|
|
641
|
+
<span class="rank-num num">{index + 1}</span>
|
|
642
|
+
<ProviderMark id={entry.providerId} size="sm" />
|
|
643
|
+
<span>{names[entry.providerId] ?? entry.providerId}</span>
|
|
644
|
+
{entry.routed && <span class="tag tag-accent">Gets requests</span>}
|
|
645
|
+
</div>
|
|
646
|
+
</th>
|
|
647
|
+
<td class="muted">{isServed(entry) ? "Served" : OFF_REASON[entry.offReason!]}</td>
|
|
648
|
+
<td class="hide-sm num">{formatContextWindow(entry.contextWindow)}</td>
|
|
649
|
+
<td class="hide-sm">{quotaPoolLabel(entry.quotaPool)}</td>
|
|
650
|
+
<td />
|
|
651
|
+
<td class="cell-switch">
|
|
652
|
+
<Switch
|
|
653
|
+
label=""
|
|
654
|
+
ariaLabel={`Serve ${row.id} from ${names[entry.providerId] ?? entry.providerId}`}
|
|
655
|
+
checked={entry.modelSwitch === "on"}
|
|
656
|
+
onChange={(on) =>
|
|
657
|
+
change(() => api.setModelsEnabled([offeringKey(entry)], on), {
|
|
658
|
+
success: `${names[entry.providerId] ?? entry.providerId} ${on ? "serves" : "no longer serves"} ${entry.id}`,
|
|
659
|
+
failure: `Could not change ${entry.id}`,
|
|
660
|
+
})
|
|
661
|
+
}
|
|
662
|
+
/>
|
|
663
|
+
</td>
|
|
664
|
+
<td />
|
|
665
|
+
</tr>
|
|
666
|
+
))}
|
|
667
|
+
</>
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// ── Provider drawer ─────────────────────────────────────────────────────
|
|
672
|
+
|
|
673
|
+
const STATE_TEXT: Record<ProviderState, (summary: ProviderSummary) => string> = {
|
|
674
|
+
off: (summary) => `${summary.provider.name} is turned off. Its accounts stay signed in and keep reporting quota, but no requests go to it.`,
|
|
675
|
+
"not-connected": (summary) => `No account has a ${summary.provider.name} credential yet. Add one to start using its models.`,
|
|
676
|
+
"needs-sign-in": (summary) =>
|
|
677
|
+
`${summary.provider.name} rejected the credential for ${summary.rejected.map((account) => masker.value.name(account.email)).join(", ")}. Sign in again with Add account; the account's other providers keep working.`,
|
|
678
|
+
unavailable: (summary) => `No account can serve ${summary.provider.name} right now. Check the accounts below.`,
|
|
679
|
+
healthy: (summary) => `${summary.canServe} of ${pluralize(summary.accounts.length, "account")} can serve ${summary.provider.name}.`,
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
function ProviderDetail({
|
|
683
|
+
summary,
|
|
684
|
+
state,
|
|
685
|
+
onClose,
|
|
686
|
+
}: {
|
|
687
|
+
summary: ProviderSummary;
|
|
688
|
+
state: ModelCatalogResponse;
|
|
689
|
+
onClose: () => void;
|
|
690
|
+
}): JSX.Element {
|
|
691
|
+
const { provider } = summary;
|
|
692
|
+
const meta = PROVIDER_STATE[summary.state];
|
|
693
|
+
const models = state.models.filter((entry) => entry.providerId === provider.id);
|
|
694
|
+
const m = masker.value;
|
|
695
|
+
const discovers = models.some((entry) => entry.source === "discovered");
|
|
696
|
+
|
|
697
|
+
return (
|
|
698
|
+
<article class="account-detail provider-detail" aria-label={`${provider.name} details`}>
|
|
699
|
+
<header class="drawer-head">
|
|
700
|
+
<div class="drawer-title provider-detail-title">
|
|
701
|
+
<ProviderMark id={provider.id} size="lg" />
|
|
702
|
+
<div>
|
|
703
|
+
<h2>{provider.name}</h2>
|
|
704
|
+
<div class="drawer-sub">
|
|
705
|
+
<span>{authLabel(provider.credentialKind)}</span>
|
|
706
|
+
<span aria-hidden="true">·</span>
|
|
707
|
+
<span>#{summary.rank + 1} in provider order</span>
|
|
708
|
+
</div>
|
|
709
|
+
</div>
|
|
710
|
+
</div>
|
|
711
|
+
<Button variant="ghost" icon="x" iconOnly onClick={onClose}>
|
|
712
|
+
Close
|
|
713
|
+
</Button>
|
|
714
|
+
</header>
|
|
715
|
+
|
|
716
|
+
<section class={`detail-status tone-${meta.tone}`}>
|
|
717
|
+
<div class="detail-status-line">
|
|
718
|
+
<Pill tone={meta.tone}>{meta.label}</Pill>
|
|
719
|
+
</div>
|
|
720
|
+
<p>{STATE_TEXT[summary.state](summary)}</p>
|
|
721
|
+
<div class="detail-actions">
|
|
722
|
+
{(summary.state === "needs-sign-in" || summary.state === "not-connected") && (
|
|
723
|
+
<Button variant="primary" icon="login" onClick={openAddAccount}>
|
|
724
|
+
{summary.state === "needs-sign-in" ? "Sign in again" : "Add account"}
|
|
725
|
+
</Button>
|
|
726
|
+
)}
|
|
727
|
+
{summary.state !== "not-connected" && (
|
|
728
|
+
<Button icon="plus" onClick={openAddAccount}>
|
|
729
|
+
Add account
|
|
730
|
+
</Button>
|
|
731
|
+
)}
|
|
732
|
+
{discovers && (
|
|
733
|
+
<AsyncButton
|
|
734
|
+
icon="refresh"
|
|
735
|
+
onClick={() => change(() => api.refreshCatalog(), { success: "Model lists refreshed", failure: "Could not refresh the model lists" })}
|
|
736
|
+
>
|
|
737
|
+
Refresh model list
|
|
738
|
+
</AsyncButton>
|
|
739
|
+
)}
|
|
740
|
+
</div>
|
|
741
|
+
</section>
|
|
742
|
+
|
|
743
|
+
<section class="detail-section">
|
|
744
|
+
<Switch
|
|
745
|
+
label={`Route traffic to ${provider.name}`}
|
|
746
|
+
checked={provider.enabled}
|
|
747
|
+
onChange={(on) =>
|
|
748
|
+
change(() => api.setProviderEnabled(provider.id, on), {
|
|
749
|
+
success: on ? `${provider.name} is routing traffic again` : `${provider.name} turned off. Its accounts stay signed in.`,
|
|
750
|
+
failure: `Could not turn ${provider.name} ${on ? "on" : "off"}`,
|
|
751
|
+
})
|
|
752
|
+
}
|
|
753
|
+
description={`When off, no requests go to ${provider.name}. Accounts stay signed in and quota keeps updating. Models only ${provider.name} lists leave the model list; a model another provider also lists moves to that provider.`}
|
|
754
|
+
/>
|
|
755
|
+
</section>
|
|
756
|
+
|
|
757
|
+
<section class="detail-section">
|
|
758
|
+
<div class="section-head">
|
|
759
|
+
<h3>Accounts</h3>
|
|
760
|
+
{summary.accounts.length > 0 && (
|
|
761
|
+
<Link href={`${BASE}/accounts?provider=${encodeURIComponent(provider.id)}`} class="link-button">
|
|
762
|
+
Open in Accounts
|
|
763
|
+
</Link>
|
|
764
|
+
)}
|
|
765
|
+
</div>
|
|
766
|
+
{summary.accounts.length === 0 ? (
|
|
767
|
+
<p class="muted">No accounts yet.</p>
|
|
768
|
+
) : (
|
|
769
|
+
<>
|
|
770
|
+
<div class="panel panel-flush">
|
|
771
|
+
<table class="table table-compact">
|
|
772
|
+
<thead>
|
|
773
|
+
<tr>
|
|
774
|
+
<th scope="col">Account</th>
|
|
775
|
+
<th scope="col">Status</th>
|
|
776
|
+
<th scope="col" class="hide-sm">
|
|
777
|
+
Quota
|
|
778
|
+
</th>
|
|
779
|
+
<th scope="col">Use for {providerLabel(provider.id)}</th>
|
|
780
|
+
</tr>
|
|
781
|
+
</thead>
|
|
782
|
+
<tbody>
|
|
783
|
+
{summary.accounts.map((account) => {
|
|
784
|
+
const off = isTurnedOffForAccount(account, provider.id);
|
|
785
|
+
const rejected = Boolean(account.invalidProviders?.[provider.id]);
|
|
786
|
+
const others = account.provider.split("+").filter((id) => id && id !== provider.id);
|
|
787
|
+
const quotas = providerQuotaRows(account, provider.id);
|
|
788
|
+
return (
|
|
789
|
+
<tr key={account.id ?? account.email} class={off ? "is-inactive" : undefined}>
|
|
790
|
+
<th scope="row">
|
|
791
|
+
<Link href={accountPath(account.email)} class="account-link">
|
|
792
|
+
{m.name(account.email)}
|
|
793
|
+
</Link>
|
|
794
|
+
{others.length > 0 && <div class="cell-sub">also {others.map(providerLabel).join(", ")}</div>}
|
|
795
|
+
</th>
|
|
796
|
+
<td>
|
|
797
|
+
{rejected ? <Pill tone="bad">Sign-in needed</Pill> : off ? <Pill tone="muted">Off for {providerLabel(provider.id)}</Pill> : <StatusPill status={account.status} />}
|
|
798
|
+
</td>
|
|
799
|
+
<td class="hide-sm">
|
|
800
|
+
{quotas.length === 0 ? (
|
|
801
|
+
<span class="muted">—</span>
|
|
802
|
+
) : (
|
|
803
|
+
<div class="quota-mini">
|
|
804
|
+
{quotas.slice(0, 2).map((quota) => (
|
|
805
|
+
<div class="quota-mini-row" key={quota.modelKey}>
|
|
806
|
+
<span class="truncate">{quota.displayName || quotaPoolLabel(quota.modelKey)}</span>
|
|
807
|
+
<Meter value={quota.percentRemaining} label={`${quota.displayName} quota remaining`} size="sm" />
|
|
808
|
+
<span class="num">{Math.round(quota.percentRemaining)}%</span>
|
|
809
|
+
</div>
|
|
810
|
+
))}
|
|
811
|
+
</div>
|
|
812
|
+
)}
|
|
813
|
+
</td>
|
|
814
|
+
<td class="cell-switch">
|
|
815
|
+
<Switch
|
|
816
|
+
label=""
|
|
817
|
+
ariaLabel={`Use ${m.name(account.email)} for ${provider.name}`}
|
|
818
|
+
checked={!off}
|
|
819
|
+
onChange={(on) =>
|
|
820
|
+
change(() => api.setAccountProviderEnabled(account.id ?? account.email, provider.id, on), {
|
|
821
|
+
success: `${provider.name} turned ${on ? "on" : "off"} for ${m.name(account.email)}`,
|
|
822
|
+
failure: `Could not change ${m.name(account.email)}`,
|
|
823
|
+
})
|
|
824
|
+
}
|
|
825
|
+
/>
|
|
826
|
+
</td>
|
|
827
|
+
</tr>
|
|
828
|
+
);
|
|
829
|
+
})}
|
|
830
|
+
</tbody>
|
|
831
|
+
</table>
|
|
832
|
+
</div>
|
|
833
|
+
<p class="section-note">
|
|
834
|
+
This switch only affects {provider.name}. To take a whole account out of service, disable it on the Accounts page.
|
|
835
|
+
{summary.accounts.some((account) => !canServeProvider(account, provider.id, now.value, {
|
|
836
|
+
quotaPools: models.map((entry) => entry.quotaPool),
|
|
837
|
+
diagnostics: overview.value?.routingDiagnostics ?? {},
|
|
838
|
+
}) && !isTurnedOffForAccount(account, provider.id)) &&
|
|
839
|
+
" Accounts that are cooling down or disabled come back on their own or from the Accounts page."}
|
|
840
|
+
</p>
|
|
841
|
+
</>
|
|
842
|
+
)}
|
|
843
|
+
</section>
|
|
844
|
+
|
|
845
|
+
<section class="detail-section">
|
|
846
|
+
<div class="section-head">
|
|
847
|
+
<h3>Models</h3>
|
|
848
|
+
<span class="muted">
|
|
849
|
+
{models.filter(isServed).length} of {models.length} on
|
|
850
|
+
</span>
|
|
851
|
+
</div>
|
|
852
|
+
{models.length === 0 ? (
|
|
853
|
+
<p class="muted">{provider.name} has not listed any models yet.</p>
|
|
854
|
+
) : (
|
|
855
|
+
<div class="panel panel-flush">
|
|
856
|
+
<table class="table table-compact">
|
|
857
|
+
<tbody>
|
|
858
|
+
{models.map((entry) => (
|
|
859
|
+
<tr key={entry.id} class={isServed(entry) ? undefined : "is-inactive"}>
|
|
860
|
+
<th scope="row">
|
|
861
|
+
<span class="model-id">{entry.id}</span>
|
|
862
|
+
{entry.modelSwitch === "review" && <span class="tag tag-info">Waiting for review</span>}
|
|
863
|
+
{entry.modelSwitch === "off" && <span class="tag">Off</span>}
|
|
864
|
+
</th>
|
|
865
|
+
<td class="muted num">{formatContextWindow(entry.contextWindow)}</td>
|
|
866
|
+
<td class="cell-switch">
|
|
867
|
+
<Switch
|
|
868
|
+
label=""
|
|
869
|
+
ariaLabel={`Serve ${entry.id} from ${provider.name}`}
|
|
870
|
+
checked={entry.modelSwitch === "on"}
|
|
871
|
+
onChange={(on) =>
|
|
872
|
+
change(() => api.setModelsEnabled([offeringKey(entry)], on), {
|
|
873
|
+
success: `${entry.id} turned ${on ? "on" : "off"}`,
|
|
874
|
+
failure: `Could not change ${entry.id}`,
|
|
875
|
+
})
|
|
876
|
+
}
|
|
877
|
+
/>
|
|
878
|
+
</td>
|
|
879
|
+
</tr>
|
|
880
|
+
))}
|
|
881
|
+
</tbody>
|
|
882
|
+
</table>
|
|
883
|
+
</div>
|
|
884
|
+
)}
|
|
885
|
+
</section>
|
|
886
|
+
</article>
|
|
887
|
+
);
|
|
888
|
+
}
|