openai-php / client

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

Error completions createStreamed : gpt-3.5-turbo-1106 #312

Closed reihaniz closed 8 months ago

reihaniz commented 9 months ago

Added ->withStreamHandler(fn (RequestInterface $request): ResponseInterface => $client->send($request, [ 'stream' => true ]))

then $stream = $client->completions()->createStreamed([ 'model' => 'gpt-3.5-turbo-1106', 'max_tokens' => 4096, 'temperature' => 0.3, 'messages' => [ [ 'role' => 'user', 'content' => "say huwa", ], ], 'stream' => True, ]);

got an error Fatal error: Uncaught TypeError: {closure}(): Argument #1 ($request) must be of type RequestInterface, Nyholm\Psr7\Request given, called in \vendor\openai-php\client\src\Transporters\HttpTransporter.php on line 92

gehrisandro commented 8 months ago

As the error states, you type definition is wrong:

->withStreamHandler(fn (RequestInterface $request): ResponseInterface => $client->send($request, [ 'stream' => true ]))

Yalme commented 7 months ago

As the error states, you type definition is wrong:

->withStreamHandler(fn (RequestInterface $request): ResponseInterface => $client->send($request, [ 'stream' => true ]))

Can you please explain more what your answer means? I'm getting exact same error. All code above is taken from example on project's github front page. What I need to do to solve it?