aboutsummaryrefslogtreecommitdiff
path: root/app/ui/hub.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/ui/hub.py')
-rw-r--r--app/ui/hub.py32
1 files changed, 32 insertions, 0 deletions
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