@hraness/sponge 0.3.3 → 0.3.4
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.
|
@@ -116,7 +116,7 @@ async function complete(origin, request, model, messages, schema, o) {
|
|
|
116
116
|
});
|
|
117
117
|
if (!response.ok) {
|
|
118
118
|
await response.body?.cancel().catch(() => undefined);
|
|
119
|
-
throw new SpongeError('unavailable');
|
|
119
|
+
throw new SpongeError('model-unavailable', { detail: { status: response.status } });
|
|
120
120
|
}
|
|
121
121
|
let parsed;
|
|
122
122
|
try {
|
|
@@ -125,14 +125,14 @@ async function complete(origin, request, model, messages, schema, o) {
|
|
|
125
125
|
catch (error) {
|
|
126
126
|
if (error instanceof SpongeError)
|
|
127
127
|
throw error;
|
|
128
|
-
throw new SpongeError('unavailable');
|
|
128
|
+
throw new SpongeError('model-unavailable');
|
|
129
129
|
}
|
|
130
130
|
const choice = parsed?.choices?.[0];
|
|
131
131
|
if (choice?.finish_reason === 'length')
|
|
132
132
|
throw new SpongeError('limit-exceeded');
|
|
133
133
|
const content = choice?.message?.content;
|
|
134
134
|
if (typeof content !== 'string' || !content.trim())
|
|
135
|
-
throw new SpongeError('unavailable');
|
|
135
|
+
throw new SpongeError('model-unavailable');
|
|
136
136
|
if (Buffer.byteLength(content) > o.maxOutputBytes)
|
|
137
137
|
throw new SpongeError('limit-exceeded');
|
|
138
138
|
return content;
|
|
@@ -486,7 +486,7 @@ export async function draftDigest(input) {
|
|
|
486
486
|
throw new SpongeError('limit-exceeded');
|
|
487
487
|
if (error instanceof SpongeError)
|
|
488
488
|
throw error;
|
|
489
|
-
throw new SpongeError('unavailable');
|
|
489
|
+
throw new SpongeError('model-unavailable', { cause: error });
|
|
490
490
|
}
|
|
491
491
|
if (userSignal.aborted)
|
|
492
492
|
throw new SpongeError('cancelled');
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare const parents: {
|
|
|
17
17
|
readonly malformed: "invalid-input";
|
|
18
18
|
readonly 'no-capture': "invalid-input";
|
|
19
19
|
readonly 'draft-rejected': "unavailable";
|
|
20
|
+
readonly 'model-unavailable': "unavailable";
|
|
20
21
|
readonly 'parent-missing': "invalid-input";
|
|
21
22
|
readonly 'target-exists': "invalid-input";
|
|
22
23
|
};
|
package/dist/src/errors.js
CHANGED
|
@@ -31,6 +31,7 @@ const parents = {
|
|
|
31
31
|
malformed: 'invalid-input',
|
|
32
32
|
'no-capture': 'invalid-input',
|
|
33
33
|
'draft-rejected': 'unavailable',
|
|
34
|
+
'model-unavailable': 'unavailable',
|
|
34
35
|
'parent-missing': 'invalid-input',
|
|
35
36
|
'target-exists': 'invalid-input',
|
|
36
37
|
};
|
|
@@ -80,7 +81,8 @@ export const hints = {
|
|
|
80
81
|
};
|
|
81
82
|
/** Hints for detail codes whose public code's hint would mislead. Fixed text only, like `hints`. */
|
|
82
83
|
export const detailHints = {
|
|
83
|
-
'draft-rejected': 'The model draft failed the digest checks listed above, even after one repair.
|
|
84
|
+
'draft-rejected': 'The model draft failed the digest checks listed above, even after one repair. Drafting is deterministic, so the same capture and model fail again; refresh the item or use another model.',
|
|
85
|
+
'model-unavailable': 'The model server did not answer or returned an error. Check that it is still running and has free GPU memory (another loaded model can exhaust it), then retry.',
|
|
84
86
|
};
|
|
85
87
|
/** The one error type. `message` is the code, so bare `String(error)` never carries detail, paths or causes. */
|
|
86
88
|
export class SpongeError extends Error {
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
}
|
|
28
28
|
],
|
|
29
29
|
"build": {
|
|
30
|
-
"asrSourceSha256": "
|
|
30
|
+
"asrSourceSha256": "ca98fb111b0d2b26ca697a6c0d55d76f7d2b5b752bff8fc053ae19389d16a52c",
|
|
31
31
|
"clangVersion": "Apple clang version 21.0.0 (clang-2100.1.1.101)",
|
|
32
|
-
"embeddingSourceSha256": "
|
|
32
|
+
"embeddingSourceSha256": "af6d6c01934d64427f2a9cb36f83edaea372f6bf2e522166b9e86e3b15f72784",
|
|
33
33
|
"swiftVersion": "Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)"
|
|
34
34
|
},
|
|
35
35
|
"minimumMacOS": "26.0",
|
|
36
|
-
"packageVersion": "0.3.
|
|
36
|
+
"packageVersion": "0.3.4",
|
|
37
37
|
"platform": "darwin",
|
|
38
38
|
"schemaVersion": 1,
|
|
39
|
-
"sourceCommit": "
|
|
39
|
+
"sourceCommit": "4e42216e86da07224ec81512c2efa0a710e38500"
|
|
40
40
|
}
|