openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.7k stars 483 forks source link

Exception OpenAI\Responses\Chat\CreateResponseMessage::__construct(): Argument #2 ($content) must be of type string, null given #189

Closed adelamarre closed 1 year ago

adelamarre commented 1 year ago

Hi, when chat gpt return a function_call message the content is null. But the constructor of CreateResponseMessage do not accept null for $content.


final class CreateResponseMessage
{
    private function __construct(
        public readonly string $role,
        public readonly string $content,
    ) {
    }

    /**
     * @param  array{role: string, content: string}  $attributes
     */
    public static function from(array $attributes): self
    {
        return new self(
            $attributes['role'],
            $attributes['content'],
        );
    }
....
}