@bd7pil/reeve 0.1.7 → 0.1.8
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/provision.json +2 -2
- package/src/gate/classify.js +15 -11
package/package.json
CHANGED
package/provision.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"name": "reeve",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"//": "REEVE 在 ocrc 实例里的装配说明。**没有二进制工件** —— 代理层是插件内的 GATE(纯 JS),不需要任何本地服务(Bifrost 时代已结束)。",
|
|
7
7
|
"host": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"enginePlugin": {
|
|
18
|
-
"spec": "@bd7pil/reeve@0.1.
|
|
18
|
+
"spec": "@bd7pil/reeve@0.1.8",
|
|
19
19
|
"kind": "package",
|
|
20
20
|
"entry": "~/.ocrc/components/reeve/node_modules/@bd7pil/reeve",
|
|
21
21
|
"requiresPeer": []
|
package/src/gate/classify.js
CHANGED
|
@@ -10,17 +10,21 @@
|
|
|
10
10
|
// 只做判断,不做 IO——纯函数,测试逐条钉。
|
|
11
11
|
|
|
12
12
|
const NEVER = [/abort/i, /context[\s_-]{0,12}overflow/i, /context\s+length/i, /too\s+many\s+tokens/i, /上下文.{0,6}超/i, /超出.{0,8}上[下]文/i]
|
|
13
|
+
// `[正则, reason]` 成对:以前用"下标 → reason"的平行数组,插入一条就整段错位(中文模型不存在被判成 always:key)。
|
|
13
14
|
const ALWAYS = [
|
|
14
|
-
/quota[\s_-]*exceeded/i,
|
|
15
|
-
/resource[\s_-]*exhausted/i,
|
|
16
|
-
/out\s+of\s+credits/i,
|
|
17
|
-
/payment\s+required/i,
|
|
18
|
-
/insufficient[\s_-]*(quota|credits?|balance)/i,
|
|
19
|
-
/使用上限|额度不足|余额不足|已耗尽|达到.{0,6}限制/i,
|
|
20
|
-
/model[^\n]{0,24}not[^\n]{0,12}(found|supported)/i,
|
|
21
|
-
|
|
22
|
-
/
|
|
23
|
-
/
|
|
15
|
+
[/quota[\s_-]*exceeded/i, 'always:quota'],
|
|
16
|
+
[/resource[\s_-]*exhausted/i, 'always:quota'],
|
|
17
|
+
[/out\s+of\s+credits/i, 'always:quota'],
|
|
18
|
+
[/payment\s+required/i, 'always:quota'],
|
|
19
|
+
[/insufficient[\s_-]*(quota|credits?|balance)/i, 'always:quota'],
|
|
20
|
+
[/使用上限|额度不足|余额不足|已耗尽|达到.{0,6}限制/i, 'always:quota'],
|
|
21
|
+
[/model[^\n]{0,24}not[^\n]{0,12}(found|supported)/i, 'always:model'],
|
|
22
|
+
// zen 对未知模型返回 400 + "Upstream request failed: Model is unavailable." / "does not exist"
|
|
23
|
+
[/model[^\n]{0,24}unavailable/i, 'always:model'],
|
|
24
|
+
[/model[^\n]{0,40}(does\s+not\s+exist|not\s+exist|unknown|invalid)/i, 'always:model'],
|
|
25
|
+
[/模型.{0,6}(不存在|不支持)/i, 'always:model'],
|
|
26
|
+
[/missing[\s_-]*api[\s_-]*key/i, 'always:key'],
|
|
27
|
+
[/api[\s_-]*key[^\n]{0,16}(missing|not\s+set|required)/i, 'always:key'],
|
|
24
28
|
]
|
|
25
29
|
const TEXT_HINTS = [
|
|
26
30
|
/rate[\s_-]*limit/i,
|
|
@@ -54,7 +58,7 @@ export function statusOf({ status, text, error, policy } = {}) {
|
|
|
54
58
|
export function classifyFailure({ status, text, error, headers, policy } = {}) {
|
|
55
59
|
const hay = `${asString(text)} ${asString(error?.message)} ${asString(error?.name)} ${asString(error?.error?.message)}`
|
|
56
60
|
for (const re of NEVER) if (re.test(hay)) return { retryable: false, reason: re === NEVER[0] ? 'never:abort' : 'never:context', status: statusOf({ status, text, error, policy }) }
|
|
57
|
-
for (const [
|
|
61
|
+
for (const [re, reason] of ALWAYS) if (re.test(hay)) return { retryable: true, reason, status: statusOf({ status, text, error, policy }) }
|
|
58
62
|
|
|
59
63
|
const code = statusOf({ status, text, error, policy })
|
|
60
64
|
const list = policy?.retry_on_errors ?? []
|