-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
255660f
commit 0575905
Showing
3 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
function threadRunStepResource(): array | ||
{ | ||
return [ | ||
'id' => 'step_1spQXgbAabXFm1YXrwiGIMUz', | ||
'object' => 'thread.run.step', | ||
'created_at' => 1699564106, | ||
'run_id' => 'run_fYijubpOJsKDnvtACWBS8C8r', | ||
'assistant_id' => 'asst_EopvUEMh90bxkNRYEYM81Orc', | ||
'thread_id' => 'thread_3WdOgtVuhD8aUIEx774Whkvo', | ||
'type' => 'message_creation', | ||
'status' => 'completed', | ||
'cancelled_at' => null, | ||
'completed_at' => 1699564119, | ||
'expires_at' => null, | ||
'failed_at' => null, | ||
'last_error' => null, | ||
'step_details' => [ | ||
'type' => 'message_creation', | ||
'message_creation' => [ | ||
'message_id' => 'msg_i404PxKbB92d0JAmdOIcX7vA', | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
function threadRunStepListResource(): array | ||
{ | ||
return [ | ||
'object' => 'list', | ||
'data' => [ | ||
threadRunStepResource(), | ||
threadRunStepResource(), | ||
], | ||
'first_id' => 'step_1spQXgbAabXFm1YXrwiGIMUz', | ||
'last_id' => 'step_1spQXgbAabXFm1YXrwiGIMUz', | ||
'has_more' => false, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Meta\MetaInformation; | ||
use OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepListResponse; | ||
use OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponse; | ||
use OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseMessageCreationStepDetails; | ||
use OpenAI\ValueObjects\Transporter\Response; | ||
|
||
test('list', function () { | ||
$client = mockClient('GET', 'threads/thread_agvtHUGezjTCt4SKgQg0NJ2Y/runs/run_vqUh7mLCAIYjudfN34dMQx4b/steps', [], Response::from(threadRunStepListResource(), metaHeaders())); | ||
|
||
$result = $client->threads()->runs()->steps()->list('thread_agvtHUGezjTCt4SKgQg0NJ2Y', 'run_vqUh7mLCAIYjudfN34dMQx4b'); | ||
|
||
expect($result) | ||
->toBeInstanceOf(ThreadRunStepListResponse::class) | ||
->object->toBe('list') | ||
->data->toBeArray()->toHaveCount(2) | ||
->data->each->toBeInstanceOf(ThreadRunStepResponse::class) | ||
->firstId->toBe('step_1spQXgbAabXFm1YXrwiGIMUz') | ||
->lastId->toBe('step_1spQXgbAabXFm1YXrwiGIMUz') | ||
->hasMore->toBeFalse(); | ||
|
||
expect($result->meta()) | ||
->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('retrieve', function () { | ||
$client = mockClient('GET', 'threads/thread_agvtHUGezjTCt4SKgQg0NJ2Y/runs/run_vqUh7mLCAIYjudfN34dMQx4b/steps/step_1spQXgbAabXFm1YXrwiGIMUz', [], Response::from(threadRunStepResource(), metaHeaders())); | ||
|
||
$result = $client->threads()->runs()->steps()->retrieve('thread_agvtHUGezjTCt4SKgQg0NJ2Y', 'run_vqUh7mLCAIYjudfN34dMQx4b', 'step_1spQXgbAabXFm1YXrwiGIMUz'); | ||
|
||
expect($result) | ||
->toBeInstanceOf(ThreadRunStepResponse::class) | ||
->id->toBe('step_1spQXgbAabXFm1YXrwiGIMUz') | ||
->object->toBe('thread.run.step') | ||
->createdAt->toBe(1699564106) | ||
->runId->toBe('run_fYijubpOJsKDnvtACWBS8C8r') | ||
->assistantId->toBe('asst_EopvUEMh90bxkNRYEYM81Orc') | ||
->threadId->toBe('thread_3WdOgtVuhD8aUIEx774Whkvo') | ||
->type->toBe('message_creation') | ||
->status->toBe('completed') | ||
->cancelledAt->toBeNull() | ||
->completedAt->toBe(1699564119) | ||
->expiresAt->toBeNull() | ||
->failedAt->toBeNull() | ||
->lastError->toBeNull() | ||
->stepDetails->toBeInstanceOf(ThreadRunStepResponseMessageCreationStepDetails::class); | ||
|
||
expect($result->meta()) | ||
->toBeInstanceOf(MetaInformation::class); | ||
}); |