retry
Browse files- package-lock.json +59 -1
- package.json +3 -1
- src/lib/components/PicletGenerator/PicletGenerator.svelte +7 -6
- src/lib/utils/qwenTimeout.ts +20 -0
package-lock.json
CHANGED
@@ -9,7 +9,9 @@
|
|
9 |
"version": "0.0.0",
|
10 |
"dependencies": {
|
11 |
"@imgly/background-removal": "^1.7.0",
|
12 |
-
"dexie": "^4.0.11"
|
|
|
|
|
13 |
},
|
14 |
"devDependencies": {
|
15 |
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
@@ -1168,6 +1170,12 @@
|
|
1168 |
"undici-types": "~7.8.0"
|
1169 |
}
|
1170 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
1171 |
"node_modules/@types/statuses": {
|
1172 |
"version": "2.0.6",
|
1173 |
"resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.6.tgz",
|
@@ -1892,6 +1900,18 @@
|
|
1892 |
"node": ">=8"
|
1893 |
}
|
1894 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1895 |
"node_modules/is-node-process": {
|
1896 |
"version": "1.2.0",
|
1897 |
"resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz",
|
@@ -2111,6 +2131,35 @@
|
|
2111 |
"optional": true,
|
2112 |
"peer": true
|
2113 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2114 |
"node_modules/path-to-regexp": {
|
2115 |
"version": "6.3.0",
|
2116 |
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
|
@@ -2289,6 +2338,15 @@
|
|
2289 |
"optional": true,
|
2290 |
"peer": true
|
2291 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2292 |
"node_modules/rollup": {
|
2293 |
"version": "4.45.1",
|
2294 |
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.45.1.tgz",
|
|
|
9 |
"version": "0.0.0",
|
10 |
"dependencies": {
|
11 |
"@imgly/background-removal": "^1.7.0",
|
12 |
+
"dexie": "^4.0.11",
|
13 |
+
"p-retry": "^6.2.1",
|
14 |
+
"p-timeout": "^6.1.4"
|
15 |
},
|
16 |
"devDependencies": {
|
17 |
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
|
1170 |
"undici-types": "~7.8.0"
|
1171 |
}
|
1172 |
},
|
1173 |
+
"node_modules/@types/retry": {
|
1174 |
+
"version": "0.12.2",
|
1175 |
+
"resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.2.tgz",
|
1176 |
+
"integrity": "sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow==",
|
1177 |
+
"license": "MIT"
|
1178 |
+
},
|
1179 |
"node_modules/@types/statuses": {
|
1180 |
"version": "2.0.6",
|
1181 |
"resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.6.tgz",
|
|
|
1900 |
"node": ">=8"
|
1901 |
}
|
1902 |
},
|
1903 |
+
"node_modules/is-network-error": {
|
1904 |
+
"version": "1.1.0",
|
1905 |
+
"resolved": "https://registry.npmjs.org/is-network-error/-/is-network-error-1.1.0.tgz",
|
1906 |
+
"integrity": "sha512-tUdRRAnhT+OtCZR/LxZelH/C7QtjtFrTu5tXCA8pl55eTUElUHT+GPYV8MBMBvea/j+NxQqVt3LbWMRir7Gx9g==",
|
1907 |
+
"license": "MIT",
|
1908 |
+
"engines": {
|
1909 |
+
"node": ">=16"
|
1910 |
+
},
|
1911 |
+
"funding": {
|
1912 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
1913 |
+
}
|
1914 |
+
},
|
1915 |
"node_modules/is-node-process": {
|
1916 |
"version": "1.2.0",
|
1917 |
"resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz",
|
|
|
2131 |
"optional": true,
|
2132 |
"peer": true
|
2133 |
},
|
2134 |
+
"node_modules/p-retry": {
|
2135 |
+
"version": "6.2.1",
|
2136 |
+
"resolved": "https://registry.npmjs.org/p-retry/-/p-retry-6.2.1.tgz",
|
2137 |
+
"integrity": "sha512-hEt02O4hUct5wtwg4H4KcWgDdm+l1bOaEy/hWzd8xtXB9BqxTWBBhb+2ImAtH4Cv4rPjV76xN3Zumqk3k3AhhQ==",
|
2138 |
+
"license": "MIT",
|
2139 |
+
"dependencies": {
|
2140 |
+
"@types/retry": "0.12.2",
|
2141 |
+
"is-network-error": "^1.0.0",
|
2142 |
+
"retry": "^0.13.1"
|
2143 |
+
},
|
2144 |
+
"engines": {
|
2145 |
+
"node": ">=16.17"
|
2146 |
+
},
|
2147 |
+
"funding": {
|
2148 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
2149 |
+
}
|
2150 |
+
},
|
2151 |
+
"node_modules/p-timeout": {
|
2152 |
+
"version": "6.1.4",
|
2153 |
+
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-6.1.4.tgz",
|
2154 |
+
"integrity": "sha512-MyIV3ZA/PmyBN/ud8vV9XzwTrNtR4jFrObymZYnZqMmW0zA8Z17vnT0rBgFE/TlohB+YCHqXMgZzb3Csp49vqg==",
|
2155 |
+
"license": "MIT",
|
2156 |
+
"engines": {
|
2157 |
+
"node": ">=14.16"
|
2158 |
+
},
|
2159 |
+
"funding": {
|
2160 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
2161 |
+
}
|
2162 |
+
},
|
2163 |
"node_modules/path-to-regexp": {
|
2164 |
"version": "6.3.0",
|
2165 |
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
|
|
|
2338 |
"optional": true,
|
2339 |
"peer": true
|
2340 |
},
|
2341 |
+
"node_modules/retry": {
|
2342 |
+
"version": "0.13.1",
|
2343 |
+
"resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz",
|
2344 |
+
"integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==",
|
2345 |
+
"license": "MIT",
|
2346 |
+
"engines": {
|
2347 |
+
"node": ">= 4"
|
2348 |
+
}
|
2349 |
+
},
|
2350 |
"node_modules/rollup": {
|
2351 |
"version": "4.45.1",
|
2352 |
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.45.1.tgz",
|
package.json
CHANGED
@@ -26,6 +26,8 @@
|
|
26 |
},
|
27 |
"dependencies": {
|
28 |
"@imgly/background-removal": "^1.7.0",
|
29 |
-
"dexie": "^4.0.11"
|
|
|
|
|
30 |
}
|
31 |
}
|
|
|
26 |
},
|
27 |
"dependencies": {
|
28 |
"@imgly/background-removal": "^1.7.0",
|
29 |
+
"dexie": "^4.0.11",
|
30 |
+
"p-retry": "^6.2.1",
|
31 |
+
"p-timeout": "^6.1.4"
|
32 |
}
|
33 |
}
|
src/lib/components/PicletGenerator/PicletGenerator.svelte
CHANGED
@@ -10,6 +10,7 @@
|
|
10 |
import { savePicletInstance, generatedDataToPicletInstance } from '$lib/db/piclets';
|
11 |
import { PicletType, TYPE_DATA } from '$lib/types/picletTypes';
|
12 |
import { EncounterService } from '$lib/db/encounterService';
|
|
|
13 |
|
14 |
interface Props extends PicletGeneratorProps {
|
15 |
// Trainer mode props
|
@@ -311,12 +312,12 @@ Format your response exactly as follows:
|
|
311 |
console.log('Generating monster concept with qwen3...');
|
312 |
|
313 |
// Call the add_message function (fn_index 13)
|
314 |
-
const output = await qwenClient.predict(13, [
|
315 |
conceptPrompt, // input_value
|
316 |
defaultSettings, // settings_form_value
|
317 |
thinkingBtnState, // thinking_btn_state_value
|
318 |
defaultState // state_value
|
319 |
-
]);
|
320 |
|
321 |
console.log('Qwen3 concept response:', output);
|
322 |
|
@@ -408,12 +409,12 @@ Create a concise visual description (1-3 sentences, max 100 words). Focus only o
|
|
408 |
console.log('Generating image prompt with qwen3...');
|
409 |
|
410 |
// Call the add_message function (fn_index 13)
|
411 |
-
const output = await qwenClient.predict(13, [
|
412 |
imagePromptPrompt, // input_value
|
413 |
defaultSettings, // settings_form_value
|
414 |
thinkingBtnState, // thinking_btn_state_value
|
415 |
defaultState // state_value
|
416 |
-
]);
|
417 |
|
418 |
console.log('Qwen3 image prompt response:', output);
|
419 |
|
@@ -770,12 +771,12 @@ Write your response within \`\`\`json\`\`\``;
|
|
770 |
};
|
771 |
|
772 |
// Call the add_message function (fn_index 13)
|
773 |
-
const output = await qwenClient.predict(13, [
|
774 |
statsPrompt, // input_value
|
775 |
defaultSettings, // settings_form_value
|
776 |
thinkingBtnState, // thinking_btn_state_value
|
777 |
defaultState // state_value
|
778 |
-
]);
|
779 |
|
780 |
console.log('Qwen3 stats response:', output);
|
781 |
|
|
|
10 |
import { savePicletInstance, generatedDataToPicletInstance } from '$lib/db/piclets';
|
11 |
import { PicletType, TYPE_DATA } from '$lib/types/picletTypes';
|
12 |
import { EncounterService } from '$lib/db/encounterService';
|
13 |
+
import { withQwenTimeout } from '$lib/utils/qwenTimeout';
|
14 |
|
15 |
interface Props extends PicletGeneratorProps {
|
16 |
// Trainer mode props
|
|
|
312 |
console.log('Generating monster concept with qwen3...');
|
313 |
|
314 |
// Call the add_message function (fn_index 13)
|
315 |
+
const output = await withQwenTimeout(() => qwenClient.predict(13, [
|
316 |
conceptPrompt, // input_value
|
317 |
defaultSettings, // settings_form_value
|
318 |
thinkingBtnState, // thinking_btn_state_value
|
319 |
defaultState // state_value
|
320 |
+
]));
|
321 |
|
322 |
console.log('Qwen3 concept response:', output);
|
323 |
|
|
|
409 |
console.log('Generating image prompt with qwen3...');
|
410 |
|
411 |
// Call the add_message function (fn_index 13)
|
412 |
+
const output = await withQwenTimeout(() => qwenClient.predict(13, [
|
413 |
imagePromptPrompt, // input_value
|
414 |
defaultSettings, // settings_form_value
|
415 |
thinkingBtnState, // thinking_btn_state_value
|
416 |
defaultState // state_value
|
417 |
+
]));
|
418 |
|
419 |
console.log('Qwen3 image prompt response:', output);
|
420 |
|
|
|
771 |
};
|
772 |
|
773 |
// Call the add_message function (fn_index 13)
|
774 |
+
const output = await withQwenTimeout(() => qwenClient.predict(13, [
|
775 |
statsPrompt, // input_value
|
776 |
defaultSettings, // settings_form_value
|
777 |
thinkingBtnState, // thinking_btn_state_value
|
778 |
defaultState // state_value
|
779 |
+
]));
|
780 |
|
781 |
console.log('Qwen3 stats response:', output);
|
782 |
|
src/lib/utils/qwenTimeout.ts
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pRetry, { AbortError } from 'p-retry';
|
2 |
+
import pTimeout from 'p-timeout';
|
3 |
+
|
4 |
+
export async function withQwenTimeout<T>(
|
5 |
+
fn: () => Promise<T>,
|
6 |
+
{ totalTimeout = 180_000, retries = 2 } = {}
|
7 |
+
): Promise<T> {
|
8 |
+
return pRetry(
|
9 |
+
() => pTimeout(fn(), { milliseconds: totalTimeout }),
|
10 |
+
{
|
11 |
+
retries,
|
12 |
+
onFailedAttempt: (error) => {
|
13 |
+
console.error(`qwen3 attempt #${error.attemptNumber} failed: ${error.message}`);
|
14 |
+
if (error.retriesLeft === 0) {
|
15 |
+
console.error('qwen3 max retries reached, giving up');
|
16 |
+
}
|
17 |
+
}
|
18 |
+
}
|
19 |
+
);
|
20 |
+
}
|