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

Exceptions should have more detailed information, like what was the RESPONSE text. #402

Open pavelthq opened 1 month ago

pavelthq commented 1 month ago

https://github.com/openai-php/client/blob/7b5652b5e107b04b67aa5bc6560acf162ef2be97/src/Transporters/HttpTransporter.php#L63

JsonException: Syntax error in /var/www/html/chatgpt/vendor/openai-php/client/src/Transporters/HttpTransporter.php:61

Next OpenAI\Exceptions\UnserializableResponse: Syntax error in /var/www/html/chatgpt/vendor/openai-php/client/src/Transporters/HttpTransporter.php:63 Stack trace:

0 /var/www/html/chatgpt/vendor/openai-php/client/src/Resources/Chat.php(33): OpenAI\Transporters\HttpTransporter->requestObject()

1 /var/www/html/chatgpt/app/Jobs/RequestItemGpt.php(159): OpenAI\Resources\Chat->create()

gehrisandro commented 1 month ago

@pavelthq Good idea. Could you make a PR?

Radiergummi commented 1 week ago

How about adding the request and response instances to the exception?