openai-php / client

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

limit on 32 messages #269

Closed kaemmi84 closed 7 months ago

kaemmi84 commented 7 months ago

`$messages = Message ::where('role', 'user') //->where('user_id', Auth::id()) ->orderBy('created_at', 'asc') ->select(['role', 'content']) ->get() ->map(function (mixed $item) { return [ 'role' => $item->role, 'content' => $item->content, ]; });

        //throw new Exception(json_encode($messages));

        $response = $this->openAIClient->threads()->createAndRun(
            [
                'assistant_id' => $this->assistantId,
                'thread' => [
                    'messages' => $messages,
                ],
            ],
        );`

on this code I became the error

OpenAI\Exceptions\ErrorException: 1 validation error for Request body -> thread -> messages ensure this value has at most 32 items (type=value_error.list.max_items; limit_value=32) in file /var/www/kaemmi/vendor/openai-php/client/src/Transporters/HttpTransporter.php on line 131

gehrisandro commented 7 months ago

Hi @kaemmi84

This is an error / limit from the OpenAI API. There is nothing the PHP client could do about this.