this is probably due to the fact that main thread is handeling both frontend display AND ollama callings
ollama callings take up very long time to execute causing windows to detect that python application as not responding
proposed fix->
move the Ollama calliing to a worker thread using QThread or some other better suited multithreading lib
Qthreads -> https://doc.qt.io/archives/qtforpython-5/PySide2/QtCore/QThread.html#qthread
Do note:
The example code is just a representation of the example workflow, please do look into the code before sending a pr
PyQt5==5.15.11 is used as stated in requirements.txt
something like this could work ->
class OllamaWorker(QThread):
result_ready = pyqtSignal(str)
error = pyqtSignal(str)
def __init__(self, prompt):
super().__init__()
self.prompt = prompt
def run(self):
try:
#call ollama model
except Exception as e:
self.error.emit(str(e))
class MainWindow(QMainWindow):
def __init__(self):
...
self.worker = None # keep reference or it gets garbage collected
def send_to_ollama(self):
...
def on_result(self, response):
self.label.setText(response)
self.button.setEnabled(True)
def on_error(self, msg):
self.label.setText(f"Error: {msg}")
self.button.setEnabled(True)```
this is probably due to the fact that main thread is handeling both frontend display AND ollama callings
ollama callings take up very long time to execute causing windows to detect that python application as not responding
proposed fix->
move the Ollama calliing to a worker thread using QThread or some other better suited multithreading lib
Qthreads -> https://doc.qt.io/archives/qtforpython-5/PySide2/QtCore/QThread.html#qthread
Do note:
The example code is just a representation of the example workflow, please do look into the code before sending a pr
PyQt5==5.15.11 is used as stated in requirements.txt
something like this could work ->