owlwire / filament-ai-prompter
An AI assistant prompt for Filament panels: ask questions about your data, mention records with @ and run quick actions.
Requires
- php: ^8.2
- filament/filament: ^4.0|^5.0
- prism-php/prism: ^0.103
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.0
- pestphp/pest-plugin-laravel: ^4.0|^5.0
- pestphp/pest-plugin-livewire: ^4.0|^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Filament AI Prompter
An AI assistant for your Filament panel. Ask questions about your data in plain language, mention records with @, and get answers streamed live, using any AI provider (Anthropic, OpenAI, Gemini, Mistral, Ollama, …) via Prism.
Works with any business: the assistant learns what it can access from your panel's resources and always respects your policies and tenancy.
- 💬 Chat page with streaming answers and Markdown rendering
@mentions: attach any record from your resources as context- 🎯 Scope: focus the assistant on a resource (e.g. "Orders")
- ⚡ Quick actions: one-click prompts for common questions
- 🔐 Policies, tenancy and hidden attributes respected — sensitive data never leaves your app
- 💾 The conversation survives page reloads; "New chat" asks for confirmation and can be undone
- 🌍 Bring your own API key, any provider
- 🗣️ Translated into English, Spanish, French, German, Italian, Dutch and Portuguese (pt_PT, pt_BR). The assistant always replies in the user's language.
Screenshots
AI Prompter Pro adds saved chat history, the assistant on every page with
⌘K, your own tools, usage limits and an audit log. Learn more at owlwire.github.io.
Requirements
- PHP 8.2+
- Laravel 12 or 13
- Filament 4 or 5
Installation
composer require owlwire/filament-ai-prompter php artisan filament:assets
Add your provider's API key to .env (see Prism's configuration):
ANTHROPIC_API_KEY=sk-ant-... AI_PROMPTER_PROVIDER=anthropic AI_PROMPTER_MODEL=claude-sonnet-5-5
Register the plugin in your panel provider:
use Owlwire\FilamentAiPrompter\AiPrompterPlugin; public function panel(Panel $panel): Panel { return $panel // ... ->plugin(AiPrompterPlugin::make()); }
That's it, an AI Assistant page now appears in your navigation.
Optionally publish the config and translations:
php artisan vendor:publish --tag="filament-ai-prompter-config" php artisan vendor:publish --tag="filament-ai-prompter-translations"
Configuration
use Owlwire\FilamentAiPrompter\AiPrompterPlugin; use Owlwire\FilamentAiPrompter\QuickAction; AiPrompterPlugin::make() // Any Prism provider + model ->provider('openai', 'gpt-5') ->maxTokens(4096) ->temperature(0.3) // Tell the assistant about your business ->systemPrompt(fn () => 'You are the assistant of '.filament()->getTenant()?->name.', a coffee machine retailer.') // UI ->icon(asset('images/logo.svg')) ->greeting(fn ($user) => "Hi {$user->first_name} 👋") ->placeholder('Ask about orders, customers, products…') ->quickActions([ QuickAction::make('today') ->label("Today's orders") ->icon('heroicon-o-shopping-bag') ->scope('order') ->prompt('Summarise the orders created today.'), ]) // Which resources can be mentioned with @ (default: all panel resources) ->resources([OrderResource::class, CustomerResource::class]) ->excludeResources([UserResource::class]) // Never send these attributes to the AI provider (merged with config) ->hiddenAttributes(['iban', 'tax_number']) // Access & navigation ->authorize(fn ($user) => $user->can('use-ai-assistant')) ->navigationGroup('Tools') ->navigationSort(1) ->slug('assistant');
Your own icon
The assistant shows the Owlwire owl next to the greeting and next to every answer. Replace it with your own brand:
AiPrompterPlugin::make() // An icon from any Blade Icons set... ->icon('heroicon-o-sparkles') // ...an image URL or path... ->icon(asset('images/logo.svg')) // ...raw SVG... ->icon(new HtmlString('<svg>...</svg>')) // ...or a closure, e.g. each tenant's logo ->icon(fn () => filament()->getTenant()?->logo_url) // Optional: a different icon next to answers (defaults to icon()) ->avatar(asset('images/assistant.png'));
Icons from an icon set and SVG follow your panel's colours; images are shown as they are.
Rendering the prompter anywhere
Disable the page and drop the Livewire component wherever you like (a dashboard widget, a custom page…):
AiPrompterPlugin::make()->page(false);
<livewire:owlwire-ai-prompter />
Custom context providers
Expose anything to @ mentions (documents, external APIs, …) by implementing ContextProvider:
use Owlwire\FilamentAiPrompter\Context\ContextItem; use Owlwire\FilamentAiPrompter\Context\ContextProvider; class KnowledgeBaseContext implements ContextProvider { public function getKey(): string { return 'kb'; } public function getLabel(): string { return 'Knowledge base'; } public function isAvailable(): bool { return auth()->check(); } public function search(string $query, int $limit = 5): array { return Article::search($query)->take($limit)->get() ->map(fn ($a) => new ContextItem('kb', (string) $a->id, $a->title, 'Article')) ->all(); } public function find(string $id): ?ContextItem { /* ... */ } public function resolve(string $id): ?string { return Article::find($id)?->body; } public function describeScope(int $limit): ?string { return null; } }
AiPrompterPlugin::make()->contextProviders([KnowledgeBaseContext::class]);
Tracking usage
After every answer an AnswerGenerated event is dispatched with the user, panel, tenant, provider, model, prompt, answer, the context sent and the tokens used. AnswerFailed is dispatched when the provider fails. Listen to them to log usage or costs:
use Illuminate\Support\Facades\Event; use Owlwire\FilamentAiPrompter\Events\AnswerGenerated; Event::listen(function (AnswerGenerated $event) { logger()->info('AI answer', [ 'user' => $event->user?->getAuthIdentifier(), 'model' => $event->model, 'input_tokens' => $event->usage?->promptTokens, 'output_tokens' => $event->usage?->completionTokens, ]); });
Privacy & security
- Records are fetched through each resource's
getEloquentQuery()and filtered bycanViewAny()/canView(), so users only ever send data they can already see. - Model
$hiddenattributes andhidden_attributesare never sent. - Related records are named (for example an order's customer) only when the user can view them through their own resource.
- Data is sent directly from your server to the provider you configure, with your own API key. Nothing goes through Owlwire.
Where the conversation is kept
The current conversation is stored in the Laravel session, per panel and tenant. With the cookie session driver a long conversation can exceed the browser's 4 KB cookie limit, so use the database, redis or file driver (Laravel's default is database).
Testing
composer test
composer analyse
Contributing
See CONTRIBUTING.md.
Security
Please report security vulnerabilities privately. See SECURITY.md.
License
MIT. See LICENSE.md.