agent-bridge-doubao 1.0.11 → 1.0.13
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.
|
@@ -6,17 +6,19 @@ exports.requestBody = requestBody;
|
|
|
6
6
|
const node_crypto_1 = require("node:crypto");
|
|
7
7
|
function doubaoStreamErrorMessage(data) {
|
|
8
8
|
let code = "";
|
|
9
|
-
let
|
|
9
|
+
let message = "";
|
|
10
10
|
try {
|
|
11
11
|
const value = JSON.parse(data);
|
|
12
|
-
code = String(value.code ?? value.error?.code ?? "");
|
|
13
|
-
|
|
12
|
+
code = String(value.error_code ?? value.code ?? value.error?.error_code ?? value.error?.code ?? "");
|
|
13
|
+
message = String(value.error_msg ?? value.message ?? value.error?.message ?? "").trim();
|
|
14
14
|
}
|
|
15
15
|
catch { /* 平台可能返回非 JSON 错误 */ }
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
if (message.length > 300)
|
|
17
|
+
message = message.slice(0, 300);
|
|
18
|
+
message = message.replace(/[\r\n\t]+/g, " ");
|
|
19
|
+
if (message)
|
|
20
|
+
return `豆包平台返回错误${code ? `(错误码 ${code})` : ""}:${message}`;
|
|
21
|
+
return `豆包平台返回流式错误${code ? `(错误码 ${code})` : ""}`;
|
|
20
22
|
}
|
|
21
23
|
const defaults = { port: Number(process.env.DOUBAO_CDP_PORT ?? "9227"), conversationId: process.env.DOUBAO_CONVERSATION_ID ?? "759450172544514", botId: process.env.DOUBAO_BOT_ID ?? "7338286299411103781", timeoutMs: Number(process.env.DOUBAO_TIMEOUT_MS ?? "180000") };
|
|
22
24
|
function sleep(ms, signal) {
|
package/package.json
CHANGED