-
Notifications
You must be signed in to change notification settings - Fork 13
How to cancel AI prompt #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey JG-Adams, I hope that you're well. I'll take a look at this when possible; if you can post a short example that would be helpful. |
I'm doing well. Thanks! Hope you're well too! catch(ollama::exception& e) { std::cerr << e.what() << std::endl; } Main thread check if it's joinable per frame of the program. So in my case I use 8192 as context limit, no problem. Fortunately it doesn't hurt the system, it just take time to clean up after itself. |
I managed to solve the issue. But this is what I did. When the exception get caught, return; However I was also using std::atomic busy; to prevent multi request. So only when it's set to false can the prompt go through. This managed to fix the problem and allow the program to be able to use it again and so user can use different setting, program fully clean everything up too. Ollama actually does cancel the process. It gave me helpful info: So this has occurred as a rather interesting bug. I don't know if return; inside of catch is the most appropriate thing in the world. But my reasoning is that it's a function so it should force it to actually reach the end of process. I do know that there appear to be no problem and every translation unit was able to fully exits. It is desirable to support using no exception too. So that's next. |
Hey JG-Adams, I'm adding some hooks to do this gracefully now within the |
Support for stopping an active stream has been added with #36 and is included with the latest release. This adds support for the bound function to return a bool that determines whether the response being streamed should continue. See the cases added in I've tested this and confirms it immediately stops generation in Ollama which should prevent wasted resources when a stream is cancelled. |
Awesome! I'm gonna try this. :) |
There is a case when I set the context limit too high it fail to deliver but the program is safe and will not crash. However this mean that the asynchronous function is still expecting response from the AI making it require a restart in order to use it! How to handle this?
The text was updated successfully, but these errors were encountered: