Skip to content

Commit 48e247f

Browse files
committed
test: augment tests for annotations
1 parent 4924a07 commit 48e247f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

tests/Fixtures/Chat.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function chatCompletionWithAnnotations(): array
246246
'id' => 'chatcmpl-123',
247247
'object' => 'chat.completion',
248248
'created' => 1677652288,
249-
'model' => 'gpt-4o-preview',
249+
'model' => 'gpt-4o-mini-search-preview',
250250
'choices' => [
251251
[
252252
'index' => 0,

tests/Responses/Chat/CreateResponseChoiceAnnotationsUrlCitationsTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use OpenAI\Responses\Chat\CreateResponseChoiceAnnotationsUrlCitations;
44

55
it('from', function () {
6-
76
$result = CreateResponseChoiceAnnotationsUrlCitations::from(chatCompletionWithAnnotations()['choices'][0]['message']['annotations'][0]['url_citation']);
87

98
expect($result)

tests/Responses/Chat/CreateResponseMessage.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use OpenAI\Responses\Chat\CreateResponseChoiceAnnotations;
34
use OpenAI\Responses\Chat\CreateResponseFunctionCall;
45
use OpenAI\Responses\Chat\CreateResponseMessage;
56
use OpenAI\Responses\Chat\CreateResponseToolCall;
@@ -10,6 +11,7 @@
1011
expect($result)
1112
->role->toBe('assistant')
1213
->content->toBe("\n\nHello there, how may I assist you today?")
14+
->annotations->toBeArray()
1315
->functionCall->toBeNull();
1416
});
1517

@@ -19,6 +21,7 @@
1921
expect($result)
2022
->role->toBe('assistant')
2123
->content->toBeNull()
24+
->annotations->toBeArray()
2225
->functionCall->toBeInstanceOf(CreateResponseFunctionCall::class);
2326
});
2427

@@ -33,6 +36,17 @@
3336
->toolCalls->each->toBeInstanceOf(CreateResponseToolCall::class);
3437
});
3538

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+
3650
test('from function response without content', function () {
3751
$result = CreateResponseMessage::from(chatCompletionMessageWithFunctionAndNoContent());
3852

@@ -63,7 +77,7 @@
6377
->toBe(chatCompletionWithToolCalls()['choices'][0]['message']);
6478
});
6579

66-
test('to array from web search options response', function () {
80+
test('to array from annotations response', function () {
6781
$result = CreateResponseMessage::from(chatCompletionWithAnnotations()['choices'][0]['message']);
6882

6983
expect($result->toArray())

0 commit comments

Comments
 (0)