bobbingwide / oik-ai

OIK AI - the new
GNU General Public License v3.0
0 stars 0 forks source link

Cater for common exceptions from OpenAI PHP client #11

Open bobbingwide opened 4 months ago

bobbingwide commented 4 months ago

The OpenAI PHP client is not particularly forgiving. Rather than return the errors from OpenAI it generates exceptions. I got this exception when attempting to generate an image for "Search bing"

Fatal error: Uncaught OpenAI\Exceptions\ErrorException: Your request was rejected as a result of our safety system. Your prompt may contain text that is not allowed by our safety system. in C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Transporters\HttpTransporter.php:133

Stack trace: 
#0 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Transporters\HttpTransporter.php(57): OpenAI\Transporters\HttpTransporter->throwIfJsonError(Array, '{\n "error": {\n...') 
#1 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Resources\Images.php(30): OpenAI\Transporters\HttpTransporter->requestObject(Object(OpenAI\ValueObjects\Transporter\Payload)) 
#2 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\classes\class-Oik-AI.php(162): OpenAI\Resources\Images->create(Array) #3 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\classes\class-ai.php(266): Oik_AI->image_data('') 
#4 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\classes\class-ai.php(253): AI->get_image('1024x1024')
 #5 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\classes\class-ai.php(122): AI->perform_get_image() 
#6 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\ai.php(26): AI->process_form() 
#7 {main} thrown in C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Transporters\HttpTransporter.php on line 133

Requirement

bobbingwide commented 4 months ago

Another one: Fatal error: Uncaught OpenAI\Exceptions\ErrorException: Billing hard limit has been reached in

bobbingwide commented 4 months ago

Another one: Bad Gateway - received twice when attempting to generate an image.

bobbingwide commented 3 months ago

Fatal error: Uncaught OpenAI\Exceptions\ErrorException: The input prompt cannot be handled by the engine.