- Cap maximum cooldown for rate limit handling in account unavailability and single-model chat flows
- Dynamic custom model fetching for model selection
This commit is contained in:
parent
c42c0146ab
commit
cca615eaff
19 changed files with 108 additions and 60 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { getComboById, updateCombo, deleteCombo, getComboByName } from "@/lib/localDb";
|
||||
import { resetComboRotation } from "open-sse/services/combo.js";
|
||||
|
||||
// Validate combo name: only a-z, A-Z, 0-9, -, _
|
||||
const VALID_NAME_REGEX = /^[a-zA-Z0-9_.\-]+$/;
|
||||
|
|
@ -40,12 +41,18 @@ export async function PUT(request, { params }) {
|
|||
}
|
||||
}
|
||||
|
||||
// Capture previous name to invalidate rotation state on rename
|
||||
const prev = await getComboById(id);
|
||||
const combo = await updateCombo(id, body);
|
||||
|
||||
if (!combo) {
|
||||
return NextResponse.json({ error: "Combo not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
// Invalidate rotation state (models/strategy/name may have changed)
|
||||
if (prev?.name) resetComboRotation(prev.name);
|
||||
if (combo.name && combo.name !== prev?.name) resetComboRotation(combo.name);
|
||||
|
||||
return NextResponse.json(combo);
|
||||
} catch (error) {
|
||||
console.log("Error updating combo:", error);
|
||||
|
|
@ -57,11 +64,14 @@ export async function PUT(request, { params }) {
|
|||
export async function DELETE(request, { params }) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const prev = await getComboById(id);
|
||||
const success = await deleteCombo(id);
|
||||
|
||||
if (!success) {
|
||||
return NextResponse.json({ error: "Combo not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
if (prev?.name) resetComboRotation(prev.name);
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue