Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/Data/ThinkingConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
], fn ($value) => $value !== null);
}
}
2 changes: 2 additions & 0 deletions src/Enums/ThinkingLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down