File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ private function __construct(
29
29
public static function from (array $ headers ): self
30
30
{
31
31
$ headers = array_change_key_case ($ headers , CASE_LOWER );
32
+
32
33
$ requestId = $ headers ['x-request-id ' ][0 ] ?? null ;
33
34
34
35
$ openai = MetaInformationOpenAI::from ([
Original file line number Diff line number Diff line change @@ -30,6 +30,17 @@ function metaHeadersFromAzure(): array
30
30
];
31
31
}
32
32
33
+ function metaHeadersWithDifferentCases (): array
34
+ {
35
+ return [
36
+ 'Openai-Model ' => ['gpt-3.5-turbo-instruct ' ],
37
+ 'OPENAI-ORGANIZATION ' => ['org-1234 ' ],
38
+ 'openai-processing-ms ' => [410 ],
39
+ 'openai-version ' => ['2020-10-01 ' ],
40
+ 'x-request-id ' => ['3813fa4fa3f17bdf0d7654f0f49ebab4 ' ],
41
+ ];
42
+ }
43
+
33
44
function meta (): MetaInformation
34
45
{
35
46
return MetaInformation::from (metaHeaders ());
Original file line number Diff line number Diff line change 82
82
->openai ->processingMs ->toBeNull ();
83
83
});
84
84
85
+ test ('from response headers in different cases ' , function () {
86
+ $ meta = MetaInformation::from ((new \GuzzleHttp \Psr7 \Response (headers: metaHeadersWithDifferentCases ()))->getHeaders ());
87
+
88
+ expect ($ meta )
89
+ ->toBeInstanceOf (MetaInformation::class)
90
+ ->requestId ->toBe ('3813fa4fa3f17bdf0d7654f0f49ebab4 ' )
91
+ ->openai ->toBeInstanceOf (MetaInformationOpenAI::class)
92
+ ->openai ->model ->toBe ('gpt-3.5-turbo-instruct ' )
93
+ ->openai ->organization ->toBe ('org-1234 ' )
94
+ ->openai ->version ->toBe ('2020-10-01 ' )
95
+ ->openai ->processingMs ->toBe (410 )
96
+ ->requestLimit ->toBeNull ()
97
+ ->tokenLimit ->toBeNull ();
98
+ });
99
+
85
100
test ('as array accessible ' , function () {
86
101
$ meta = MetaInformation::from (metaHeaders ());
87
102
You can’t perform that action at this time.
0 commit comments