<?php

namespace App\Console\Commands;

use App\Services\AI\AgentService;
use App\Models\User;
use Illuminate\Console\Command;

class TestAI extends Command
{
    protected $signature = 'ai:test {user?}';
    protected $description = 'Test AI agent with a user';

    public function handle(AgentService $agent)
    {
        $userId = $this->argument('user') ?? 1;
        $user = User::find($userId);
        if (!$user) {
            $this->error('User not found');
            return 1;
        }

        $message = $this->ask('Enter your message');
        $result = $agent->processMessage($user, $message);
        $this->info('Response: ' . $result['response']);
        $this->info('Recommendations: ' . json_encode($result['recommendations']));
        return 0;
    }
}
