ollama-python icon indicating copy to clipboard operation
ollama-python copied to clipboard

support a custom HTTPX client in `Client` and `AsyncClient`

Open samuelcolvin opened this issue 1 year ago • 6 comments

As well as allowing a custom httpx client, this also improves type safety in Client and AsyncClient - previously self._client implicitly had type of None.

samuelcolvin avatar Dec 14 '24 11:12 samuelcolvin

This is needed for pydantic-ai to use this library rather than the OpenAI compatibility layer, see https://github.com/pydantic/pydantic-ai/issues/242.

samuelcolvin avatar Dec 14 '24 11:12 samuelcolvin

Thanks for the PR. Can you provide some details in the description of why this change is necessary for pydantic-ai?

mxyng avatar Dec 16 '24 19:12 mxyng

We would like to reuse a set of http connections (encapsulated in an HTTPX client) when creating Ollama clients, so it's as cheap as possible to create new clients.

Please could you at least kick off tests.

By the way, you can set github to run tests automatically, even for new contributors; this change makes it much more attractive to contribute to the library.

samuelcolvin avatar Dec 17 '24 09:12 samuelcolvin

Hi can you fix the tests? ollama-python currently targets 3.8 so the union types | are not supported. Please use typing.Union

mxyng avatar Dec 17 '24 21:12 mxyng

Fixed suggestions I think, by the way it would be easier for contributors and less work for you if you let tests run automatically.

samuelcolvin avatar Dec 21 '24 15:12 samuelcolvin

Friendly request to please take another peek at this PR. I’m here as a user of pydantic-ai and would love to be able to leverage ollama structured outputs and pydantic-ai for super powered local agents.😀

Really appreciate the hard work from both projects, so thank you all in advance!

Also, if you have a donation link of some kind, I’d be happy to use that to support.

bgeesaman avatar Jan 16 '25 02:01 bgeesaman