From 547b117aaab51e891babf2694f8b5d6b992d9191 Mon Sep 17 00:00:00 2001 From: rema424 Date: Fri, 11 Jul 2025 18:03:33 +0900 Subject: [PATCH 1/3] fix: clarify HTTP client variable in factory example The example in the README was using an undefined $client variable within the withStreamHandler method. This change explicitly defines the $client variable when configuring withHttpClient to make the example clearer and prevent potential confusion. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a501f03..10107d4 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ $client = Gemini::factory() ->withBaseUrl('https://generativelanguage.example.com/v1beta') // default: https://generativelanguage.googleapis.com/v1beta/ ->withHttpHeader('X-My-Header', 'foo') ->withQueryParam('my-param', 'bar') - ->withHttpClient(new \GuzzleHttp\Client([])) // default: HTTP client found using PSR-18 HTTP Client Discovery + ->withHttpClient($client = new \GuzzleHttp\Client([])) // default: HTTP client found using PSR-18 HTTP Client Discovery ->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $client->send($request, [ 'stream' => true // Allows to provide a custom stream handler for the http client. ])) From c32658696deccac07efe771a9635942ac3f664bb Mon Sep 17 00:00:00 2001 From: rema424 Date: Fri, 11 Jul 2025 18:15:35 +0900 Subject: [PATCH 2/3] refactor: rename client variable to guzzleClient for clarity Renamed the HTTP client variable from $client to $guzzleClient to avoid confusion with the Gemini client instance and make the code example more explicit about which client is being referenced. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10107d4..a973ada 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,8 @@ $client = Gemini::factory() ->withBaseUrl('https://generativelanguage.example.com/v1beta') // default: https://generativelanguage.googleapis.com/v1beta/ ->withHttpHeader('X-My-Header', 'foo') ->withQueryParam('my-param', 'bar') - ->withHttpClient($client = new \GuzzleHttp\Client([])) // default: HTTP client found using PSR-18 HTTP Client Discovery - ->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $client->send($request, [ + ->withHttpClient($guzzleClient = new \GuzzleHttp\Client([])) // default: HTTP client found using PSR-18 HTTP Client Discovery + ->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $guzzleClient->send($request, [ 'stream' => true // Allows to provide a custom stream handler for the http client. ])) ->make(); From ca4a549498c4a9e4f001662bc60bfd799e89c2ae Mon Sep 17 00:00:00 2001 From: rema424 Date: Fri, 11 Jul 2025 18:16:56 +0900 Subject: [PATCH 3/3] docs: add timeout configuration to HTTP client example Added a timeout configuration to the Guzzle client example to demonstrate best practices for HTTP client configuration. This helps users understand how to configure client options properly. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a973ada..4d1488b 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ $client = Gemini::factory() ->withBaseUrl('https://generativelanguage.example.com/v1beta') // default: https://generativelanguage.googleapis.com/v1beta/ ->withHttpHeader('X-My-Header', 'foo') ->withQueryParam('my-param', 'bar') - ->withHttpClient($guzzleClient = new \GuzzleHttp\Client([])) // default: HTTP client found using PSR-18 HTTP Client Discovery + ->withHttpClient($guzzleClient = new \GuzzleHttp\Client(['timeout' => 30])) // default: HTTP client found using PSR-18 HTTP Client Discovery ->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $guzzleClient->send($request, [ 'stream' => true // Allows to provide a custom stream handler for the http client. ]))