@ynhcj/xiaoyi-channel 0.0.58-next → 0.0.59-next
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/src/provider.js +7 -5
- package/package.json +1 -1
package/dist/src/provider.js
CHANGED
|
@@ -23,12 +23,13 @@ function isRetryableProviderError(message) {
|
|
|
23
23
|
return true;
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
/** Compute retry delay in ms for the given 1-based attempt. */
|
|
26
|
+
/** Compute retry delay in ms for the given 1-based attempt, with up to 10s jitter. */
|
|
27
27
|
function getRetryDelayMs(attempt) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const base = attempt <= RETRY_DELAYS_MS.length
|
|
29
|
+
? RETRY_DELAYS_MS[attempt - 1]
|
|
30
|
+
: RETRY_DELAYS_MS[RETRY_DELAYS_MS.length - 1];
|
|
31
|
+
const jitter = Math.floor(Math.random() * 10_000);
|
|
32
|
+
return base + jitter;
|
|
32
33
|
}
|
|
33
34
|
function sleep(ms) {
|
|
34
35
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -206,6 +207,7 @@ export const xiaoyiProvider = {
|
|
|
206
207
|
// Wait for the stream to settle (done or error) to inspect the result.
|
|
207
208
|
// stream.result() resolves to the final AssistantMessage (even on error).
|
|
208
209
|
const result = await stream.result();
|
|
210
|
+
console.log("[provider] stream result:", result);
|
|
209
211
|
// Check if this is a retryable error
|
|
210
212
|
if (result.stopReason === "error" && isRetryableProviderError(result.errorMessage)) {
|
|
211
213
|
const delayMs = getRetryDelayMs(attempt);
|