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
14 changes: 12 additions & 2 deletions src/Data/ThinkingConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Gemini\Data;

use Gemini\Contracts\Arrayable;
use Gemini\Enums\ThinkingLevel;

/**
* Config for thinking features.
Expand All @@ -16,28 +17,37 @@ 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 ThinkingLevel|null $thinkingLevel Controls reasoning behavior.
*/
public function __construct(
public readonly bool $includeThoughts,
public readonly int $thinkingBudget,
public readonly ?ThinkingLevel $thinkingLevel = null,
) {}

/**
* @param array{ includeThoughts: bool, thinkingBudget: int} $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'],
thinkingLevel: $attributes['thinkingLevel'] ?? null
);
}

public function toArray(): array
{
return [
$items = [
'includeThoughts' => $this->includeThoughts,
'thinkingBudget' => $this->thinkingBudget,
];

if ($this->thinkingLevel) {
$items['thinkingLevel'] = $this->thinkingLevel->value;
}

return $items;
}
}
19 changes: 19 additions & 0 deletions src/Enums/ThinkingLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Gemini\Enums;

/**
* Controls reasoning behavior.
*
* Gemini 3 Pro: low, high
* Gemini 3 Flash: minimal, low, medium, high
*/
enum ThinkingLevel: string
{
case LOW = 'low';
case HIGH = 'high';
case MINIMAL = 'minimal';
case MEDIUM = 'medium';
}