@x1a0f3n9/dsh-llm 0.1.5-rc.2 → 0.1.5-rc.3
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/lib/index.js +7 -1
- package/lib/types/error.js +11 -1
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -155,6 +155,12 @@ const STRUCTURED_CONTEXT_OVERFLOW = new RegExp(String.raw`(?:^|[^a-z0-9])context
|
|
|
155
155
|
const TOO_LARGE_FOR_CONTEXT = new RegExp(String.raw`\b(?:request|prompt|input|messages?)\s+(?:is\s+|are\s+)?` + String.raw`too\s+(?:large|long)\s+for\s+(?:(?:this|the)\s+)?` + String.raw`(?:model(?:'s)?\s+)?context(?:\s+window)?\b`, "i");
|
|
156
156
|
/** "Exceeds" wording is safe only when its object is explicitly the model context. */
|
|
157
157
|
const EXCEEDS_MODEL_CONTEXT = new RegExp(String.raw`\b(?:input|prompt|request|messages?)\b.{0,40}` + String.raw`\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}` + String.raw`\b(?:the\s+)?(?:model(?:'s)?\s+)?context(?:\s+(?:length|window))?\b`, "i");
|
|
158
|
+
/** xAI Grok and similar OpenAI-compatible gateways name the bound as prompt length. */
|
|
159
|
+
const MAXIMUM_PROMPT_LENGTH = /\bmaximum prompt length\b|\bprompt is too long\b/i;
|
|
160
|
+
/** Groq and similar gateways ask the caller to shorten the message list. */
|
|
161
|
+
const REDUCE_MESSAGE_LENGTH = /\breduce the length of the messages\b/i;
|
|
162
|
+
/** Chinese OpenAI-compatible gateways often return localized overflow copy. */
|
|
163
|
+
const CHINESE_CONTEXT_OVERFLOW = /上下文(?:窗口|长度)|(?:提示词|输入|请求).{0,8}过长/;
|
|
158
164
|
/**
|
|
159
165
|
* Recognize the context-overflow wording used by OpenAI-compatible providers
|
|
160
166
|
* and library adapters. Adapters pass all available provider code, type, and
|
|
@@ -163,7 +169,7 @@ const EXCEEDS_MODEL_CONTEXT = new RegExp(String.raw`\b(?:input|prompt|request|me
|
|
|
163
169
|
* @returns true when the detail identifies a request exceeding the model context window.
|
|
164
170
|
*/
|
|
165
171
|
function isContextWindowExceededError(detail) {
|
|
166
|
-
return STRUCTURED_CONTEXT_OVERFLOW.test(detail) || /\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(detail) || TOO_LARGE_FOR_CONTEXT.test(detail) || /\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(detail) || EXCEEDS_MODEL_CONTEXT.test(detail);
|
|
172
|
+
return STRUCTURED_CONTEXT_OVERFLOW.test(detail) || /\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(detail) || TOO_LARGE_FOR_CONTEXT.test(detail) || /\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(detail) || /\btoo long for (?:this|the) model\b/i.test(detail) || EXCEEDS_MODEL_CONTEXT.test(detail) || MAXIMUM_PROMPT_LENGTH.test(detail) || REDUCE_MESSAGE_LENGTH.test(detail) || CHINESE_CONTEXT_OVERFLOW.test(detail);
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
175
|
* Recognize provider wording that identifies an exhausted account quota rather
|
package/lib/types/error.js
CHANGED
|
@@ -51,6 +51,12 @@ const TOO_LARGE_FOR_CONTEXT = new RegExp(String.raw `\b(?:request|prompt|input|m
|
|
|
51
51
|
const EXCEEDS_MODEL_CONTEXT = new RegExp(String.raw `\b(?:input|prompt|request|messages?)\b.{0,40}`
|
|
52
52
|
+ String.raw `\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}`
|
|
53
53
|
+ String.raw `\b(?:the\s+)?(?:model(?:'s)?\s+)?context(?:\s+(?:length|window))?\b`, 'i');
|
|
54
|
+
/** xAI Grok and similar OpenAI-compatible gateways name the bound as prompt length. */
|
|
55
|
+
const MAXIMUM_PROMPT_LENGTH = /\bmaximum prompt length\b|\bprompt is too long\b/i;
|
|
56
|
+
/** Groq and similar gateways ask the caller to shorten the message list. */
|
|
57
|
+
const REDUCE_MESSAGE_LENGTH = /\breduce the length of the messages\b/i;
|
|
58
|
+
/** Chinese OpenAI-compatible gateways often return localized overflow copy. */
|
|
59
|
+
const CHINESE_CONTEXT_OVERFLOW = /上下文(?:窗口|长度)|(?:提示词|输入|请求).{0,8}过长/;
|
|
54
60
|
/**
|
|
55
61
|
* Recognize the context-overflow wording used by OpenAI-compatible providers
|
|
56
62
|
* and library adapters. Adapters pass all available provider code, type, and
|
|
@@ -63,7 +69,11 @@ export function isContextWindowExceededError(detail) {
|
|
|
63
69
|
|| /\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(detail)
|
|
64
70
|
|| TOO_LARGE_FOR_CONTEXT.test(detail)
|
|
65
71
|
|| /\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(detail)
|
|
66
|
-
||
|
|
72
|
+
|| /\btoo long for (?:this|the) model\b/i.test(detail)
|
|
73
|
+
|| EXCEEDS_MODEL_CONTEXT.test(detail)
|
|
74
|
+
|| MAXIMUM_PROMPT_LENGTH.test(detail)
|
|
75
|
+
|| REDUCE_MESSAGE_LENGTH.test(detail)
|
|
76
|
+
|| CHINESE_CONTEXT_OVERFLOW.test(detail);
|
|
67
77
|
}
|
|
68
78
|
/**
|
|
69
79
|
* Recognize provider wording that identifies an exhausted account quota rather
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x1a0f3n9/dsh-llm",
|
|
3
3
|
"description": "Provider-neutral LLM service interface for the DeepSeek Harness",
|
|
4
|
-
"version": "0.1.5-rc.
|
|
4
|
+
"version": "0.1.5-rc.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"zod": "^4.4.3",
|
|
68
|
-
"@x1a0f3n9/dsh-util-crypto": "^0.1.5-rc.
|
|
68
|
+
"@x1a0f3n9/dsh-util-crypto": "^0.1.5-rc.3",
|
|
69
69
|
"@deepseek-ai/schemastery": "^3.18.2",
|
|
70
|
-
"@x1a0f3n9/dsh-timeout": "^0.1.5-rc.
|
|
71
|
-
"@x1a0f3n9/dsh-brand": "^0.1.5-rc.
|
|
72
|
-
"@x1a0f3n9/dsh-util-values": "^0.1.5-rc.
|
|
73
|
-
"@x1a0f3n9/dsh-typert-protocol": "^0.1.5-rc.
|
|
70
|
+
"@x1a0f3n9/dsh-timeout": "^0.1.5-rc.3",
|
|
71
|
+
"@x1a0f3n9/dsh-brand": "^0.1.5-rc.3",
|
|
72
|
+
"@x1a0f3n9/dsh-util-values": "^0.1.5-rc.3",
|
|
73
|
+
"@x1a0f3n9/dsh-typert-protocol": "^0.1.5-rc.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@x1a0f3n9/dsh-attachment": "^0.1.5-rc.
|
|
77
|
-
"@x1a0f3n9/dsh-invariants": "^0.1.5-rc.
|
|
76
|
+
"@x1a0f3n9/dsh-attachment": "^0.1.5-rc.3",
|
|
77
|
+
"@x1a0f3n9/dsh-invariants": "^0.1.5-rc.3",
|
|
78
78
|
"@deepseek-ai/cordis": "^4.0.2"
|
|
79
79
|
}
|
|
80
80
|
}
|