feature: Use PSR-18 compatible wrapper for Laravel HTTP client#127
feature: Use PSR-18 compatible wrapper for Laravel HTTP client#127dshafik wants to merge 1 commit into
Conversation
|
I'm a bit nervous that we move our implementation to a 3rd party wrapper package. It seems my argument is more with Laravel on why their HTTP Client isn't PSR-18 compatible. When we saw the last implementation (https://github.com/gehrisandro/laravel-http-psr18) of wrapping Laravel/HTTP it had some issues. I wonder what we are looking at in terms of stability. Is this package basically done forever, barring a major Guzzle change? It seems PSR-18 is set and Guzzle probably isn't changing until a major. |
iBotPeaches
left a comment
There was a problem hiding this comment.
I finally sat down to try this out and I'm sorry for the delay. I wanted to check to ensure no regressions.
Anytime I used an endpoint that was streamed, it crashed. This might have poked a hole in our testing if nothing failed, yet fails in real usage.
To use stream requests you must provide an stream handler closure via the OpenAI factory.
at /home/xxx/Desktop/Projects/PHP/openai-client/src/Factory.php:201
197▕ return fn (RequestInterface $request): ResponseInterface => $client->sendRequest($request); // @phpstan-ignore-line
198▕ }
199▕
200▕ return function (RequestInterface $_): never {
➜ 201▕ throw new Exception('To use stream requests you must provide an stream handler closure via the OpenAI factory.');
202▕ };
203▕ }
204▕ }
205▕
```
I was trying to review OpenAI requests using Telescope which captures requests made using the Laravel HTTP Client, however this integration uses Guzzle directly.
The OpenAI PHP library supports any PSR-18 compatible client, so I pulled in
swisnl/laravel-psr-http-client-bridgewhich is a PSR-18 compatible wrapper around the Laravel HTTP Client and used that instead of Guzzle directly.This change allows the requests to show up in Telescope as expected.