Jan2000 commited on
Commit
d909246
·
unverified ·
1 Parent(s): 289de8b

Update main.js

Browse files
Files changed (1) hide show
  1. static/js/main.js +9 -14
static/js/main.js CHANGED
@@ -361,26 +361,21 @@ document.addEventListener('DOMContentLoaded', async () => {
361
  }
362
  }
363
 
364
- // *** تغییر اصلی: حذف محدودیت زمانی کلاینت ***
365
- // دیگر خبری از Promise.race و تایمر نیست.
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("Silent Error detected:", error);
375
- // اگر خطایی رخ داد، به کاربر چیزی نشان نمی‌دهیم یا فقط پیام توقف کوچک
376
- // چون کاربر خواسته هیچ خطای "سرور پاسخگو نبود" نبیند.
377
  if (modelBubbleOuterDiv) {
378
- // بجای پیام خطای قرمز، فقط یک متن کوچک
379
- const contentArea = modelBubbleOuterDiv.querySelector('.message-content') || modelBubbleOuterDiv;
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 {