sferra/filament-side-chat

Sidechat plugin for Filament — uses sferra/delta for streaming SSE communication with AI providers

Maintainers

Package info

github.com/FelipeSferra/filament-side-chat

Type:filament-plugin

pkg:composer/sferra/filament-side-chat

Transparency log

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.5.0 2026-08-03 19:09 UTC

This package is auto-updated.

Last update: 2026-08-04 13:09:45 UTC


README

AI-powered chat assistant for Filament admin panels. Adds a sidebar chat button that opens a slide-over modal with real-time SSE streaming via sferra/delta.

Installation

composer require sferra/filament-side-chat

Publish and run the migration:

php artisan vendor:publish --tag=filament-side-chat-migrations
php artisan migrate

Setup

1. Configure the Delta provider

Add your AI provider credentials to .env:

DELTA_URL=http://localhost:8642/v1/chat/completions
DELTA_KEY=my-api-key
DELTA_MODEL=hermes-agent

See sferra/delta for all supported providers (OpenAI, Ollama, OpenCode, vLLM, etc.).

2. Register the plugin

In your AppPanelProvider.php:

use Sferra\FilamentSideChat\FilamentSideChatPlugin;

->plugin(
    FilamentSideChatPlugin::make()
        ->icon('heroicon-o-chat-bubble-left-right')
)

That's it. A chat button appears in the Filament topbar.

Features

  • ✅ Slide-over modal with AI chat
  • ✅ Real-time streaming via SSE
  • ✅ Multi-session support — switch between conversations
  • ✅ Session deletion with confirmation dialog
  • ✅ Chat history persisted to the database
  • ✅ Cancel streaming button
  • ✅ Copy response button
  • ✅ Export conversation as Markdown
  • ✅ Resend / edit user messages
  • Context-aware assistant — auto-injects user identity, current Filament page, and custom blocks into a system prompt on every request
  • ✅ Configurable icon, assistant name and render hook
  • ✅ Works with any OpenAI-compatible API

Configuration

Fluent methods (Panel Provider)

FilamentSideChatPlugin::make()
    ->icon('heroicon-o-chat-bubble-left-right')   // topbar button icon
    ->assistantIcon('heroicon-o-computer-desktop') // assistant avatar icon
    ->assistantName('Assistente')                  // modal heading title

Context-aware assistant

On every Delta::stream() call, the plugin prepends a role: system message so the model knows who is asking and from where. Nothing is persisted — the system message lives only in the request payload.

What's injected by default

  • User identity — id, name, email
  • Page state — current Filament panel, resource class, record id, route name
  • Custom blocks — any closures registered via ->context(...)

Toggles (master + granular)

FilamentSideChatPlugin::make()
    ->includeContext(true)        // master switch (default true)
    ->includeUserContext(true)    // inject user identity (default true)
    ->includePageContext(true)    // inject page state (default true)
    ->context(fn () => [
        'Empresa ativa' => session('active_company_name'),
        'Permissões'    => auth()->user()?->getAllPermissions()->pluck('name')->implode(', '),
    ])
    ->systemPromptPrefix('Responda sempre em português brasileiro.');

Pass null to context() to clear all custom providers:

FilamentSideChatPlugin::make()->context(null);

Custom system prompt via Markdown file

Publish the stub:

php artisan vendor:publish --tag=filament-side-chat-stubs

Edit resources/ai/system-context.md (path is configurable). The {auto_context} placeholder is replaced with the auto-generated block (user + page + custom providers):

# Assistente do {panel}

Você é o assistente do painel administrativo.

# Regras
- Responda em PT-BR.
- Não exponha dados sensíveis.

{auto_context}

Activate it with:

FilamentSideChatPlugin::make()
    ->systemContextFile('resources/ai/system-context.md');
// ->systemContextTemplate(true)  // default — substitutes {auto_context}

Disable everything (use only your own prompt)

FilamentSideChatPlugin::make()
    ->includeContext(false)
    ->systemPromptPrefix('Você é um assistente. Responda em PT-BR.');

Config keys (all overridable per ENV)

FILAMENT_SIDE_CHAT_CONTEXT_ENABLED=true
FILAMENT_SIDE_CHAT_CONTEXT_USER=true
FILAMENT_SIDE_CHAT_CONTEXT_PAGE=true
FILAMENT_SIDE_CHAT_CONTEXT_FILE=resources/ai/system-context.md
FILAMENT_SIDE_CHAT_CONTEXT_TEMPLATE=true
FILAMENT_SIDE_CHAT_CONTEXT_PREFIX=

Multiple panels: if you have more than one Filament panel and each one registers a different context config, the last-registered panel wins (since the config() values are global). In that case, prefer the config file or FILAMENT_SIDE_CHAT_CONTEXT_* env vars instead of the fluent setters.

Config file

Publish the config file:

php artisan vendor:publish --tag=filament-side-chat-config
// config/filament-side-chat.php
return [
    'icon'            => 'heroicon-o-chat-bubble-left-right',
    'assistant_icon'  => 'heroicon-o-computer-desktop',
    'assistant_name'  => 'Assistente',
    'render_hook'     => \Filament\View\PanelsRenderHook::TOPBAR_END,
];

Fluent methods take precedence over the config file.

Customization

Change the render position

use Filament\View\PanelsRenderHook;

FilamentSideChatPlugin::make()
    ->renderHook(PanelsRenderHook::USER_MENU_BEFORE)

Publish and customize views

php artisan vendor:publish --tag=filament-side-chat-views

Publish the system context stub

php artisan vendor:publish --tag=filament-side-chat-stubs

Requirements

  • PHP ^8.2
  • Laravel ^11|^12|^13
  • Filament ^3.0|^4.0|^5.0
  • sferra/delta ^1.0

License

MIT