AI agent guidance for the Platform component.
Unified abstraction for AI platforms (OpenAI, Anthropic, Azure, Gemini, VertexAI, Ollama, etc.). Provides consistent interfaces regardless of provider.
- Platform: Main entry point implementing
PlatformInterface - Model: AI models with provider-specific configurations
- Contract: Abstract contracts for AI capabilities (chat, embedding, speech)
- Message: Message system for AI interactions
- Template: Message templating with pluggable rendering strategies
- Tool: Function calling capabilities
- Bridge: Provider-specific implementations
src/Bridge/: Provider implementationssrc/Contract/: Abstract contracts and interfacessrc/Message/: Message handling system with Template supportsrc/Message/TemplateRenderer/: Template rendering strategiessrc/Tool/: Function calling and tool definitionssrc/Result/: Result types and converterssrc/Exception/: Platform-specific exceptions
Bridge implementations for:
- OpenAI (GPT, DALL-E, Whisper)
- Anthropic (Claude models)
- Azure OpenAI
- Google Gemini, VertexAI
- AWS Bedrock, Ollama
- Many others (see composer.json)
vendor/bin/phpunit
vendor/bin/phpunit tests/ModelTest.php
vendor/bin/phpunit --coverage-html coveragevendor/bin/phpstan analyse
cd ../../.. && vendor/bin/php-cs-fixer fix src/platform/composer install
composer updateTemplates support variable substitution with type-based rendering. SystemMessage and UserMessage support templates.
use Symfony\AI\Platform\Message\Message;
use Symfony\AI\Platform\Message\MessageBag;
use Symfony\AI\Platform\Message\Template;
// SystemMessage with template
$template = Template::string('You are a {role} assistant.');
$message = Message::forSystem($template);
// UserMessage with template
$message = Message::ofUser(Template::string('Calculate {operation}'));
// Multiple messages with templates
$messages = new MessageBag(
Message::forSystem(Template::string('You are a {role} assistant.')),
Message::ofUser(Template::string('Calculate {operation}'))
);
$result = $platform->invoke('gpt-4o-mini', $messages, [
'template_vars' => [
'role' => 'helpful',
'operation' => '2 + 2',
],
]);
// Expression template (requires symfony/expression-language)
$template = Template::expression('price * quantity');Rendering happens externally during Platform.invoke() when template_vars option is provided.
- PHPUnit 11+ with strict configuration
- Test fixtures in
../../fixturesfor multimodal content - MockHttpClient pattern preferred
- Follows Symfony coding standards
- Bridge pattern for provider implementations
- Consistent contract interfaces across providers
- Template system uses type-based rendering (not renderer injection)
- Template rendering via TemplateRendererListener during invocation