openai-php / client

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

[Bug]: /vendor/openai-php/client/src/Transporters/HttpTransporter.php(61): json_decode() #341

Open chengxs1994 opened 4 months ago

chengxs1994 commented 4 months ago

Description

When the content returned by openai is not JSON,/vendor/openai php/client/src/Transporters/HttpTransporter. php (61): will throw an exception, but we cannot obtain the specific content by capturing the DeserializableResponse

Could we add the contents attribute to the UnserializableResponse class?

Steps To Reproduce

try {
    /** @var array{error?: array{message: string, type: string, code: string}} $data */
    $data = json_decode($contents, true, flags: JSON_THROW_ON_ERROR);
} catch (JsonException $jsonException) {
    throw new UnserializableResponse($jsonException);
}

OpenAI PHP Client Version

v0.8.1

PHP Version

8.1

Notes

No response