Skip to content

pixelworxio/ai-action-testbench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Action Testbench

A manual UI testing environment for pixelworxio/laravel-ai-action (core) and pixelworxio/filament-ai-action (Filament plugin).

What this repo is

This testbench demonstrates the package split concretely through two intentionally contrasted examples:

  • Example 1 — A Filament v5 resource (PostResource) that uses AiAction from filament-ai-action. This shows the Filament plugin doing its job: streaming modals, persistResultTo, withUserInstruction, and AgentResultEntry in an infolist.
  • Example 2 — A standalone Livewire v4 component (SubscriptionDetail) that uses RunAgentAction directly from laravel-ai-action. No AiAction, no Filament UI, no modal. Just the core package working in a plain Laravel + Livewire context with structured output rendered inline.

Setup

git clone <this-repo> ai-action-testbench
cd ai-action-testbench
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate --seed
php artisan serve

The SQLite database is committed and pre-seeded, so migrate --seed will populate it. Log in with test@example.com / password.

Example 1 — Filament Post Resource

Example 1 - Filament Post Resource

  1. Navigate to Posts in the sidebar
  2. Click the Summarize (sparkle) action on any table row
  3. A streaming modal appears with the AI summary
  4. Posts with an existing summary show a gold sparkle icon in the table
  5. Click View on a post to see the AgentResultEntry infolist displaying the persisted summary

This example uses pixelworxio/filament-ai-action. The AiAction is configured as a table row action on PostResource:

AiAction::make('summarize')
    ->agent(SummarizePostAgent::class)
    ->stream()
    ->withUserInstruction('Focus on anything specific? (optional)')
    ->persistResultTo('ai_summary')

Example 2 — Standalone Livewire Subscription Detail

Example 2 - Subscriptions List

Example 2 - Subscription Detail

Example 2 - Subscription Detail

  1. Navigate to Subscriptions in the sidebar
  2. Click any company name to open the detail page
  3. Click Analyze Churn Risk or Re-Analyze — the button shows a spinner while $analyzing is true
  4. The structured risk assessment appears inline with score, level badge, recommended action, rationale, and churn signals
  5. Pre-assessed subscriptions already show results on both the index and detail pages
  6. Re-analyze the subscription. Notice the default fake response.
  7. Update the repo with your api keys.
  8. Comment out the app binding in AppServiceProvider
  9. Re-analyze a subscription. Notice a complete analysis is returned (after a moment).

This example uses pixelworxio/laravel-ai-action directly — no Filament involved. RunAgentAction is injected via Livewire v4 method injection:

public function analyzeRisk(RunAgentAction $runner): void
{
    $result = $runner->execute(new SubscriptionRiskAgent(), $context);
    $this->subscription->update(['ai_risk_assessment' => $result->structured]);
    $this->subscription->refresh();
}

Switching to real AI responses

By default, FakeAgentAction is bound in AppServiceProvider so the app works without any API key. To use real Anthropic responses:

  1. Add your API key to .env:
    ANTHROPIC_API_KEY=sk-ant-...
    
  2. Comment out the $this->app->bind(...) block in AppServiceProvider::register()

The app will then make real calls to claude-sonnet-4-20250514 for both examples.

Switching AI Provider & Model

  1. Edit config/ai-action.php to set your default provider and model
  2. Add the respective api keys to .env

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages