forked from google-gemini-php/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThinkingConfig.php
More file actions
48 lines (42 loc) · 1.52 KB
/
ThinkingConfig.php
File metadata and controls
48 lines (42 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace Gemini\Data;
use Gemini\Contracts\Arrayable;
use Gemini\Enums\ThinkingLevel;
/**
* Config for thinking features.
*
* https://ai.google.dev/api/generate-content#ThinkingConfig
*/
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|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 = null,
public readonly ?ThinkingLevel $thinkingLevel = null,
) {}
/**
* @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'] ?? null,
thinkingLevel: $attributes['thinkingLevel'] ?? null
);
}
public function toArray(): array
{
return array_filter([
'includeThoughts' => $this->includeThoughts,
'thinkingBudget' => $this->thinkingBudget,
'thinkingLevel' => $this->thinkingLevel?->value,
], fn ($value) => $value !== null);
}
}