Skip to content
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

Idiomatic way to cancel request? #39

Closed
nanmu42 opened this issue Feb 4, 2024 · 1 comment · Fixed by #40
Closed

Idiomatic way to cancel request? #39

nanmu42 opened this issue Feb 4, 2024 · 1 comment · Fixed by #40
Assignees

Comments

@nanmu42
Copy link

nanmu42 commented Feb 4, 2024

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.

@BruceMacD
Copy link
Collaborator

BruceMacD commented Feb 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants