mioku-service-webui 4.6.1 → 4.7.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/package.json +1 -1
- package/routes/ai.ts +32 -0
package/package.json
CHANGED
package/routes/ai.ts
CHANGED
|
@@ -354,6 +354,38 @@ export function createAIRoutes() {
|
|
|
354
354
|
return c.json({ ok: true, data: api.getRoleBindings() });
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
+
app.get("/fallback", (c) => {
|
|
358
|
+
const api = getAIApi();
|
|
359
|
+
const chain = api?.getMainFallbackChain?.() ?? [];
|
|
360
|
+
return c.json({
|
|
361
|
+
ok: true,
|
|
362
|
+
data: {
|
|
363
|
+
fallback: chain,
|
|
364
|
+
liveFallback: chain,
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
app.put("/fallback", async (c) => {
|
|
370
|
+
const api = getAIApi();
|
|
371
|
+
if (!api?.setMainFallbackChain) {
|
|
372
|
+
return c.json({ ok: false, error: "AI_SERVICE_UNAVAILABLE" }, 503);
|
|
373
|
+
}
|
|
374
|
+
const body = await c.req.json();
|
|
375
|
+
const raw = Array.isArray(body?.fallback) ? body.fallback : [];
|
|
376
|
+
const fallback = Array.from(
|
|
377
|
+
new Set(
|
|
378
|
+
raw
|
|
379
|
+
.map((id: unknown) => String(id || "").trim())
|
|
380
|
+
.filter((id: string) => id.includes("/") && id.length > 1),
|
|
381
|
+
),
|
|
382
|
+
);
|
|
383
|
+
logger.info(`[webui-action] ai.fallback.update`, { count: fallback.length });
|
|
384
|
+
api.setMainFallbackChain(fallback);
|
|
385
|
+
const live = api.getMainFallbackChain?.() ?? fallback;
|
|
386
|
+
return c.json({ ok: true, data: { fallback: live, liveFallback: live } });
|
|
387
|
+
});
|
|
388
|
+
|
|
357
389
|
app.put("/roles", async (c) => {
|
|
358
390
|
const api = getAIApi();
|
|
359
391
|
if (!api?.setRoleBinding) {
|