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

Being able to stop api/pull models download stream #568

Closed
JulienElkaim opened this issue Oct 9, 2024 · 5 comments
Closed

Being able to stop api/pull models download stream #568

JulienElkaim opened this issue Oct 9, 2024 · 5 comments
Labels
p:ollama_dart ollama_dart package. t:enhancement New feature or request

Comments

@JulienElkaim
Copy link

Feature request

Hi,

I would like a feature to make it possible to cancel a pullModelStream , so Ollama stops downloading the model if we want to.

Motivation

In my Ollama client, I want to give users the right to missclick. Therefore, if they finally decide they don't want the huge models on their computer, they can stop downloading it !

Your contribution

Please share your preferences of implementation, and I will be happy to contribute

@JulienElkaim JulienElkaim added the t:enhancement New feature or request label Oct 9, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in LangChain.dart Oct 9, 2024
@davidmigloz
Copy link
Owner

Hey @JulienElkaim,

Thanks for bringing this up.

The problem is that the official http package doesn't support cancelling requests yet. Do you have any suggestions?

@davidmigloz davidmigloz added the p:langchain_ollama langchain_ollama package. label Oct 9, 2024
@JulienElkaim
Copy link
Author

Hi,

Interesting for an official http package!
I understand they feel it's negligible most of time... but with models that size the stake is high. As official library they should support these edge cases :/

I would hope we can support it. I tried with curls & ctrl+C and it confirms cancelling http request stops download, see screenshot:
Screenshot 2024-10-09 at 8 18 44 PM

Could we switch http library? I did not dig into your codebase yet so I am not sure how big it is.
If you like the idea, I can do further analysis. It seems dio package support cancellation, If I understand correctly.

  • How open would you be to switch to dio?
  • Do you prefer the same http package dependency for ALL Ollama calls or can we only switch library for api/pull ?

I can give a try with dio and provide an example next week. See if switching library is worth it before doing anything :)

@davidmigloz
Copy link
Owner

davidmigloz commented Oct 9, 2024

I agree, it's a pity that such a basic feature is still not supported.

Migrating to another client would have quite some impact, as we generate the OllamaClient from the OpenAPI spec using the openapi_spec generator. So, first we would need to add support for different clients in the generator... And using different clients for different methods would be a bit confusing, I think.

Do you know if there is any alternative that wraps the official http client and adds support for cancelling requests without modifying its API? That would be an ideal solution, as you can always pass your custom http client:

final client = OllamaClient(
  client: CancellableHttpClient(),
);

@davidmigloz
Copy link
Owner

An example would be https://pub.dev/packages/fetch_client (which is used internally by OllamaClient when targetting web to support streaming). It implements the same http API, but under-the-hood it uses the JS fetch API which supports cancelling requests.

@davidmigloz davidmigloz added p:ollama_dart ollama_dart package. and removed p:langchain_ollama langchain_ollama package. labels Dec 6, 2024
@davidmigloz
Copy link
Owner

I'll close this issue for now, as it's not actionable at the moment. We'll reconsider it if http package adds the needed functionality or if we decide to migrate to a different http client.

@davidmigloz davidmigloz closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in LangChain.dart Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p:ollama_dart ollama_dart package. t:enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants