Filament CMS with actions in Post Edit page that use AI capabilities: create a tweet, suggest title options, translate post text, generate image thumbnail.
The system is built around AI Agents that plug into Filament actions. When a user edits a post, they can trigger AI-powered actions from the toolbar:
app/Filament/Actions/SuggestTitleAction.php
$context = filled($record->title) ? "Current title: {$record->title}\n\nPost body:\n{$record->body}" : "Post body:\n{$record->body}"; $response = (new TitleSuggesterAgent(customInstructions: $customPrompt))->prompt( $context, provider: static::resolveProvider($data), model: static::resolveModel($data),);
Each agent implements the Laravel AI SDK Agent contract and defines its own system instructions:
app/Ai/Agents/TitleSuggesterAgent.php
class TitleSuggesterAgent implements Agent{ use Promptable; public function __construct(public ?string $customInstructions = null) {} public function instructions(): Stringable|string { if ($this->customInstructions) { return $this->customInstructions; } return SystemPrompt::query() ->where('operation', 'title-suggester') ->value('prompt') ?? 'You are a blog title expert. Given a blog post body...'; }}
The user picks a provider and model from a dropdown (only configured providers are shown), the agent calls the...