PHP code example of pixelworxio / filament-ai-action
1. Go to this page and download the library: Download pixelworxio/filament-ai-action 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/ */
pixelworxio / filament-ai-action example snippets
use Pixelworxio\FilamentAiAction\FilamentAiActionPlugin;
->plugins([
FilamentAiActionPlugin::make(),
])
use Pixelworxio\FilamentAiAction\AiAction;
AiAction::make()
->agent(SummaryAgent::class)
use Pixelworxio\LaravelAiAction\Testing\FakeAgentAction;
beforeEach(fn () => FakeAgentAction::reset());
it('persists the agent result to the model column', function (): void {
FakeAgentAction::fakeResponse(SummaryAgent::class, 'This is the summary.');
$record = Post::factory()->create();
$action = AiAction::make('ai')
->agent(SummaryAgent::class)
->persistResultTo('ai_summary');
$action->record($record);
$reflection = new ReflectionMethod($action, 'runAgent');
$reflection->setAccessible(true);
$reflection->invoke($action);
expect($record->fresh()->ai_summary)->toBe('This is the summary.');
FakeAgentAction::assertAgentCalled(SummaryAgent::class, 1);
});