PHP code example of hayderhatem / filament-natural-language-filter
1. Go to this page and download the library: Download hayderhatem/filament-natural-language-filter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hayderhatem / filament-natural-language-filter example snippets
use HayderHatem\FilamentNaturalLanguageFilter\Filters\NaturalLanguageFilter;
public function table(Table $table): Table
{
return $table
->columns([
// your columns
])
->filters([
NaturalLanguageFilter::make()
->availableColumns([
'id',
'name',
'email',
'status',
'created_at',
'updated_at'
])
]);
}
NaturalLanguageFilter::make()
->availableColumns(['name', 'email', 'status'])
->submitSearch() // Users press Enter to search
NaturalLanguageFilter::make()
->availableColumns(['name', 'email', 'status'])
->liveSearch() // Search happens automatically as user types
NaturalLanguageFilter::make()
->availableColumns(['name', 'email', 'status'])
->searchMode('live') // or 'submit'
// config/filament-natural-language-filter.php
return [
'model' => 'gpt-3.5-turbo', // OpenAI model
'openai' => [
'api_key' => env('OPENAI_API_KEY'),
'max_tokens' => 500,
'temperature' => 0.1,
],
'cache' => [
'enabled' => true,
'ttl' => 3600, // 1 hour
],
'languages' => [
'universal_support' => true,
'auto_detect_direction' => true,
'preserve_original_values' => true,
],
];