@@ -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}
0 commit comments