codewithngoni/filament-ask-ai

Adds AI-power on Filament forms fields.

v1.0.0 2025-04-30 09:59 UTC

This package is auto-updated.

Last update: 2025-04-30 10:44:50 UTC


README

Filament Ask AI is a Laravel package that adds AI-powered hint actions to Filament form fields. It integrates with AI models (like Mistral, Gemini, and Claude) to provide a "hint action" in your form fields, allowing users to interact with AI directly within your Laravel Filament forms.

Latest Version on Packagist

Total Downloads

Installation

To install the package, run the following command:

composer require codewithngoni/filament-ask-ai

Usage

After installing, run the package installation command:

php artisan vendor:publish --tag=filament-ask-ai-config

This command will:

Publish the configuration file for Filament AI settings.

Publish the configuration file for openai-php/laravel settings.

Create a symbolic link for storage.

We use Gemini and Mistral for API keys. Add the following to your .env file:

MISTRAL_API_KEY=your_mistral_api_key
GEMINI_API_KEY=your_gemini_api_key

Configuration

You can configure the AI keys by modifying the config/filament-ask-ai.php file. Ensure that the correct API keys for Mistral, Gemini, and Claude are set.

Usage for Developers

Adding AI to Built-in Filament Form Fields You can add AI generation capabilities to TextInput, Textarea, and RichEditor fields using the AskMistral(), AskGemini(), or AskClaude() methods:

Without Options

use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\RichEditor;

TextInput::make('title')
    ->AskMistral()

Textarea::make('description')
    ->AskGemini()

With Options

TextInput::make('title')
    ->AskMistral([
        'model' => 'mistral-large-latest',
        'temperature' => 0.7,
    ])

Textarea::make('description')
    ->AskGemini([
        'model' => 'gemini-2.0-flash',
        'max_tokens' => 200,
    ])

RichEditor::make('content')
    ->AskClaude([
        'model' => 'claude-2',
        'temperature' => 0.8,
    ])

Credits

License

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