mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 10:56:10 +00:00
Merge pull request #81 from catrobe/custom-binary-in-settings
Describe the binary the settings point at, not the one Dikte found
This commit is contained in:
@@ -806,6 +806,7 @@ TR = {
|
|||||||
"Local model": "Yerel model",
|
"Local model": "Yerel model",
|
||||||
"Not installed.": "Kurulu değil.",
|
"Not installed.": "Kurulu değil.",
|
||||||
"Installed on the system: {path}": "Sistemde kurulu: {path}",
|
"Installed on the system: {path}": "Sistemde kurulu: {path}",
|
||||||
|
"Using custom build: {path}": "Özel derleme kullanılıyor: {path}",
|
||||||
"Download again": "Yeniden indir",
|
"Download again": "Yeniden indir",
|
||||||
"Downloaded, version {version}.": "İndirildi, sürüm {version}.",
|
"Downloaded, version {version}.": "İndirildi, sürüm {version}.",
|
||||||
"Downloaded, version {version}. There was no Vulkan build, "
|
"Downloaded, version {version}. There was no Vulkan build, "
|
||||||
|
|||||||
+20
-5
@@ -255,9 +255,11 @@ class LocalModelBox(QGroupBox):
|
|||||||
|
|
||||||
changed = pyqtSignal()
|
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)
|
super().__init__(title, parent)
|
||||||
self.program = program
|
self.program = program
|
||||||
|
self._binary = binary # () -> a path set by hand, or ""
|
||||||
self._models = models # () -> [hub.Item], or (repo) -> [hub.Item]
|
self._models = models # () -> [hub.Item], or (repo) -> [hub.Item]
|
||||||
self._model_path = model_path # (name) -> Path
|
self._model_path = model_path # (name) -> Path
|
||||||
self._repos = repos # None, or () -> [repo id]
|
self._repos = repos # None, or () -> [repo id]
|
||||||
@@ -421,13 +423,23 @@ class LocalModelBox(QGroupBox):
|
|||||||
self._fill_repos(self.repository())
|
self._fill_repos(self.repository())
|
||||||
self._fetch_models(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):
|
def _show_program(self):
|
||||||
path = ggml.program_path(self.program)
|
path = self._program_path()
|
||||||
if not path:
|
if not path:
|
||||||
self.program_label.setText(t("Not installed."))
|
self.program_label.setText(t("Not installed."))
|
||||||
self.install_button.setText(t("Download"))
|
self.install_button.setText(t("Download"))
|
||||||
self.install_button.setVisible(True)
|
self.install_button.setVisible(True)
|
||||||
return
|
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
|
# 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
|
# every few weeks, and a graphics card installed after Dikte was
|
||||||
# changes which build this machine should be running; the button was
|
# changes which build this machine should be running; the button was
|
||||||
@@ -839,7 +851,7 @@ class LocalModelBox(QGroupBox):
|
|||||||
repo=self.repository(), cap=ggml.human_size(ggml.GGUF_MAX_BYTES)))
|
repo=self.repository(), cap=ggml.human_size(ggml.GGUF_MAX_BYTES)))
|
||||||
elif not name:
|
elif not name:
|
||||||
self.status.setText(t("Nothing downloaded yet."))
|
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
|
# The model alone runs nothing, and "Ready" over a missing program
|
||||||
# reads as though it does.
|
# reads as though it does.
|
||||||
self.status.setText(t("{name} is here, but the program above is "
|
self.status.setText(t("{name} is here, but the program above is "
|
||||||
@@ -1199,7 +1211,8 @@ class SettingsWindow(QDialog):
|
|||||||
|
|
||||||
self.local_whisper = LocalModelBox(
|
self.local_whisper = LocalModelBox(
|
||||||
ggml.WHISPER, t("On this machine"),
|
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)
|
stt_form.addRow(self.local_whisper)
|
||||||
|
|
||||||
self.local_gpu = QCheckBox(t("Use the graphics card"))
|
self.local_gpu = QCheckBox(t("Use the graphics card"))
|
||||||
@@ -1310,7 +1323,9 @@ class SettingsWindow(QDialog):
|
|||||||
|
|
||||||
self.local_llm = LocalModelBox(
|
self.local_llm = LocalModelBox(
|
||||||
ggml.LLAMA, t("On this machine"),
|
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)
|
orr_form.addRow(self.local_llm)
|
||||||
|
|
||||||
self.local_llm_gpu = QCheckBox(t("Use the graphics card"))
|
self.local_llm_gpu = QCheckBox(t("Use the graphics card"))
|
||||||
|
|||||||
@@ -1556,6 +1556,29 @@ class LocalModels(DikteTest):
|
|||||||
self.assertNotIn("Ready", box.status.text())
|
self.assertNotIn("Ready", box.status.text())
|
||||||
self.assertIn("program", 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):
|
def test_changing_the_publisher_changes_the_model(self):
|
||||||
# The model chosen under the old publisher is not published by the new
|
# 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
|
# one. Carried over, it was added back as "not downloaded" and selected
|
||||||
|
|||||||
Reference in New Issue
Block a user