diff options
Diffstat (limited to 'workers/ollama_check_worker.py')
| -rw-r--r-- | workers/ollama_check_worker.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/workers/ollama_check_worker.py b/workers/ollama_check_worker.py new file mode 100644 index 0000000..5f47492 --- /dev/null +++ b/workers/ollama_check_worker.py @@ -0,0 +1,19 @@ +from __future__ import annotations +import urllib.request +from PyQt6.QtCore import QThread, pyqtSignal + + +class OllamaCheckWorker(QThread): + reachable = pyqtSignal(bool, str) # (ok, url_tried) + + def __init__(self, host_url: str, timeout: int = 4, parent=None): + super().__init__(parent) + self._url = host_url.rstrip("/") + "/api/tags" + self._timeout = timeout + + def run(self): + try: + urllib.request.urlopen(self._url, timeout=self._timeout) + self.reachable.emit(True, self._url) + except Exception: + self.reachable.emit(False, self._url) |
