Update main.js
Browse files- static/js/main.js +9 -14
static/js/main.js
CHANGED
|
@@ -361,26 +361,21 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
| 361 |
}
|
| 362 |
}
|
| 363 |
|
| 364 |
-
// *** تغییر
|
| 365 |
-
//
|
| 366 |
-
//
|
| 367 |
|
| 368 |
const response = await api.getChatStream(historyForApi, state.globalAbortController.signal);
|
| 369 |
await api.readStreamAndDisplay(response, modelBubbleOuterDiv);
|
| 370 |
|
| 371 |
-
|
| 372 |
} catch (error) {
|
| 373 |
if (error.name !== 'AbortError') {
|
| 374 |
-
console.error("
|
| 375 |
-
// اگر
|
| 376 |
-
//
|
| 377 |
if (modelBubbleOuterDiv) {
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
// اگر هنوز محتوایی تولید نشده بود، این متن را بگذار
|
| 381 |
-
if(contentArea.innerText.trim() === '') {
|
| 382 |
-
contentArea.innerHTML = '<p class="text-xs text-slate-400 mt-2 text-center p-4">...</p>';
|
| 383 |
-
}
|
| 384 |
}
|
| 385 |
} else {
|
| 386 |
if (modelBubbleOuterDiv && !modelBubbleOuterDiv.querySelector('.message-content')?.innerText.includes('متوقف شد')) {
|
|
@@ -473,7 +468,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
| 473 |
|
| 474 |
const response = await api.getChatStream(historyForApi, state.globalAbortController.signal);
|
| 475 |
await api.readStreamAndDisplay(response, newModelBubble);
|
| 476 |
-
|
| 477 |
} catch(error) {
|
| 478 |
if (error.name !== 'AbortError') console.error("Regeneration failed:", error);
|
| 479 |
} finally {
|
|
|
|
| 361 |
}
|
| 362 |
}
|
| 363 |
|
| 364 |
+
// *** تغییر مهم: حذف منطق Retry کلاینت و تایماوت کوتاه ***
|
| 365 |
+
// ما فقط یک درخواست میزنیم و صبر میکنیم. بکاند خودش چرخش کلید را انجام میدهد.
|
| 366 |
+
// به این ترتیب خطای "Server did not respond" که ناشی از عجله کلاینت بود حذف میشود.
|
| 367 |
|
| 368 |
const response = await api.getChatStream(historyForApi, state.globalAbortController.signal);
|
| 369 |
await api.readStreamAndDisplay(response, modelBubbleOuterDiv);
|
| 370 |
|
|
|
|
| 371 |
} catch (error) {
|
| 372 |
if (error.name !== 'AbortError') {
|
| 373 |
+
console.error("خطا در هنگام تولید پیام:", error);
|
| 374 |
+
// اگر خطای واقعی رخ داد، فقط در کنسول لاگ میکنیم و به کاربر چیزی نشان نمیدهیم یا یک متن عمومی
|
| 375 |
+
// طبق خواسته شما که گفتید خطا نشان داده نشود.
|
| 376 |
if (modelBubbleOuterDiv) {
|
| 377 |
+
// اینجا میتوانیم هیچ کاری نکنیم یا یک متن خالی بگذاریم
|
| 378 |
+
// اما برای جلوگیری از گیر کردن، وضعیت را ریست میکنیم
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
} else {
|
| 381 |
if (modelBubbleOuterDiv && !modelBubbleOuterDiv.querySelector('.message-content')?.innerText.includes('متوقف شد')) {
|
|
|
|
| 468 |
|
| 469 |
const response = await api.getChatStream(historyForApi, state.globalAbortController.signal);
|
| 470 |
await api.readStreamAndDisplay(response, newModelBubble);
|
| 471 |
+
|
| 472 |
} catch(error) {
|
| 473 |
if (error.name !== 'AbortError') console.error("Regeneration failed:", error);
|
| 474 |
} finally {
|