Closed RhydianJenkins closed 5 months ago
I'm currently trying to create a fake streamed response which should return some string like "This is a test response".
Here's my what I've tried:
<?php use OpenAI\Responses\Chat\CreateStreamedResponse; use OpenAI\Testing\ClientFake; require __DIR__ . '/vendor/autoload.php'; $handle = fopen('php://memory', 'r+'); fwrite($handle, "This is a test response.\n"); rewind($handle); $client = new ClientFake([ CreateStreamedResponse::fake($handle), ]); $client->chat()->createStreamed([ 'model' => 'gpt-3.5-turbo', 'messages' => [ [ 'role' => 'user', 'content' => 'Hello', ], ], ]);
For some reason, the fake streamed response is swallowing the "This is a test response\n" and not outputting anything.
Is this intended behaviour? Thanks
Solved.
I needed to provide the full json encoded strong from the open ai response :facepalm:
I'm currently trying to create a fake streamed response which should return some string like "This is a test response".
Here's my what I've tried:
For some reason, the fake streamed response is swallowing the "This is a test response\n" and not outputting anything.
Is this intended behaviour? Thanks