openai-php / laravel

⚡️ OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with OpenAI API
MIT License
2.82k stars 188 forks source link

[Bug]: Meta information not included in CreateResponse #102

Closed birdhouses closed 5 months ago

birdhouses commented 5 months ago

The meta information is not on the CreateResponse object. I could not find how to obtain the metainformation on a ChatCompletion response in the documentation.

Getting the metainformation only works for legacy completions, not for Chat

$client = \OpenAI::client(env('OPENAI_API_KEY'));

$response = $client->chat()->create([
                    'model' => $model,
                    'temperature' => 0,
                    'top_p' => 0,
                    'messages' => [
                        [
                            "role" => "user",
                            "content" => $generatedPrompt->prompt
                        ]
                    ],
                ]);

Log::info(json_encode($response->meta()));

Call to undefined method OpenAI\Responses\Chat\CreateResponse::meta() {"userId":1,"exception":"[object] (Error(code: 0): Call to undefined method OpenAI\\Responses\\Chat\\CreateResponse::meta()

        "openai-php/laravel": "^0.6.3",
        "php": "^8.1",
gehrisandro commented 5 months ago

Hi @birdhouses

Please upgrade to the latest version, it is available there.