This project demonstrates AI integration in Filament using OpenAI to automatically extract tags from job descriptions. An action button triggers OpenAI analysis, parses the response into tags, and auto-populates a Select field while creating any missing tags, providing a foundation for various AI-assisted data entry scenarios.
We have a simple form with a Multi-Select for Tags:
app/Filament/Resources/JobOffers/JobOfferResource.php
use Filament\Schemas\Schema;use Filament\Support\Icons\Heroicon;use App\Filament\Resources\JobOffers\Pages\ListJobOffers;use App\Filament\Resources\JobOffers\Pages\CreateJobOffer;use App\Filament\Resources\JobOffers\Pages\EditJobOffer;use App\Models\JobOffer;use Filament\Resources\Resource;use Filament\Tables\Table;use App\Filament\Resources\JobOffers\Schemas\JobOfferForm;use App\Filament\Resources\JobOffers\Tables\JobOffersTable; class JobOfferResource extends Resource{ protected static ?string $model = JobOffer::class; protected static string | \BackedEnum | null $navigationIcon = Heroicon::OutlinedRectangleStack; public static function form(Schema $schema): Schema { return JobOfferForm::configure($schema); } public static function table(Table $table): Table { return JobOffersTable::configure($table); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => ListJobOffers::route('/'), 'create' => CreateJobOffer::route('/create'), 'edit' => EditJobOffer::route('/{record}/edit'), ]; }}
And here we want to add a OpenAI query to extract these tags automatically using AI. So let's create our Action button: