Skip to content

Commit 1391adf

Browse files
authored
Merge pull request #161 from foremtehan/patch-1
Add ThinkingLevel enum
2 parents 37c2f15 + 5f827c5 commit 1391adf

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/Data/ThinkingConfig.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Gemini\Data;
66

77
use Gemini\Contracts\Arrayable;
8+
use Gemini\Enums\ThinkingLevel;
89

910
/**
1011
* Config for thinking features.
@@ -16,28 +17,37 @@ final class ThinkingConfig implements Arrayable
1617
/**
1718
* @param bool $includeThoughts Indicates whether to include thoughts in the response. If true, thoughts are returned only when available.
1819
* @param int $thinkingBudget The number of thoughts tokens that the model should generate.
20+
* @param ThinkingLevel|null $thinkingLevel Controls reasoning behavior.
1921
*/
2022
public function __construct(
2123
public readonly bool $includeThoughts,
2224
public readonly int $thinkingBudget,
25+
public readonly ?ThinkingLevel $thinkingLevel = null,
2326
) {}
2427

2528
/**
26-
* @param array{ includeThoughts: bool, thinkingBudget: int} $attributes
29+
* @param array{ includeThoughts: bool, thinkingBudget: int, thinkingLevel: ?ThinkingLevel} $attributes
2730
*/
2831
public static function from(array $attributes): self
2932
{
3033
return new self(
3134
includeThoughts: $attributes['includeThoughts'],
3235
thinkingBudget: $attributes['thinkingBudget'],
36+
thinkingLevel: $attributes['thinkingLevel'] ?? null
3337
);
3438
}
3539

3640
public function toArray(): array
3741
{
38-
return [
42+
$items = [
3943
'includeThoughts' => $this->includeThoughts,
4044
'thinkingBudget' => $this->thinkingBudget,
4145
];
46+
47+
if ($this->thinkingLevel) {
48+
$items['thinkingLevel'] = $this->thinkingLevel->value;
49+
}
50+
51+
return $items;
4252
}
4353
}

src/Enums/ThinkingLevel.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Gemini\Enums;
6+
7+
/**
8+
* Controls reasoning behavior.
9+
*
10+
* Gemini 3 Pro: low, high
11+
* Gemini 3 Flash: minimal, low, medium, high
12+
*/
13+
enum ThinkingLevel: string
14+
{
15+
case LOW = 'low';
16+
case HIGH = 'high';
17+
case MINIMAL = 'minimal';
18+
case MEDIUM = 'medium';
19+
}

0 commit comments

Comments
 (0)