Spaces:
Sleeping
Sleeping
Heebin Moon Claude Opus 4.6 commited on
Commit ยท
97fa2d2
1
Parent(s): 1212107
Switch default LLM to Gemini Flash-Lite and fix SSE for Cloudflare
Browse files- Change default LLM from gpt-4o-mini to gemini-flash-lite across frontend and backend
- Replace SSE streaming with polling for Cloudflare Tunnel compatibility
- Add cache/buffering headers to SSE endpoint
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- formatter.py +2 -2
- templates/index.html +34 -22
- web.py +9 -1
formatter.py
CHANGED
|
@@ -587,7 +587,7 @@ def _truncate_text(text: str, max_chars: int = 100000) -> tuple:
|
|
| 587 |
def format_as_markdown(
|
| 588 |
text: str,
|
| 589 |
title: str,
|
| 590 |
-
llm_provider: str = "
|
| 591 |
api_key: Optional[str] = None,
|
| 592 |
ollama_model: str = "llama3.2",
|
| 593 |
on_progress: Optional[Callable] = None,
|
|
@@ -646,7 +646,7 @@ def format_as_markdown(
|
|
| 646 |
def translate_text(
|
| 647 |
text: str,
|
| 648 |
target_lang: str,
|
| 649 |
-
llm_provider: str = "
|
| 650 |
api_key: Optional[str] = None,
|
| 651 |
ollama_model: str = "llama3.2",
|
| 652 |
on_progress: Optional[Callable] = None,
|
|
|
|
| 587 |
def format_as_markdown(
|
| 588 |
text: str,
|
| 589 |
title: str,
|
| 590 |
+
llm_provider: str = "gemini-flash-lite",
|
| 591 |
api_key: Optional[str] = None,
|
| 592 |
ollama_model: str = "llama3.2",
|
| 593 |
on_progress: Optional[Callable] = None,
|
|
|
|
| 646 |
def translate_text(
|
| 647 |
text: str,
|
| 648 |
target_lang: str,
|
| 649 |
+
llm_provider: str = "gemini-flash-lite",
|
| 650 |
api_key: Optional[str] = None,
|
| 651 |
ollama_model: str = "llama3.2",
|
| 652 |
on_progress: Optional[Callable] = None,
|
templates/index.html
CHANGED
|
@@ -794,7 +794,7 @@
|
|
| 794 |
let timerInterval = null;
|
| 795 |
let startTime = null;
|
| 796 |
let tipInterval = null;
|
| 797 |
-
let selectedLLM = '
|
| 798 |
let llmModels = [];
|
| 799 |
let languages = [];
|
| 800 |
let llmLoaded = false;
|
|
@@ -1194,32 +1194,44 @@
|
|
| 1194 |
}
|
| 1195 |
|
| 1196 |
const jobId = data.job_id;
|
| 1197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1198 |
|
| 1199 |
-
|
| 1200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1201 |
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1205 |
}
|
| 1206 |
-
}
|
| 1207 |
-
|
| 1208 |
stopTimer();
|
| 1209 |
-
|
| 1210 |
-
setTimeout(() => showResult(msg.result), 500);
|
| 1211 |
-
} else if (msg.type === 'error') {
|
| 1212 |
-
eventSource.close();
|
| 1213 |
-
stopTimer();
|
| 1214 |
-
showError(msg.message);
|
| 1215 |
}
|
| 1216 |
-
};
|
| 1217 |
-
|
| 1218 |
-
eventSource.onerror = () => {
|
| 1219 |
-
eventSource.close();
|
| 1220 |
-
stopTimer();
|
| 1221 |
-
showError('์๋ฒ ์ฐ๊ฒฐ์ด ๋์ด์ก์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์.');
|
| 1222 |
-
};
|
| 1223 |
} catch (err) {
|
| 1224 |
stopTimer();
|
| 1225 |
showError(`์์ฒญ ์คํจ: ${err.message}`);
|
|
|
|
| 794 |
let timerInterval = null;
|
| 795 |
let startTime = null;
|
| 796 |
let tipInterval = null;
|
| 797 |
+
let selectedLLM = 'gemini-flash-lite';
|
| 798 |
let llmModels = [];
|
| 799 |
let languages = [];
|
| 800 |
let llmLoaded = false;
|
|
|
|
| 1194 |
}
|
| 1195 |
|
| 1196 |
const jobId = data.job_id;
|
| 1197 |
+
let pollSeen = 0;
|
| 1198 |
+
|
| 1199 |
+
const pollInterval = setInterval(async () => {
|
| 1200 |
+
try {
|
| 1201 |
+
const res = await fetch(`/api/status/${jobId}`);
|
| 1202 |
+
const job = await res.json();
|
| 1203 |
+
|
| 1204 |
+
if (job.error && !job.progress) {
|
| 1205 |
+
clearInterval(pollInterval);
|
| 1206 |
+
stopTimer();
|
| 1207 |
+
showError(job.error);
|
| 1208 |
+
return;
|
| 1209 |
+
}
|
| 1210 |
|
| 1211 |
+
while (pollSeen < job.progress.length) {
|
| 1212 |
+
const msg = job.progress[pollSeen];
|
| 1213 |
+
if (msg.step && msg.percent !== undefined) {
|
| 1214 |
+
updateStep(msg.step, msg.percent, msg.detail || '');
|
| 1215 |
+
}
|
| 1216 |
+
pollSeen++;
|
| 1217 |
+
}
|
| 1218 |
|
| 1219 |
+
if (job.status === 'completed') {
|
| 1220 |
+
clearInterval(pollInterval);
|
| 1221 |
+
stopTimer();
|
| 1222 |
+
setAllStepsDone();
|
| 1223 |
+
setTimeout(() => showResult(job.result), 500);
|
| 1224 |
+
} else if (job.status === 'error') {
|
| 1225 |
+
clearInterval(pollInterval);
|
| 1226 |
+
stopTimer();
|
| 1227 |
+
showError(job.error);
|
| 1228 |
}
|
| 1229 |
+
} catch (err) {
|
| 1230 |
+
clearInterval(pollInterval);
|
| 1231 |
stopTimer();
|
| 1232 |
+
showError('์๋ฒ ์ฐ๊ฒฐ์ด ๋์ด์ก์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1233 |
}
|
| 1234 |
+
}, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1235 |
} catch (err) {
|
| 1236 |
stopTimer();
|
| 1237 |
showError(`์์ฒญ ์คํจ: ${err.message}`);
|
web.py
CHANGED
|
@@ -215,7 +215,15 @@ async def stream_status(job_id: str):
|
|
| 215 |
|
| 216 |
await asyncio.sleep(0.5)
|
| 217 |
|
| 218 |
-
return StreamingResponse(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
|
| 221 |
@app.get("/api/download/{filename}")
|
|
|
|
| 215 |
|
| 216 |
await asyncio.sleep(0.5)
|
| 217 |
|
| 218 |
+
return StreamingResponse(
|
| 219 |
+
event_generator(),
|
| 220 |
+
media_type="text/event-stream",
|
| 221 |
+
headers={
|
| 222 |
+
"Cache-Control": "no-cache",
|
| 223 |
+
"X-Accel-Buffering": "no",
|
| 224 |
+
"Connection": "keep-alive",
|
| 225 |
+
},
|
| 226 |
+
)
|
| 227 |
|
| 228 |
|
| 229 |
@app.get("/api/download/{filename}")
|