ollama / ollama-js

Ollama JavaScript library
https://ollama.ai
MIT License
1.56k stars 103 forks source link

AbortableAsyncIterator #97

Closed hopperelec closed 2 weeks ago

hopperelec commented 1 month ago

Closes https://github.com/ollama/ollama-js/issues/95

hopperelec commented 4 weeks ago

I've just realised https://github.com/ollama/ollama-js/tree/main/examples/abort exists, I'll update this example shortly. I've also just realised that it's probably a good idea to still have a function to abort all requests but, since each request now has it's own AbortController, this will need to be implemented differently to before

hopperelec commented 4 weeks ago

This probably isn't the best way to do this, and it might be useful to allow users to interact with the array of requests in more ways, but I wanted to keep it simple so I can respond to feedback more easily

hopperelec commented 3 weeks ago

No worries! There's definitely other things which could be added, such as some extra error handling and allowing users to interact with the array of streamed requests (but while maintaining encapsulation), but I also want to avoid over-complicating it. If anyone thinks these should be added, I'm happy to include them, but otherwise I'm happy with it as it is.