Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined array key "openai-version" #201

Closed
TarikHusovicContentoo opened this issue Aug 30, 2023 · 5 comments
Closed

Undefined array key "openai-version" #201

TarikHusovicContentoo opened this issue Aug 30, 2023 · 5 comments

Comments

@TarikHusovicContentoo
Copy link

TarikHusovicContentoo commented Aug 30, 2023

After upgrading to version 0.7.1 I get the following message.

My call that call the API is:

`$client = OpenAI::factory()
                ->withBaseUri($this->azureOpenAiUrl)
                ->withHttpHeader('api-key', $this->azureOpenAiKey)
                ->withQueryParam('api-version', $this->azureOpenAiVersion)
                ->make();
            $settings = array_merge($settings, ['prompt' => $prompt]);
            $results = $client->completions()->create($settings);

ErrorException {#1365 // app/Services/OpenAIService.php:311 #message: "Undefined array key "openai-version"" #code: 0 #file: "/home/labs/vendor/openai-php/client/src/Responses/Meta/MetaInformation.php" #line: 36 #severity: E_WARNING trace: { /home/labs/vendor/openai-php/client/src/Responses/Meta/MetaInformation.php:36 { Illuminate\Foundation\Bootstrap\HandleExceptions->handleError($level, $message, $file = '', $line = 0, $context = []) … › 'organization' => $headers['openai-organization'][0] ?? null, › 'version' => $headers['openai-version'][0], › 'processingMs' => (int) $headers['openai-processing-ms'][0], } /home/labs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:270 { Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure} … › return fn (...$arguments) => static::$app › ? $this->{$method}(...$arguments) › : false; } /home/labs/vendor/openai-php/client/src/Responses/Meta/MetaInformation.php:36 { OpenAI\Responses\Meta\MetaInformation::from(array $headers): self … › 'organization' => $headers['openai-organization'][0] ?? null, › 'version' => $headers['openai-version'][0], › 'processingMs' => (int) $headers['openai-processing-ms'][0], }....

Same thing happens on chat resource. I have tried with gpt3 and gpt4 models.

@gehrisandro
Copy link
Collaborator

Hi @TarikHusovicContentoo

Looks like OpenAI on Azure does not return the same headers as the standard API. I try to figure out what the differences are and how to tackle them.
If you could provide a dump of all the HTTP-Headers returned, this would be helpful.

Meanwhile the only thing you can do is to downgrade to v0.6.X

@TarikHusovicContentoo
Copy link
Author

@gehrisandro Hi, thanks for the response. Here are the headers from the completions endpoint over Azure:

`-headers: array:14 [
"cache-control" => array:1 [
  0 => "no-cache, must-revalidate"
]
"content-length" => array:1 [
  0 => "2273"
]
"content-type" => array:1 [
  0 => "application/json"
]
"access-control-allow-origin" => array:1 [
  0 => "*"
]
"apim-request-id" => array:1 [
  0 => "72631d56-85a9-498d-b885-346af53d59e6"
]
"strict-transport-security" => array:1 [
  0 => "max-age=31536000; includeSubDomains; preload"
]
"x-ms-region" => array:1 [
  0 => "East US"
]
"x-content-type-options" => array:1 [
  0 => "nosniff"
]
"openai-model" => array:1 [
  0 => "text-davinci-003"
]
"openai-processing-ms" => array:1 [
  0 => "3482.8264"
]
"x-accel-buffering" => array:1 [
  0 => "no"
]
"x-ms-client-request-id" => array:1 [
  0 => "72631d56-85a9-498d-b885-346af53d59e6"
]
"x-request-id" => array:1 [
  0 => "a2896998-e276-4466-ac0e-5a211a8ecd3e"
]
"date" => array:1 [
  0 => "Thu, 31 Aug 2023 09:34:33 GMT"
]

]
headerNames: array:14 [
"cache-control" => "cache-control"
"content-length" => "content-length"
"content-type" => "content-type"
"access-control-allow-origin" => "access-control-allow-origin"
"apim-request-id" => "apim-request-id"
"strict-transport-security" => "strict-transport-security"
"x-ms-region" => "x-ms-region"
"x-content-type-options" => "x-content-type-options"
"openai-model" => "openai-model"
"openai-processing-ms" => "openai-processing-ms"
"x-accel-buffering" => "x-accel-buffering"
"x-ms-client-request-id" => "x-ms-client-request-id"
"x-request-id" => "x-request-id"
"date" => "date"
]`

And we cannot used the 0.6.* version as for the chat endpoint response 'content' is always expected and throws an error when there is no content in the response. It was fixed in 0.7.0 with ?? null addition.

@gehrisandro
Copy link
Collaborator

Thank you @TarikHusovicContentoo

I am going to make a new release which fixes this issue in the next couple of hours.

@gehrisandro
Copy link
Collaborator

gehrisandro commented Aug 31, 2023

Fixed in v0.7.2

@TarikHusovicContentoo could you please provide a feedback if this now works for you?

@TarikHusovicContentoo
Copy link
Author

@gehrisandro Works like a charm, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants