Skip to content

Commit 511aaa3

Browse files
authored
Merge pull request #162 from foremtehan/patch-2
Make thinkingBudget optional in ThinkingConfig
2 parents 1391adf + fc5a326 commit 511aaa3

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/Data/ThinkingConfig.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,33 @@ final class ThinkingConfig implements Arrayable
1616
{
1717
/**
1818
* @param bool $includeThoughts Indicates whether to include thoughts in the response. If true, thoughts are returned only when available.
19-
* @param int $thinkingBudget The number of thoughts tokens that the model should generate.
19+
* @param int|null $thinkingBudget The number of thoughts tokens that the model should generate.
2020
* @param ThinkingLevel|null $thinkingLevel Controls reasoning behavior.
2121
*/
2222
public function __construct(
2323
public readonly bool $includeThoughts,
24-
public readonly int $thinkingBudget,
24+
public readonly ?int $thinkingBudget = null,
2525
public readonly ?ThinkingLevel $thinkingLevel = null,
2626
) {}
2727

2828
/**
29-
* @param array{ includeThoughts: bool, thinkingBudget: int, thinkingLevel: ?ThinkingLevel} $attributes
29+
* @param array{ includeThoughts: bool, thinkingBudget?: int, thinkingLevel?: ?ThinkingLevel} $attributes
3030
*/
3131
public static function from(array $attributes): self
3232
{
3333
return new self(
3434
includeThoughts: $attributes['includeThoughts'],
35-
thinkingBudget: $attributes['thinkingBudget'],
35+
thinkingBudget: $attributes['thinkingBudget'] ?? null,
3636
thinkingLevel: $attributes['thinkingLevel'] ?? null
3737
);
3838
}
3939

4040
public function toArray(): array
4141
{
42-
$items = [
42+
return array_filter([
4343
'includeThoughts' => $this->includeThoughts,
4444
'thinkingBudget' => $this->thinkingBudget,
45-
];
46-
47-
if ($this->thinkingLevel) {
48-
$items['thinkingLevel'] = $this->thinkingLevel->value;
49-
}
50-
51-
return $items;
45+
'thinkingLevel' => $this->thinkingLevel?->value,
46+
], fn ($value) => $value !== null);
5247
}
5348
}

src/Enums/ThinkingLevel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*
1010
* Gemini 3 Pro: low, high
1111
* Gemini 3 Flash: minimal, low, medium, high
12+
*
13+
* https://ai.google.dev/gemini-api/docs/thinking#thinking-levels
1214
*/
1315
enum ThinkingLevel: string
1416
{

0 commit comments

Comments
 (0)