PHPackages                             gwhthompson/filament-ai-forms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gwhthompson/filament-ai-forms

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gwhthompson/filament-ai-forms
=============================

AI-powered form generation for Filament v4/v5 using Laravel AI SDK

v2.0.0(2mo ago)0130MITPHPPHP ^8.3CI passing

Since Dec 18Pushed 2mo agoCompare

[ Source](https://github.com/gwhthompson/filament-ai-forms)[ Packagist](https://packagist.org/packages/gwhthompson/filament-ai-forms)[ Docs](https://github.com/gwhthompson/filament-ai-forms)[ RSS](/packages/gwhthompson-filament-ai-forms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (21)Versions (5)Used By (0)

Filament AI Forms
=================

[](#filament-ai-forms)

[![Latest Version on Packagist](https://camo.githubusercontent.com/33751bdb8029a7c70ab832c6ecba71ee286c655dd0e6fd93c384379d60148d9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67776874686f6d70736f6e2f66696c616d656e742d61692d666f726d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gwhthompson/filament-ai-forms)[![codecov](https://camo.githubusercontent.com/7165be9dda3ed43549ff75d85b0927f3c41b9973445dfb0c25aee0e56fdc0e70/68747470733a2f2f636f6465636f762e696f2f67682f67776874686f6d70736f6e2f66696c616d656e742d61692d666f726d732f6272616e63682f6d61696e2f67726170682f62616467652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/gwhthompson/filament-ai-forms)[![PHPStan](https://camo.githubusercontent.com/49415074f7c9796f46c46e6f43e9ed901cb3ad6451a9ff2003055841dcce11cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![License](https://camo.githubusercontent.com/fbd284ad8c9e1f24102642df7620fcd102b0c4b9334e92dd9ac646a1dea2857b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f67776874686f6d70736f6e2f66696c616d656e742d61692d666f726d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gwhthompson/filament-ai-forms)

AI-powered form generation for Filament, built on the Laravel AI SDK.

Describe what each field represents with `aiSchema()`. An AI agent fills them in. Your field types and validation rules act as constraints, so you always get valid data back.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11+
- Filament v4+
- [Laravel AI SDK](https://github.com/laravel/ai)

Installation
------------

[](#installation)

```
composer require gwhthompson/filament-ai-forms
```

Publish the config file:

```
php artisan vendor:publish --tag="filament-ai-forms-config"
```

Register the plugin in your panel provider:

```
use Gwhthompson\FilamentAiForms\FilamentAiFormsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(FilamentAiFormsPlugin::make());
}
```

Quick Start
-----------

[](#quick-start)

Mark fields with `aiSchema()` and add `AiGenerateAction` to your page:

```
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Gwhthompson\FilamentAiForms\Actions\AiGenerateAction;

public static function form(Form $form): Form
{
    return $form->schema([
        TextInput::make('name')
            ->aiSchema(description: 'The company name'),

        Textarea::make('description')
            ->aiSchema(
                description: 'A marketing description',
                prompt: 'Write 2-3 sentences',
            ),
    ]);
}

protected function getHeaderActions(): array
{
    return [
        AiGenerateAction::make(),
    ];
}
```

The action opens a wizard: select fields, generate, review, then accept or reject each value.

Configuration
-------------

[](#configuration)

```
// config/filament-ai-forms.php

return [
    'agents' => [
        'generation' => env('AI_FORMS_GENERATION_AGENT'),
        'chat' => env('AI_FORMS_CHAT_AGENT'),
    ],
    'logging' => [
        'enabled' => env('AI_FORMS_LOGGING', true),
        'path' => storage_path('logs/ai-generation'),
    ],
];
```

Env varPurpose`AI_FORMS_GENERATION_AGENT`Agent class for bulk generation`AI_FORMS_CHAT_AGENT`Agent class for chat refinement`AI_FORMS_LOGGING`Enable/disable generation logging (default: `true`)You can also set agents on the plugin directly:

```
FilamentAiFormsPlugin::make()
    ->agent(MyGenerationAgent::class)
    ->chatAgent(MyChatAgent::class)
```

aiSchema Parameters
-------------------

[](#aischema-parameters)

ParameterTypeDefaultPurpose`enabled`bool`true`Enable/disable generation for this field`description`string`null`What this field represents`prompt`string`null`Instructions for the agent`required`bool`true`Whether the agent must fill this field`examples`array`[]`Example values to guide output`pattern`string`null`Regex pattern constraintAiGenerateAction
----------------

[](#aigenerateaction)

Bulk-generate multiple fields at once. Add it as a header action or form action.

MethodPurpose`agent(string|Closure)`Custom agent class`systemPrompt(string|Closure)`System instructions`contextProvider(Closure)`Pass context data (URLs, etc.)`beforeGeneration(Closure)`Pre-generation hook`afterGeneration(Closure)`Post-generation hook`logEnabled(bool)`Enable/disable logging`tools(array)`Pass tools to default agent (e.g., WebSearch)`logPath(string)`Custom log path```
AiGenerateAction::make()
    ->systemPrompt('You are a business data specialist.')
    ->contextProvider(fn ($action) => [
        'url' => $action->getRecord()->website_url,
    ])
```

AiChatAction
------------

[](#aichataction)

Refine a single field through a chat interface. Add it as a suffix action on any field.

MethodPurpose`agent(string|Closure)`Custom agent class`systemPrompt(string|Closure)`System instructions`initialPrompt(string|Closure)`Pre-fill the chat input`contextPrompt(string|Closure)`Additional context```
Textarea::make('bio')
    ->aiSchema(description: 'Professional biography')
    ->suffixAction(
        AiChatAction::make()
            ->systemPrompt('You are a professional copywriter.')
            ->initialPrompt('Help me write a compelling bio')
    )
```

Custom Agents
-------------

[](#custom-agents)

Agents use the Laravel AI SDK. Configure model, provider, and temperature with PHP attributes.

```
use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Contracts\HasStructuredOutput;
use Laravel\Ai\Contracts\HasTools;
use Laravel\Ai\Promptable;
use Laravel\Ai\Attributes\Provider;
use Laravel\Ai\Attributes\Model;
use Laravel\Ai\Attributes\Temperature;

#[Provider('openai')]
#[Model('gpt-4o')]
#[Temperature(0.1)]
class MyGenerationAgent implements Agent, HasStructuredOutput, HasTools
{
    use Promptable;

    public function tools(): array
    {
        return [
            new \Laravel\Ai\Tools\WebSearch,
        ];
    }
}
```

Key interfaces:

- `HasStructuredOutput` -- for generation agents (returns typed data)
- `Conversational` -- for chat agents (maintains message history)
- `HasTools` -- adds tool usage (web search, web fetch, etc.)
- `HasMiddleware` -- adds middleware to the agent pipeline

Agent resolution order: action-level `->agent()` &gt; plugin-level `->agent()` &gt; config value &gt; built-in default.

Testing
-------

[](#testing)

The Laravel AI SDK provides test helpers to fake agent responses:

```
use Laravel\Ai\Facades\Agent;

Agent::fake([
    ['name' => 'Acme Corp', 'description' => 'A test company'],
]);

// ... trigger the action ...

Agent::assertPrompted(fn ($prompt) => str_contains($prompt, 'company name'));
```

Use `Agent::preventStrayPrompts()` to catch unexpected agent calls in your test suite.

How It Works
------------

[](#how-it-works)

The package converts your Filament form schema into a JSON schema that the agent follows. Your Laravel validation rules (required, max length, enum values) become constraints in that schema. The agent returns structured data matching your field types, and you review each value before it touches the form.

Custom Themes
-------------

[](#custom-themes)

If you have a custom Filament theme, add the package views to your theme's `@source` directive:

```
@source '../../../../vendor/gwhthompson/filament-ai-forms/resources/views';
```

The chat interface uses named CSS classes (`fi-ai-chat-*`) for easy customisation:

```
/* Custom user bubble colour */
.fi-ai-chat-message-user .fi-ai-chat-message-content {
    @apply bg-indigo-600;
}

/* Hide delete buttons */
.fi-ai-chat-message-delete-btn {
    @apply hidden;
}
```

Credits
-------

[](#credits)

- [George Thompson](https://github.com/gwhthompson)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance87

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Total

4

Last Release

62d ago

Major Versions

v1.1.0 → v2.0.02026-03-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/a90a51f914928afc199daa8bc616198958f2cc55624ebc3bd3bcef6c3e835e69?d=identicon)[gwhthompson](/maintainers/gwhthompson)

---

Top Contributors

[![gwhthompson](https://avatars.githubusercontent.com/u/84133262?v=4)](https://github.com/gwhthompson "gwhthompson (9 commits)")

---

Tags

laravelaiFormsfilamentagentsstructured-outputs

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/gwhthompson-filament-ai-forms/health.svg)

```
[![Health](https://phpackages.com/badges/gwhthompson-filament-ai-forms/health.svg)](https://phpackages.com/packages/gwhthompson-filament-ai-forms)
```

###  Alternatives

[pboivin/filament-peek

Full-screen page preview modal for Filament

253319.6k12](/packages/pboivin-filament-peek)[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

15828.6k](/packages/relaticle-custom-fields)[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

124139.3k2](/packages/dotswan-filament-map-picker)[defstudio/filament-searchable-input

A searchable autocomplete input for Filament forms

3212.4k](/packages/defstudio-filament-searchable-input)[jibaymcs/filament-tour

Bring the power of DriverJs to your Filament panels and start a tour !

12247.8k](/packages/jibaymcs-filament-tour)[aymanalhattami/filament-context-menu

context menu (right click menu) for filament

9838.0k](/packages/aymanalhattami-filament-context-menu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
