8000 Add test for Chat/CreateResponse faking with "function_call" · openai-php/client@6bc5f1e · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bc5f1e

Browse files
committed
Add test for Chat/CreateResponse faking with "function_call"
1 parent 3173e08 commit 6bc5f1e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Responses/Chat/CreateResponse.php

Lines changed: 24 additions & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,27 @@
7171
->message->content->toBe('Hi, there!')
7272
->message->role->toBe('assistant');
7373
});
74+
75+
test('fake with function call', function () {
76+
$response = CreateResponse::fake([
77+
'id' => 'chatcmpl-111',
78+
'choices' => [
79+
[
80+
'message' => [
81+
'function_call' => [
82+
'name' => 'get_current_weather',
83+
'arguments' => "{\n \"location\": \"Boston, MA\"\n}",
84+
],
85+
],
86+
'finish_reason' => 'function_call',
87+
],
88+
],
89+
]);
90+
91+
expect($response)
92+
->id->toBe('chatcmpl-111')
93+
->and($response->choices[0])
94+
->message->functionCall->name->toBe('get_current_weather')
95+
->message->functionCall->arguments->toBe("{\n \"location\": \"Boston, MA\"\n}")
96+
->finishReason->toBe('function_call');
97+
});

0 commit comments

Comments
 (0)
0