Closed contactlutforrahman closed 1 year ago
Are you on 0.6.4+?
I was just going to post this issue. This solution was generated by ChatGPT:
It looks like the OpenAI API response may not always include the 'transient' key, leading to a "Undefined array key 'transient'" warning when the PHP client tries to access it directly. Also, the constructor of the TranscriptionResponseSegment class strictly requires a bool for the $transient parameter, leading to a "TypeError" when null is provided if 'transient' key is not present.
Here is an alternative way to handle the absence of the 'transient' key, while also ensuring that $transient is of type bool:
// In the file: /vendor/openai-php/client/src/Responses/Audio/TranscriptionResponseSegment.php
public static function from(array $attributes): self
{
$transient = $attributes['transient'] ?? false;
return new self(
$attributes['id'],
$attributes['seek'],
$attributes['start'],
$attributes['end'],
$attributes['text'],
$attributes['tokens'],
$attributes['temperature'],
$attributes['avg_logprob'],
$attributes['compression_ratio'],
$attributes['no_speech_prob'],
(bool) $transient
);
}
This manual adjustment worked on my end. It's a bit ugly, but it works.
It should also be solved by upgrading
Suddenly I'm getting this error - Undefined array key "transient"
Here's my code: