File tree Expand file tree Collapse file tree
src/Responses/Responses/Output/WebSearch
tests/Responses/Responses/Output Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use OpenAI \Testing \Responses \Concerns \Fakeable ;
1010
1111/**
12- * @phpstan-type WebSearchActionSourcesType array{type: 'url', url: string}
12+ * @phpstan-type WebSearchActionSourcesType array{type: 'url', url: string|null }
1313 *
1414 * @implements ResponseContract<WebSearchActionSourcesType>
1515 */
@@ -27,7 +27,7 @@ final class OutputWebSearchActionSources implements ResponseContract
2727 */
2828 private function __construct (
2929 public readonly string $ type ,
30- public readonly string $ url
30+ public readonly ? string $ url
3131 ) {}
3232
3333 /**
@@ -37,7 +37,7 @@ public static function from(array $attributes): self
3737 {
3838 return new self (
3939 type: $ attributes ['type ' ],
40- url: $ attributes ['url ' ],
40+ url: $ attributes ['url ' ] ?? null ,
4141 );
4242 }
4343
Original file line number Diff line number Diff line change 100100 ->not ->toHaveKey ('query ' )
101101 ->not ->toHaveKey ('sources ' );
102102});
103+
104+ test ('from with source without url ' , function () {
105+ $ payload = outputWebSearchToolCall ();
106+ $ payload ['action ' ]['sources ' ] = [
107+ ['type ' => 'url ' ],
108+ ];
109+
110+ $ response = OutputWebSearchToolCall::from ($ payload );
111+
112+ expect ($ response )
113+ ->toBeInstanceOf (OutputWebSearchToolCall::class)
114+ ->action ->sources ->toHaveCount (1 );
115+
116+ expect ($ response ->action ->sources [0 ])
117+ ->type ->toBe ('url ' )
118+ ->url ->toBeNull ();
119+ });
You can’t perform that action at this time.
0 commit comments