mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 18:50:33 +00:00
**Description**: Add a `async_client_kwargs` field to ollama chat/llm/embeddings adapters that is passed to async httpx client constructor. **Motivation:** In my use-case: - chat/embedding model adapters may be created frequently, sometimes to be called just once or to never be called at all - they may be used in bots sunc and async mode (not known at the moment they are created) So, I want to keep a static transport instance maintaining connection pool, so model adapters can be created and destroyed freely. But that doesn't work when both sync and async functions are in use as I can only pass one transport instance for both sync and async client, while transport types must be different for them. So I can't make both sync and async calls use shared transport with current model adapter interfaces. In this PR I add a separate `async_client_kwargs` that gets passed to async client constructor, so it will be possible to pass a separate transport instance. For sake of backwards compatibility, it is merged with `client_kwargs`, so nothing changes when it is not set. I am unable to run linter right now, but the changes look ok.