From 5d34c7de2b54f1e3a96c45e56259c88820120f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Sun, 29 Jun 2025 01:56:22 +0200 Subject: [PATCH] fix: Async response not instanceof ImageResponse in example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ```php assert($response instanceof ImageResponse); // ❌ ``` The response is an AsyncResponse that wraps a ImageResponse (and forwards methods and properties via __call and __get) but the assertion fails. Not sure how to show this simply in the example code. --- examples/openai/image-output-dall-e-3.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/openai/image-output-dall-e-3.php b/examples/openai/image-output-dall-e-3.php index 6747834b9..45462a7b9 100644 --- a/examples/openai/image-output-dall-e-3.php +++ b/examples/openai/image-output-dall-e-3.php @@ -12,6 +12,7 @@ use Symfony\AI\Platform\Bridge\OpenAI\DallE; use Symfony\AI\Platform\Bridge\OpenAI\DallE\ImageResponse; use Symfony\AI\Platform\Bridge\OpenAI\PlatformFactory; +use Symfony\AI\Platform\Response\AsyncResponse; use Symfony\Component\Dotenv\Dotenv; require_once dirname(__DIR__).'/vendor/autoload.php'; @@ -32,9 +33,14 @@ ], ); -assert($response instanceof ImageResponse); +if ($response instanceof AsyncResponse) { + echo 'This is an async response. Please wait for the completion...'.\PHP_EOL; -echo 'Revised Prompt: '.$response->revisedPrompt.\PHP_EOL.\PHP_EOL; + $innerResponse = $response->unwrap(); + assert($innerResponse instanceof ImageResponse); +} + +echo 'Revised Prompt: '.$innerResponse->revisedPrompt.\PHP_EOL.\PHP_EOL; foreach ($response->getContent() as $index => $image) { echo 'Image '.$index.': '.$image->url.\PHP_EOL;