Closed tomirons closed 1 year ago
Hi @tomirons
Thank you for raising the issue and your PR.
I made another PR #134 which solves the problem in a more generic way.
Am I right when I assume that the content type is application/json
instead of application/json; charset=utf-8
. Currently I am not able to reproduce the issue by myself.
@gehrisandro yeah, the content type I've been seeing when debugging this is just application/json
.
I'm having the same issue today. Thanks for reporting @tomirons.
Hi, I just encountered this when openAI was returning a content_filtered error. It would be really nice to know if there was an error on the completion call and then what type of error it was.
To help, here's the completion response on this error:
CATEGORY:array(1) { ["error"]=> array(5) { ["message"]=> string(265) "The response was filtered due to the prompt triggering Azure OpenAI’s content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766" ["type"]=> NULL ["param"]=> string(6) "prompt" ["code"]=> string(14) "content_filter" ["status"]=> int(400) } }
I have a similar issue... pls help: got the ErrorException Undefined array key "choices" in prompt
$client = \OpenAI::client(getenv('OPENAI_API_KEY'));
$result_text = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => 'Analyse this text and give me sentiment of the context on a scale between -1.0 and 1.0 just as decimal without spaces and consider context about Ukraine and Russland or war or death as very negative: ' . $this->article->text,
This has been fixed in the latest version: 0.5.3
Hi I am using the newest version 0.6.1 and still having this:
[2023-06-17 09:09:12] production.ERROR: Undefined array key "choices" {"exception":"[object] (ErrorException(code: 0): Undefined array key \"choices\" at /home/forge/app.deeply.cz/vendor/openai-php/client/src/Responses/Chat/CreateStreamedResponse.php:44) [stacktrace]
any idea? thanks a lot
I'm currently using v0.5.2.
When using the chat completions, I keep getting the following exception when there is a server error on OpenAI's side.
While debugging I came across this line.
Why does it check the charset? Is that required?
If I remove the charset part, then the following exception is thrown which I would expect.