athena129 commited on
Commit
34409ab
·
verified ·
1 Parent(s): 86122cc

Surface stream errors/timeouts even when partial content arrived (no more silent truncation)

Browse files
Files changed (1) hide show
  1. index.html +8 -4
index.html CHANGED
@@ -1114,15 +1114,17 @@ async function askModel(prompt, history, onChunk, onStatus){
1114
  if (watchdog) clearTimeout(watchdog);
1115
  }
1116
 
1117
- if (timedOut && !lastContent){
1118
- const err = new Error("The streaming connection went quiet for 90 s — likely a backend hang or dropped SSE.");
1119
  err.title = "Stream timeout";
 
1120
  throw err;
1121
  }
1122
- if (errorPayload && !lastContent){
1123
  const err = new Error(errorPayload.message || errorPayload.title || "Backend returned an error.");
1124
  err.title = errorPayload.title;
1125
  err.detail = errorPayload.message;
 
1126
  throw err;
1127
  }
1128
  return { answer: lastContent || "The model returned no output. Try again." };
@@ -1407,10 +1409,12 @@ async function sendMessage(text){
1407
  const { answer } = await askModel(text, hist, onChunk, onStatus);
1408
  convo[convo.length - 1] = { role:'bot', text: answer };
1409
  } catch (e){
 
 
1410
  convo[convo.length - 1] = {
1411
  role:'bot',
1412
  error: true,
1413
- text: explainError(e),
1414
  };
1415
  // Drop the cached gradio Client so the next send rebuilds a fresh
1416
  // SSE/queue connection. If the previous one got into a bad state
 
1114
  if (watchdog) clearTimeout(watchdog);
1115
  }
1116
 
1117
+ if (timedOut){
1118
+ const err = new Error("The streaming connection went quiet for 90 s — likely a backend hang, dropped SSE, or ZeroGPU duration cap reached.");
1119
  err.title = "Stream timeout";
1120
+ err.partial = lastContent;
1121
  throw err;
1122
  }
1123
+ if (errorPayload){
1124
  const err = new Error(errorPayload.message || errorPayload.title || "Backend returned an error.");
1125
  err.title = errorPayload.title;
1126
  err.detail = errorPayload.message;
1127
+ err.partial = lastContent;
1128
  throw err;
1129
  }
1130
  return { answer: lastContent || "The model returned no output. Try again." };
 
1409
  const { answer } = await askModel(text, hist, onChunk, onStatus);
1410
  convo[convo.length - 1] = { role:'bot', text: answer };
1411
  } catch (e){
1412
+ const errMsg = explainError(e);
1413
+ const partial = (e && typeof e.partial === 'string') ? e.partial : '';
1414
  convo[convo.length - 1] = {
1415
  role:'bot',
1416
  error: true,
1417
+ text: partial ? `${partial}\n\n— ${errMsg}` : errMsg,
1418
  };
1419
  // Drop the cached gradio Client so the next send rebuilds a fresh
1420
  // SSE/queue connection. If the previous one got into a bad state