update db fix

This commit is contained in:
nikolay
2026-05-06 16:42:03 +03:00
parent 0f2ea42ee6
commit 1a78de96b9
3 changed files with 18 additions and 2 deletions
BIN
View File
Binary file not shown.
+14 -2
View File
@@ -965,8 +965,20 @@
if (oldest && oldest.id) url += `&before_id=${encodeURIComponent(oldest.id)}`;
}
const r = await fetch(url);
const data = await r.json().catch(() => ({}));
if (!r.ok || !data.ok) throw new Error(data.error || "chat load failed");
const raw = await r.text().catch(() => "");
let data = {};
try {
data = raw ? JSON.parse(raw) : {};
} catch {
data = {};
}
if (!r.ok || !data.ok) {
const details =
(data && data.error) ||
(raw && raw.trim() ? raw.trim().slice(0, 300) : "") ||
`${r.status} ${r.statusText}`.trim();
throw new Error(details || "chat load failed");
}
const pageDesc = data.items || [];
const pageChrono = pageDesc.slice().reverse(); // newest->oldest => oldest->newest
+4
View File
@@ -224,6 +224,8 @@ def _required_str(payload: Dict[str, Any], key: str) -> Tuple[Optional[str], Opt
app = Flask(__name__, static_folder=".", static_url_path="")
# Accept both `/path` and `/path/` to be resilient behind proxies/CDNs.
app.url_map.strict_slashes = False
def _db_connect() -> sqlite3.Connection:
@@ -510,6 +512,7 @@ def discover_models(provider: str) -> list:
@app.get("/api/chat")
@app.get("/api/chat/")
def api_chat_list() -> Any:
provider = request.args.get("provider", "").strip()
if not provider:
@@ -580,6 +583,7 @@ def api_chat_list() -> Any:
@app.post("/api/chat/clear")
@app.post("/api/chat/clear/")
def api_chat_clear() -> Any:
payload = request.get_json(silent=True) or {}
provider, err = _required_str(payload, "provider")