From d04a2c53b926ccde0d582dbf4a7360dc0f072205 Mon Sep 17 00:00:00 2001 From: historia Date: Wed, 2 Sep 2026 22:53:07 -0400 Subject: fix: warn before using a likely too-big chunk size for sglang-omni models --- app/ui/hub.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'app/ui/hub.py') diff --git a/app/ui/hub.py b/app/ui/hub.py index 13f17e7..7a6bfcc 100644 --- a/app/ui/hub.py +++ b/app/ui/hub.py @@ -1133,6 +1133,32 @@ def _tui_confirm(stdscr) -> Callable: return confirm +def _tui_chunk_clamp(stdscr, entry) -> Optional[int]: + """The chunk-cap popup for an sglomni run (None = no clamp). + + A model whose catalog entry caps a sub-request below CHUNK_SIZE + (Higgs: the server pins each request's prompt plus generation at a + fixed window) asks before the run: clamp CHUNK_SIZE for this run, + keep it (audio may cut off mid-chunk), or go back to the form. The + answer rides the command's kwargs (``chunk_size``) so the converter + and its client see it; the config.CHUNK_SIZE setting itself is never + rewritten. + """ + if not converter_mod.chunk_clamp_needed(entry): + return None + words = entry.chunk_words + answer = tui.menu( + stdscr, "Generation cap", + [(f"Set Chunk to {words} (this run)", "clamp"), + ("Try anyway", "anyway"), + ("Cancel", "cancel")], + help_lines=converter_mod.chunk_clamp_message(entry), + back_value="cancel") + if answer == "cancel": + raise _BackToForm() + return words if answer == "clamp" else None + + def _check_preflight_plan(stdscr, book_files: list, planned: dict) -> bool: """The shared nothing-to-convert flashes; True when there is a plan. @@ -1180,6 +1206,12 @@ def _preflight(stdscr, cmd: tuple) -> bool: confirm=_tui_confirm(stdscr)) if not _check_preflight_plan(stdscr, book_files, {"": planned}): return False + if backend == BACKEND_SGLOMNI: + entry = sglomni_backend.entry_by_key((kwargs.get("model_id") + or "").strip()) + clamp = _tui_chunk_clamp(stdscr, entry) + if clamp is not None: + kwargs["chunk_size"] = clamp kwargs["book_files"] = book_files kwargs["planned"] = planned return True -- cgit v1.2.3