Merge branch 'staging' into request-proxy
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | "cookie-session": "^2.1.0", |
| 23 | 23 | "cors": "^2.8.5", |
| 24 | 24 | "csrf-csrf": "^2.2.3", |
| 25 | 25 | "express": "^4.1920.20", |
| 26 | 26 | "form-data": "^4.0.0", |
| 27 | 27 | "google-translate-api-browser": "^3.0.1", |
| 28 | 28 | "he": "^1.2.0", |
| @@ -5394,36 +5394,6 @@ | ||
| 5394 | 5394 | "node": ">= 0.8.0" |
| 5395 | 5395 | } |
| 5396 | 5396 | }, |
| 5397 | - "node_modules/serve-static/node_modules/ms": { | |
| 5398 | - "version": "2.1.3", | |
| 5399 | - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", | |
| 5400 | - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", | |
| 5401 | - "license": "MIT" | |
| 5402 | - }, | |
| 5403 | - "node_modules/serve-static/node_modules/send": { | |
| 5404 | - "version": "0.18.0", | |
| 5405 | - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", | |
| 5406 | - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", | |
| 5407 | - "license": "MIT", | |
| 5408 | - "dependencies": { | |
| 5409 | - "debug": "2.6.9", | |
| 5410 | - "depd": "2.0.0", | |
| 5411 | - "destroy": "1.2.0", | |
| 5412 | - "encodeurl": "~1.0.2", | |
| 5413 | - "escape-html": "~1.0.3", | |
| 5414 | - "etag": "~1.8.1", | |
| 5415 | - "fresh": "0.5.2", | |
| 5416 | - "http-errors": "2.0.0", | |
| 5417 | - "mime": "1.6.0", | |
| 5418 | - "ms": "2.1.3", | |
| 5419 | - "on-finished": "2.4.1", | |
| 5420 | - "range-parser": "~1.2.1", | |
| 5421 | - "statuses": "2.0.1" | |
| 5422 | - }, | |
| 5423 | - "engines": { | |
| 5424 | - "node": ">= 0.8.0" | |
| 5425 | - } | |
| 5426 | - }, | |
| 5427 | 5397 | "node_modules/set-function-length": { |
| 5428 | 5398 | "version": "1.2.2", |
| 5429 | 5399 | "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", |
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | "cookie-session": "^2.1.0", |
| 13 | 13 | "cors": "^2.8.5", |
| 14 | 14 | "csrf-csrf": "^2.2.3", |
| 15 | 15 | "express": "^4.1920.20", |
| 16 | 16 | "form-data": "^4.0.0", |
| 17 | 17 | "google-translate-api-browser": "^3.0.1", |
| 18 | 18 | "he": "^1.2.0", |
| @@ -63,6 +63,9 @@ | ||
| 63 | 63 | }, |
| 64 | 64 | "node-fetch": { |
| 65 | 65 | "whatwg-url": "^14.0.0" |
| 66 | + }, | |
| 67 | + "express": { | |
| 68 | + "send": "^0.19.0" | |
| 66 | 69 | } |
| 67 | 70 | }, |
| 68 | 71 | "name": "sillytavern", |
| @@ -2533,22 +2533,23 @@ async function askCharacter(args, text) { | ||
| 2533 | 2533 | lastMessage.force_avatar = force_avatar; |
| 2534 | 2534 | lastMessage.original_avatar = original_avatar; |
| 2535 | 2535 | } |
| 2536 | - | |
| 2537 | - // Kill this callback once the event fires | |
| 2538 | - eventSource.removeListener(event_types.CHARACTER_MESSAGE_RENDERED, restoreCharacter); | |
| 2539 | 2536 | }; |
| 2540 | 2537 | |
| 2541 | 2538 | // Run generate and restore previous character on error |
| 2542 | 2539 | try { |
| 2543 | 2540 | toastr.info(`Asking ${character.name} something...`); |
| 2544 | 2541 | await Generate('ask_command'); |
| 2545 | - } catch { | |
| 2542 | + await saveChatConditional(); | |
| 2543 | + } catch (error) { | |
| 2544 | + console.error('Error running /ask command', error); | |
| 2545 | + } finally { | |
| 2546 | 2546 | restoreCharacter(); |
| 2547 | + | |
| 2548 | + if (this_chid !== prevChId) { | |
| 2549 | + toastr.error('It is strongly recommended to reload the page.', 'Something went wrong'); | |
| 2550 | + } | |
| 2547 | 2551 | } |
| 2548 | 2552 | |
| 2549 | - // Restore previous character once message renders | |
| 2550 | - // Hack for generate | |
| 2551 | - eventSource.on(event_types.CHARACTER_MESSAGE_RENDERED, restoreCharacter); | |
| 2552 | 2553 | return ''; |
| 2553 | 2554 | } |
| 2554 | 2555 | |