Describe the binary the settings point at, not the one Dikte found

program_path takes the custom path as its second argument, and config.py
passes it, but the settings window never did. Happened on this machine:
Compiled my own whisper.cpp and llama.cpp with CUDA and pointed the
settings at them. The box with no downloaded copy said "Not installed."
The box with one said "Downloaded, version b4938." naming a processor
build while the CUDA one did the transcribing.

LocalModelBox is now handed a callable, so the setting is read when
the label is drawn rather than frozen when the window is built.

The label reflects that too. A path set by hand now says so, instead of
claiming Dikte downloaded something it didn't.
This commit is contained in:
M. Ömer Okyar
2026-09-05 16:10:07 +03:00
parent 4b3ae8d70b
commit b46181e001
3 changed files with 44 additions and 5 deletions
+1
View File
@@ -806,6 +806,7 @@ TR = {
"Local model": "Yerel model",
"Not installed.": "Kurulu değil.",
"Installed on the system: {path}": "Sistemde kurulu: {path}",
"Using custom build: {path}": "Özel derleme kullanılıyor: {path}",
"Download again": "Yeniden indir",
"Downloaded, version {version}.": "İndirildi, sürüm {version}.",
"Downloaded, version {version}. There was no Vulkan build, "
+20 -5
View File
@@ -253,9 +253,11 @@ class LocalModelBox(QGroupBox):
changed = pyqtSignal()
def __init__(self, program, title, models, model_path, repos=None, parent=None):
def __init__(self, program, title, models, model_path, binary=None,
repos=None, parent=None):
super().__init__(title, parent)
self.program = program
self._binary = binary # () -> a path set by hand, or ""
self._models = models # () -> [hub.Item], or (repo) -> [hub.Item]
self._model_path = model_path # (name) -> Path
self._repos = repos # None, or () -> [repo id]
@@ -417,13 +419,23 @@ class LocalModelBox(QGroupBox):
self._fill_repos(self.repository())
self._fetch_models(self.repository())
def _program_path(self):
return ggml.program_path(self.program,
self._binary() if self._binary else "")
def _show_program(self):
path = ggml.program_path(self.program)
path = self._program_path()
if not path:
self.program_label.setText(t("Not installed."))
self.install_button.setText(t("Download"))
self.install_button.setVisible(True)
return
if self._binary and self._binary():
# Neither a system copy nor one Dikte fetched, and "Downloaded"
# over a build someone made themselves is not true.
self.program_label.setText(t("Using custom build: {path}", path=path))
self.install_button.setVisible(False)
return
# A copy that is here is not a copy that is right. whisper.cpp releases
# every few weeks, and a graphics card installed after Dikte was
# changes which build this machine should be running; the button was
@@ -835,7 +847,7 @@ class LocalModelBox(QGroupBox):
repo=self.repository(), cap=ggml.human_size(ggml.GGUF_MAX_BYTES)))
elif not name:
self.status.setText(t("Nothing downloaded yet."))
elif here and not ggml.program_path(self.program):
elif here and not self._program_path():
# The model alone runs nothing, and "Ready" over a missing program
# reads as though it does.
self.status.setText(t("{name} is here, but the program above is "
@@ -1191,7 +1203,8 @@ class SettingsWindow(QDialog):
self.local_whisper = LocalModelBox(
ggml.WHISPER, t("On this machine"),
ggml.whisper_models, ggml.whisper_model_path)
ggml.whisper_models, ggml.whisper_model_path,
binary=lambda: self.conf["local_binary"])
stt_form.addRow(self.local_whisper)
self.local_gpu = QCheckBox(t("Use the graphics card"))
@@ -1300,7 +1313,9 @@ class SettingsWindow(QDialog):
self.local_llm = LocalModelBox(
ggml.LLAMA, t("On this machine"),
ggml.llm_quants, ggml.llm_model_path, repos=ggml.llm_repos)
ggml.llm_quants, ggml.llm_model_path,
binary=lambda: self.conf["local_llm_binary"],
repos=ggml.llm_repos)
orr_form.addRow(self.local_llm)
self.local_llm_gpu = QCheckBox(t("Use the graphics card"))
+23
View File
@@ -1461,6 +1461,29 @@ class LocalModels(DikteTest):
self.assertNotIn("Ready", box.status.text())
self.assertIn("program", box.status.text())
def test_a_program_set_in_the_settings_is_not_called_downloaded(self):
mine = self.path("my-whisper-server")
mine.write_text("#!/bin/sh\n")
mine.chmod(0o755)
self.patch_attr(ggml.shutil, "which", lambda name: None)
box = self.window(self.config(local_binary=str(mine))).local_whisper
self.assertIn(str(mine), box.program_label.text())
self.assertFalse(box.install_button.isVisibleTo(box))
def test_a_model_over_a_program_set_by_hand_is_ready(self):
# The program is there, it is just named by the settings rather than
# downloaded, and the status line looked past it.
mine = self.path("my-whisper-server")
mine.write_text("#!/bin/sh\n")
mine.chmod(0o755)
self.patch_attr(ggml.shutil, "which", lambda name: None)
path = ggml.whisper_model_path("ggml-small.bin")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(b"not really a model")
box = self.window(self.config(local_binary=str(mine))).local_whisper
box.load("ggml-small.bin")
self.assertIn("Ready", box.status.text())
def test_changing_the_publisher_changes_the_model(self):
# The model chosen under the old publisher is not published by the new
# one. Carried over, it was added back as "not downloaded" and selected