-
Notifications
You must be signed in to change notification settings - Fork 486
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
support a custom HTTPX client in Client
and AsyncClient
#380
base: main
Are you sure you want to change the base?
Conversation
This is needed for |
Thanks for the PR. Can you provide some details in the description of why this change is necessary for |
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. |
Hi can you fix the tests? ollama-python currently targets 3.8 so the union types |
@@ -74,48 +74,54 @@ | |||
T = TypeVar('T') | |||
|
|||
|
|||
class BaseClient: | |||
class Client: | |||
@overload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These overload aren't necessary since there's no overlap between the client and non-client versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are to maintain proper typing, the point is you can't pass client
and follow_redirects
or timeout
together. These overloads mean doing so will give a typing error.
Fixed suggestions I think, by the way it would be easier for contributors and less work for you if you let tests run automatically. |
As well as allowing a custom httpx client, this also improves type safety in
Client
andAsyncClient
- previouslyself._client
implicitly had type ofNone
.