Relative Content

Tag Archive for pythonmultithreadingtkinterllamaollama

how to instantly terminate a thread? Using ollama python API with tkinter to stream a response from llama2

I’m using ollama to stream a response from llama2 large language model. The functionality I need is, when I click the stop button, it should stop the thread immediately. The code below works but the problem is, it always waits for the first chunk to be available before it checks if stop is true. Sometimes the response can take some time before the first chunk is ready. It shouldn’t wait for the first chunk. It should immediately stop the thread when stop button is clicked.