@zhongqian97-code/ecode 0.5.24 → 0.5.25
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/dist/index.js +21 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5744,7 +5744,11 @@ function generateAdminHtml(version2) {
|
|
|
5744
5744
|
async function apiFetch(path, opts = {}) {
|
|
5745
5745
|
const url = apiUrl(path);
|
|
5746
5746
|
const res = await fetch(url, opts);
|
|
5747
|
-
if (!res.ok)
|
|
5747
|
+
if (!res.ok) {
|
|
5748
|
+
let msg = res.status + ' ' + res.statusText;
|
|
5749
|
+
try { const err = await res.json(); if (err.error) msg = err.error; } catch {}
|
|
5750
|
+
throw new Error(msg);
|
|
5751
|
+
}
|
|
5748
5752
|
return res.json();
|
|
5749
5753
|
}
|
|
5750
5754
|
|
|
@@ -6010,8 +6014,7 @@ function generateAdminHtml(version2) {
|
|
|
6010
6014
|
} else if (type === 'session.error') {
|
|
6011
6015
|
finalizeStreamingMsg();
|
|
6012
6016
|
setStatus('idle');
|
|
6013
|
-
|
|
6014
|
-
'\u9519\u8BEF: ' + escHtml(msg.error || 'unknown error');
|
|
6017
|
+
showToast('\u9519\u8BEF: ' + (msg.error || 'unknown error'), 'error');
|
|
6015
6018
|
}
|
|
6016
6019
|
}
|
|
6017
6020
|
|
|
@@ -6047,7 +6050,7 @@ function generateAdminHtml(version2) {
|
|
|
6047
6050
|
body: JSON.stringify({ requestId: pending.requestId || pending.id, approved }),
|
|
6048
6051
|
});
|
|
6049
6052
|
} catch (e) {
|
|
6050
|
-
|
|
6053
|
+
showToast('\u5BA1\u6279\u8BF7\u6C42\u5931\u8D25: ' + e.message, 'error');
|
|
6051
6054
|
}
|
|
6052
6055
|
}
|
|
6053
6056
|
|
|
@@ -6105,7 +6108,7 @@ function generateAdminHtml(version2) {
|
|
|
6105
6108
|
body: JSON.stringify({ message: text }),
|
|
6106
6109
|
});
|
|
6107
6110
|
} catch (e) {
|
|
6108
|
-
|
|
6111
|
+
showToast('\u53D1\u9001\u5931\u8D25: ' + e.message, 'error');
|
|
6109
6112
|
setStatus('idle');
|
|
6110
6113
|
}
|
|
6111
6114
|
}
|
|
@@ -6484,8 +6487,19 @@ async function chatRoutes(app, opts) {
|
|
|
6484
6487
|
if (typeof body.systemPrompt === "string") {
|
|
6485
6488
|
sessionOpts.systemPrompt = body.systemPrompt;
|
|
6486
6489
|
}
|
|
6487
|
-
|
|
6488
|
-
|
|
6490
|
+
if (!opts.config.apiKey) {
|
|
6491
|
+
return reply.code(400).send({
|
|
6492
|
+
success: false,
|
|
6493
|
+
error: "\u672A\u914D\u7F6E API Key\uFF0C\u8BF7\u5148\u70B9\u51FB\u53F3\u4E0A\u89D2\u300C\u914D\u7F6E\u300D\u6309\u94AE\u586B\u5199"
|
|
6494
|
+
});
|
|
6495
|
+
}
|
|
6496
|
+
try {
|
|
6497
|
+
const runtime = await manager.createSession(sessionOpts);
|
|
6498
|
+
return reply.code(201).send({ success: true, session: runtime.snapshot() });
|
|
6499
|
+
} catch (err) {
|
|
6500
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
6501
|
+
return reply.code(500).send({ success: false, error: msg });
|
|
6502
|
+
}
|
|
6489
6503
|
});
|
|
6490
6504
|
app.post("/api/chat/sessions/:id/submit", async (request, reply) => {
|
|
6491
6505
|
const { id } = request.params;
|