Closed dpatschke closed 4 months ago
Perhaps some of the other llm
plugins faced a similar problem and has a solution that we can copy?
I'll look into it.
My first thought would be to pass a host
parameter in via options
and then extract and remove it before the options are then passed into the chat
method, but this doesn't seem overly elegant.
Actually, I found a solution.
The following line of code suggest that adding a OLLAMA_HOST
environment variable should solve the problem.
https://github.com/ollama/ollama-python/blob/8b694bb0f4578c07ab50da06d80bc7276a470e7c/ollama/_client.py#L56
I did, in fact, test this and it works. Closing the issue.
Actually, I found a solution.
The following line of code suggest that adding a OLLAMA_HOST
environment variable should solve the problem.
https://github.com/ollama/ollama-python/blob/8b694bb0f4578c07ab50da06d80bc7276a470e7c/ollama/_client.py#L56
I did, in fact, test this and it works. Closing the issue.
Thanks for researching. I've added a note about this variable to the README.
I'm not sure what changed and when, but this doesn't work today. Or at least, doesn't work for llm ollama list-models
. The problem is that the ollama
library instantiates a bare Client()
to use by default here which ignores the environment variable, and that's what's used when you call ollama.list
here. The result is that the available models never get registered, so you can't select them for prompting.
I've followed your first link and I think this bare Client()
actually gets host set from environment variable, see here: https://github.com/ollama/ollama-python/blob/ebe332b29d5c65aeccfadd4151bf6059ded7049b/ollama/_client.py#L57
Ah you're right, of course. I'm being misled by IPv6 horribleness.
It looks like there is currently only support for utilizing ollama servers hosted on the default server/port (localhost:11434).
The python API supports
from ollama import Client
where Client can then be utilized like:vs. the current method of just using
ollama.chat
.I'm trying to build a docker-compose application that has an application leveraging
llm
in one container andollama
server running in another and am facing some headwinds implementing this without theClient
functionality readily exposed inllm-ollama
.It seems like this would be very doable. The main question would be where/how to pass in an optional
host
parameter forClient
.