From 6acc205de045527b83d12c0aa1d2bb598de067fa Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Sun, 31 Mar 2024 10:54:17 -0700 Subject: [PATCH] client/ollama: install and use (*Client).HTTPClient --- client/ollama/ollama.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ollama/ollama.go b/client/ollama/ollama.go index 631d94172..b491cda57 100644 --- a/client/ollama/ollama.go +++ b/client/ollama/ollama.go @@ -36,6 +36,8 @@ var I_Acknowledge_This_API_Is_Under_Development bool type Client struct { // BaseURL is the base URL of the Ollama API. BaseURL string + + HTTPClient *http.Client // The HTTP client to use. If nil, http.DefaultClient is used. } // Build requests the remote Ollama service to build a model. It uploads any @@ -104,7 +106,8 @@ func Do[Res any](ctx context.Context, c *Client, method, path string, in any) (* return nil, err } - res, err := http.DefaultClient.Do(req) + hc := cmp.Or(c.HTTPClient, http.DefaultClient) + res, err := hc.Do(req) if err != nil { return nil, err }