* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\AI\Platform\Bridge\OpenAi\Factory; use Symfony\AI\Platform\Message\Message; use Symfony\AI\Platform\Message\MessageBag; use Symfony\AI\Platform\StructuredOutput\PlatformSubscriber; use Symfony\AI\Platform\Tests\Fixtures\StructuredOutput\MathReasoning; use Symfony\Component\EventDispatcher\EventDispatcher; require_once dirname(__DIR__).'/bootstrap.php'; $dispatcher = new EventDispatcher(); $dispatcher->addSubscriber(new PlatformSubscriber()); $platform = Factory::createPlatform(env('OPENAI_API_KEY'), http_client(), eventDispatcher: $dispatcher); $messages = new MessageBag( Message::forSystem('You are a helpful math tutor. Guide the user through the solution step by step.'), Message::ofUser('how can I solve 8x + 7 = -23'), ); $result = $platform->invoke('gpt-5-mini', $messages, ['response_format' => MathReasoning::class]); dump($result->asObject());