Skip to content

Undefined 'status' Key in OpenAI Provider Response #1

@DeGraciaMathieu

Description

@DeGraciaMathieu

Hello,

It seems that the OpenAI provider has a bug when handling a simple message:

   ErrorException

  Undefined array key "status"

  at vendor/inspector-apm/neuron-ai/src/Providers/OpenAI.php:104
    100▕             ->getBody()->getContents();
    101▕
    102▕         $result = \json_decode($result, true);
    103▕
  ➜ 104▕         if ($result['status'] === 'requires_action') {
    105▕             $response = $this->createToolMessage(
    106▕                 $result['required_action']['submit_tool_outputs']['tool_calls']
    107▕             );
    108▕         } else {

By dumping the $result variable, we notice that it does not contain the "status" key, even though the call seems to have been successfully made.

array:8 [
  "id" => "[...]"
  "object" => "chat.completion"
  "created" => 1741345401
  "model" => "gpt-4o-2024-08-06"
  "choices" => array:1 [
    0 => array:4 [
      "index" => 0
      "message" => array:3 [
        "role" => "assistant"
        "content" => "Hello Valerio! How can I assist you today?"
        "refusal" => null
      ]
      "logprobs" => null
      "finish_reason" => "stop"
    ]
  ]
  "usage" => array:5 [
    "prompt_tokens" => 12
    "completion_tokens" => 12
    "total_tokens" => 24
    "prompt_tokens_details" => array:2 [
      "cached_tokens" => 0
      "audio_tokens" => 0
    ]
    "completion_tokens_details" => array:4 [
      "reasoning_tokens" => 0
      "audio_tokens" => 0
      "accepted_prediction_tokens" => 0
      "rejected_prediction_tokens" => 0
    ]
  ]
  "service_tier" => "default"
  "system_fingerprint" => "[...]"
]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions