|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +use OpenAI\Responses\Chat\CreateResponseChoiceAnnotations; |
3 | 4 | use OpenAI\Responses\Chat\CreateResponseFunctionCall; |
4 | 5 | use OpenAI\Responses\Chat\CreateResponseMessage; |
5 | 6 | use OpenAI\Responses\Chat\CreateResponseToolCall; |
|
10 | 11 | expect($result) |
11 | 12 | ->role->toBe('assistant') |
12 | 13 | ->content->toBe("\n\nHello there, how may I assist you today?") |
| 14 | + ->annotations->toBeArray() |
13 | 15 | ->functionCall->toBeNull(); |
14 | 16 | }); |
15 | 17 |
|
|
19 | 21 | expect($result) |
20 | 22 | ->role->toBe('assistant') |
21 | 23 | ->content->toBeNull() |
| 24 | + ->annotations->toBeArray() |
22 | 25 | ->functionCall->toBeInstanceOf(CreateResponseFunctionCall::class); |
23 | 26 | }); |
24 | 27 |
|
|
33 | 36 | ->toolCalls->each->toBeInstanceOf(CreateResponseToolCall::class); |
34 | 37 | }); |
35 | 38 |
|
| 39 | +test('from annotations response', function () { |
| 40 | + $result = CreateResponseMessage::from(chatCompletionWithAnnotations()['choices'][0]['message']); |
| 41 | + |
| 42 | + expect($result) |
| 43 | + ->role->toBe('assistant') |
| 44 | + ->content->toBe('Hello World') |
| 45 | + ->annotations->toBeArray() |
| 46 | + ->annotations->toHaveCount(1) |
| 47 | + ->annotations->each->toBeInstanceOf(CreateResponseChoiceAnnotations::class); |
| 48 | +}); |
| 49 | + |
36 | 50 | test('from function response without content', function () { |
37 | 51 | $result = CreateResponseMessage::from(chatCompletionMessageWithFunctionAndNoContent()); |
38 | 52 |
|
|
63 | 77 | ->toBe(chatCompletionWithToolCalls()['choices'][0]['message']); |
64 | 78 | }); |
65 | 79 |
|
66 | | -test('to array from web search options response', function () { |
| 80 | +test('to array from annotations response', function () { |
67 | 81 | $result = CreateResponseMessage::from(chatCompletionWithAnnotations()['choices'][0]['message']); |
68 | 82 |
|
69 | 83 | expect($result->toArray()) |
|
0 commit comments