-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Follow-up to #2, and pending WordPress/php-ai-client#100: We need to ensure the WordPress_HTTP_Client supports streaming responses.
Unfortunately, WordPress (and its Requests library) do not support this. So we'll need to likely come with our own implementation (e.g. use Guzzle) that still ties in with the WordPress way to make requests as much as possible.
This will mean duplicating quite a bit of WordPress Core code that isn't properly abstracted out. But that may be the lesser evil of the alternative of trying to properly build support for response streaming into WordPress Core, which would be subject to several bottlenecks (e.g. the Requests library has barely any active maintenance).
For additional context, see this comment: #2 (comment)
Also, adding some references for how I solved this in the AI Services plugin for WordPress, using Guzzle under the hood while keeping things WordPress-y otherwise (most importantly run the necessary hooks):
- https://github.com/felixarntz/ai-services/blob/main/includes/Services/HTTP/HTTP_With_Streams.php
- Relevant base class (which has most of the WordPress Core duplicated logic): https://github.com/felixarntz/wp-oop-plugin-lib/blob/main/src/HTTP/HTTP.php