diff --git a/src/Testing/Responses/Concerns/Fakeable.php b/src/Testing/Responses/Concerns/Fakeable.php index 86cdb81e..d2876679 100644 --- a/src/Testing/Responses/Concerns/Fakeable.php +++ b/src/Testing/Responses/Concerns/Fakeable.php @@ -50,17 +50,17 @@ private static function buildAttributes(array $original, array $override): array public static function fakeResponseMetaInformation(): MetaInformation { return MetaInformation::from([ - 'openai-model' => 'gpt-3.5-turbo-instruct', - 'openai-organization' => 'org-1234', - 'openai-processing-ms' => '410', - 'openai-version' => '2020-10-01', - 'x-ratelimit-limit-requests' => '3000', - 'x-ratelimit-limit-tokens' => '250000', - 'x-ratelimit-remaining-requests' => '2999', - 'x-ratelimit-remaining-tokens' => '249989', - 'x-ratelimit-reset-requests' => '20ms', - 'x-ratelimit-reset-tokens' => '2ms', - 'x-request-id' => '3813fa4fa3f17bdf0d7654f0f49ebab4', + 'openai-model' => ['gpt-3.5-turbo-instruct'], + 'openai-organization' => ['org-1234'], + 'openai-processing-ms' => ['410'], + 'openai-version' => ['2020-10-01'], + 'x-ratelimit-limit-requests' => ['3000'], + 'x-ratelimit-limit-tokens' => ['250000'], + 'x-ratelimit-remaining-requests' => ['2999'], + 'x-ratelimit-remaining-tokens' => ['249989'], + 'x-ratelimit-reset-requests' => ['20ms'], + 'x-ratelimit-reset-tokens' => ['2ms'], + 'x-request-id' => ['3813fa4fa3f17bdf0d7654f0f49ebab4'], ]); } } diff --git a/tests/Testing/ClientFake.php b/tests/Testing/ClientFake.php index ca1abec2..e9fb459c 100644 --- a/tests/Testing/ClientFake.php +++ b/tests/Testing/ClientFake.php @@ -24,6 +24,30 @@ expect($completion['choices'][0]['text'])->toBe('awesome!'); }); +it('returns fake meta data', function () { + $fake = new ClientFake([ + CreateResponse::fake(), + ]); + + $completion = $fake->completions()->create([ + 'model' => 'gpt-3.5-turbo-instruct', + 'prompt' => 'PHP is ', + ]); + + expect($completion->meta()) + ->requestId->toBe('3813fa4fa3f17bdf0d7654f0f49ebab4') + ->openai->model->toBe('gpt-3.5-turbo-instruct') + ->openai->organization->toBe('org-1234') + ->openai->processingMs->toBe(410) + ->openai->version->toBe('2020-10-01') + ->requestLimit->limit->toBe(3000) + ->requestLimit->remaining->toBe(2999) + ->requestLimit->reset->toBe('20ms') + ->tokenLimit->limit->toBe(250000) + ->tokenLimit->remaining->toBe(249989) + ->tokenLimit->reset->toBe('2ms'); +}); + it('throws fake exceptions', function () { $fake = new ClientFake([ new \OpenAI\Exceptions\ErrorException([