Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Main #175

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Closure;
use Exception;
use GuzzleHttp\Client as GuzzleClient;
use Http\Discovery\Psr18Client;
use Http\Discovery\Psr18ClientDiscovery;
use OpenAI\Transporters\HttpTransporter;
use OpenAI\ValueObjects\ApiKey;
Expand All @@ -14,7 +15,6 @@
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpClient\Psr18Client;

final class Factory
{
Expand Down Expand Up @@ -174,12 +174,12 @@ private function makeStreamHandler(ClientInterface $client): Closure
return fn (RequestInterface $request): ResponseInterface => $client->send($request, ['stream' => true]);
}

if ($client instanceof Psr18Client) { // @phpstan-ignore-line
return fn (RequestInterface $request): ResponseInterface => $client->sendRequest($request); // @phpstan-ignore-line
if ($client instanceof Psr18Client) {
return fn (RequestInterface $request): ResponseInterface => $client->sendRequest($request);
}

return function (RequestInterface $_): never {
throw new Exception('To use stream requests you must provide an stream handler closure via the OpenAI factory.');
throw new Exception('To use stream requests you must provide a stream handler closure via the OpenAI factory.');
};
}
}
}