Skip to content

Commit bea3cf8

Browse files
committed
add 2 test
1 parent 38e129f commit bea3cf8

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

tests/Fixtures/Chat.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,44 @@ function chatCompletionStreamVisionContentChunk(): array
722722
];
723723
}
724724

725+
/**
726+
* @return array<string, mixed>
727+
*/
728+
function chatCompletionReasoningContent(): array
729+
{
730+
return [
731+
'id' => 'chatcmpl-123',
732+
'object' => 'chat.completion',
733+
'created' => 1677652288,
734+
'model' => 'deepseek-reasoner',
735+
'choices' => [
736+
[
737+
'index' => 0,
738+
'message' => [
739+
'role' => 'assistant',
740+
'content' => null,
741+
'reasoning_content' => "Hello world",
742+
],
743+
'logprobs' => null,
744+
'finish_reason' => 'stop',
745+
],
746+
],
747+
'usage' => [
748+
'prompt_tokens' => 9,
749+
'completion_tokens' => 12,
750+
'total_tokens' => 21,
751+
'prompt_tokens_details' => [
752+
'cached_tokens' => 5,
753+
],
754+
'completion_tokens_details' => [
755+
'reasoning_tokens' => 12,
756+
'accepted_prediction_tokens' => 0,
757+
'rejected_prediction_tokens' => 0,
758+
],
759+
],
760+
];
761+
}
762+
725763
/**
726764
* @return resource
727765
*/

tests/Responses/Chat/CreateResponseMessage.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,24 @@
5656
->functionCall->toBeInstanceOf(CreateResponseFunctionCall::class);
5757
});
5858

59+
test('from reasoning', function () {
60+
$result = CreateResponseMessage::from(chatCompletionReasoningContent()['choices'][0]['message']);
61+
62+
expect($result)
63+
->role->toBe('assistant')
64+
->reasoningContent->toBe("Hello world")
65+
->annotations->toBeArray()
66+
->functionCall->toBeNull();
67+
});
68+
5969
test('to array', function () {
70+
$result = CreateResponseMessage::from(chatCompletionReasoningContent()['choices'][0]['message']);
71+
72+
expect($result->toArray())
73+
->toBe(chatCompletionReasoningContent()['choices'][0]['message']);
74+
});
75+
76+
test('to array from reasoning', function () {
6077
$result = CreateResponseMessage::from(chatCompletion()['choices'][0]['message']);
6178

6279
expect($result->toArray())

0 commit comments

Comments
 (0)