ollama / ollama-js

Ollama JavaScript library

Home Page:https://ollama.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Idiomatic way to cancel request?

nanmu42 opened this issue · comments

Hi, Ollama is great, love it.

I am trying to handle user cancellation during generation, so far I am trying AsyncGenerator.prototype.return() of the return value of await ollama.chat but it freezes the Ollama server and all following requests hang.

I see ollama-js is using fetch and normally we use AbortController to signal abort. Is there something similiar in ollama-js?

Thank you for your effort and time.

Hey @nanmu42, I just ran into this too. I've merged a change which is in the new release (v0.4.6)

Here's an example of how to use it:
https://github.com/ollama/ollama-js/blob/main/examples/abort/abort.ts