openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.57k stars 466 forks source link

[Bug]: Metadata cannot be obtained properly when using Azure AI #295

Closed rkgo55 closed 6 months ago

rkgo55 commented 6 months ago

Description

Hello, this library always helps me

The metadata is retrieved from the header, but it doesn't seem to be parsed properly. The azure AI header looks like this: (notice: The type is different from that of openAI)

array:14 [ // vendor/openai-php/client/src/Responses/Meta/MetaInformation.php:31
~ Omitted ~
  "x-ratelimit-remaining-requests" => array:1 [
    0 => INT
  ]
  "x-ratelimit-remaining-tokens" => array:1 [
    0 => INT
  ]
~ Omitted ~
]

Steps To Reproduce

$response = $client->chat()->create([ 'messages' => [ ['role' => 'system', 'content' => 'hello'], ], ]);

OpenAI PHP Client Version

0.8.0

PHP Version

8.1.13

Notes

No response

rkgo55 commented 6 months ago

For those who are having trouble with this bug You can avoid it using the method below. https://github.com/openai-php/client/issues/218#issuecomment-1748755876

gehrisandro commented 6 months ago

Fixed https://github.com/openai-php/client/pull/307