From 75cecf78e1bb14f7c401ebf07ae779531437ed84 Mon Sep 17 00:00:00 2001 From: foremtehan <53290883+foremtehan@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:12:10 -0500 Subject: [PATCH 1/6] Make thinkingBudget optional in ThinkingConfig --- src/Data/ThinkingConfig.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Data/ThinkingConfig.php b/src/Data/ThinkingConfig.php index 750978c..719f2fa 100644 --- a/src/Data/ThinkingConfig.php +++ b/src/Data/ThinkingConfig.php @@ -16,38 +16,33 @@ final class ThinkingConfig implements Arrayable { /** * @param bool $includeThoughts Indicates whether to include thoughts in the response. If true, thoughts are returned only when available. - * @param int $thinkingBudget The number of thoughts tokens that the model should generate. + * @param int|null $thinkingBudget The number of thoughts tokens that the model should generate. * @param ThinkingLevel|null $thinkingLevel Controls reasoning behavior. */ public function __construct( public readonly bool $includeThoughts, - public readonly int $thinkingBudget, + public readonly ?int $thinkingBudget = null, public readonly ?ThinkingLevel $thinkingLevel = null, ) {} /** - * @param array{ includeThoughts: bool, thinkingBudget: int, thinkingLevel: ?ThinkingLevel} $attributes + * @param array{ includeThoughts: bool, thinkingBudget?: int, thinkingLevel?: ?ThinkingLevel} $attributes */ public static function from(array $attributes): self { return new self( includeThoughts: $attributes['includeThoughts'], - thinkingBudget: $attributes['thinkingBudget'], + thinkingBudget: $attributes['thinkingBudget'] ?? null, thinkingLevel: $attributes['thinkingLevel'] ?? null ); } public function toArray(): array { - $items = [ + return array_filter([ 'includeThoughts' => $this->includeThoughts, 'thinkingBudget' => $this->thinkingBudget, - ]; - - if ($this->thinkingLevel) { - $items['thinkingLevel'] = $this->thinkingLevel->value; - } - - return $items; + 'thinkingLevel' => $this->thinkingLevel?->value, + ]); } } From f07edee96ea28fce046d5394508b0be6044a2551 Mon Sep 17 00:00:00 2001 From: foremtehan <53290883+foremtehan@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:15:02 -0500 Subject: [PATCH 2/6] Add documentation link to ThinkingLevel enum Added documentation link for thinking levels. --- src/Enums/ThinkingLevel.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Enums/ThinkingLevel.php b/src/Enums/ThinkingLevel.php index 355a091..afcf092 100644 --- a/src/Enums/ThinkingLevel.php +++ b/src/Enums/ThinkingLevel.php @@ -9,6 +9,8 @@ * * Gemini 3 Pro: low, high * Gemini 3 Flash: minimal, low, medium, high + * + * https://ai.google.dev/gemini-api/docs/thinking#thinking-levels */ enum ThinkingLevel: string { From 10dce5aa542613bdc13a1a45442490a8c5b265ac Mon Sep 17 00:00:00 2001 From: foremtehan <53290883+foremtehan@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:17:39 -0500 Subject: [PATCH 3/6] Refactor from method in ThinkingConfig Refactor from method to return filtered attributes. --- src/Data/ThinkingConfig.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Data/ThinkingConfig.php b/src/Data/ThinkingConfig.php index 719f2fa..a732a1e 100644 --- a/src/Data/ThinkingConfig.php +++ b/src/Data/ThinkingConfig.php @@ -30,11 +30,11 @@ public function __construct( */ public static function from(array $attributes): self { - return new self( - includeThoughts: $attributes['includeThoughts'], - thinkingBudget: $attributes['thinkingBudget'] ?? null, - thinkingLevel: $attributes['thinkingLevel'] ?? null - ); + return array_filter([ + 'includeThoughts' => $this->includeThoughts, + 'thinkingBudget' => $this->thinkingBudget, + 'thinkingLevel' => $this->thinkingLevel?->value, + ], fn($value) => $value !== null); } public function toArray(): array From e51a2a9c820a818099d3911fc75acf410f1ed944 Mon Sep 17 00:00:00 2001 From: foremtehan <53290883+foremtehan@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:18:27 -0500 Subject: [PATCH 4/6] Refactor from method to use constructor --- src/Data/ThinkingConfig.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Data/ThinkingConfig.php b/src/Data/ThinkingConfig.php index a732a1e..719f2fa 100644 --- a/src/Data/ThinkingConfig.php +++ b/src/Data/ThinkingConfig.php @@ -30,11 +30,11 @@ public function __construct( */ public static function from(array $attributes): self { - return array_filter([ - 'includeThoughts' => $this->includeThoughts, - 'thinkingBudget' => $this->thinkingBudget, - 'thinkingLevel' => $this->thinkingLevel?->value, - ], fn($value) => $value !== null); + return new self( + includeThoughts: $attributes['includeThoughts'], + thinkingBudget: $attributes['thinkingBudget'] ?? null, + thinkingLevel: $attributes['thinkingLevel'] ?? null + ); } public function toArray(): array From 667b9398224fc5f96e84a501d521739f33cd7dab Mon Sep 17 00:00:00 2001 From: foremtehan <53290883+foremtehan@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:19:07 -0500 Subject: [PATCH 5/6] Update ThinkingConfig.php --- src/Data/ThinkingConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/ThinkingConfig.php b/src/Data/ThinkingConfig.php index 719f2fa..dfb4780 100644 --- a/src/Data/ThinkingConfig.php +++ b/src/Data/ThinkingConfig.php @@ -43,6 +43,6 @@ public function toArray(): array 'includeThoughts' => $this->includeThoughts, 'thinkingBudget' => $this->thinkingBudget, 'thinkingLevel' => $this->thinkingLevel?->value, - ]); + ], fn($value) => $value !== null); } } From fc5a326c062fa0fef422b48c7d798fe0612b4737 Mon Sep 17 00:00:00 2001 From: foremtehan <53290883+foremtehan@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:21:38 -0500 Subject: [PATCH 6/6] Fix spacing in array_filter callback function --- src/Data/ThinkingConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/ThinkingConfig.php b/src/Data/ThinkingConfig.php index dfb4780..8377b77 100644 --- a/src/Data/ThinkingConfig.php +++ b/src/Data/ThinkingConfig.php @@ -43,6 +43,6 @@ public function toArray(): array 'includeThoughts' => $this->includeThoughts, 'thinkingBudget' => $this->thinkingBudget, 'thinkingLevel' => $this->thinkingLevel?->value, - ], fn($value) => $value !== null); + ], fn ($value) => $value !== null); } }