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

Add the ability for ollama ports to stay open while it's still running with .WithLifetime(Persistent) #406

Open
JohnGalt1717 opened this issue Jan 21, 2025 · 6 comments

Comments

@JohnGalt1717
Copy link

Related to an existing integration?

Yes

Existing integration

Ollama

Overview

Right now you can specify a port to use, and you can specify persistence, but there is no way to specify that the instance keeps the port assigned. It would be nice to either have an extension for .WithPort(int, bool proxy = true) or add an optional parameter on AddOllama().

This would solve the problem so that the instance stays available for external calls while the aspire host isn't running.

Usage example

See above.

Breaking change?

No

Alternatives

I can't find any.

Additional context

This means you can use the instance and API while doing other things and makes Ollama with persistent lifetime work as you'd expect.

Help us help you

No, just wanted to propose this

@aaronpowell
Copy link
Member

You can specify a port as the final argument of the AddOllama method:

var ollama = builder.AddOllama("ollama", 12345);

Alternatively, you can call the WithEndpoint method exposed by Aspire and provide a port, which would override the one that we do initially.

Would either of these do what you're after?

@JohnGalt1717
Copy link
Author

Unfortunately not because when you shut down the aspire host, the port mapping is removed even though the container is not because of WithLifetime(Persistent)

Basically when you set WithLifetime(Persistent), the container should be up and be able to be used even when the aspire host isn't running which means that the ports should stay available.

Interestingly, the UI.WithLifetime(Persistent) does keep the ports open, but it can't access the container for the ollama server because those ports were removed.

@aaronpowell
Copy link
Member

ah yes, because that port is the port that is used by the proxy in the app host, not the port assigned in Docker when the container is started.

I feel like this problem is a by-design, my understanding is that persistent containers are persistent from the app host perspective, but they aren't meant to be then used by other systems outside of the app host/aspire app. @davidfowl is this the right assumption that I have?

@davidfowl
Copy link

We've implemeneted a mititgation in 9.1 dotnet/aspire#7063 (comment)

@JohnGalt1717
Copy link
Author

On some of the implementations there is a flag "useProxy" that if you set to false, tells it not to proxy the ports but to directly expose them.

Is it possible to enable this for ollama as an optional parameter like others have done in the mean time?

@davidfowl
Copy link

If you want a workaround right now, then you should be able to turn off the proxy like this:

var ollama = builder.AddOllama("ollama", 12345).WithEndpoint("http", e => e.IsProxied = false);

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

No branches or pull requests

3 participants