<?php
/**
 * Test WebChat API
 */

require_once __DIR__ . '/app/config/config.php';
require_once __DIR__ . '/app/api/webchat.php';

echo "Testing WebChat Service...\n\n";

// Test 1: Get Model Config
echo "1. Testing getModelConfig()...\n";
$chatService = new WebChatService();
$reflection = new ReflectionClass($chatService);
$method = $reflection->getMethod('getModelConfig');
$method->setAccessible(true);
$config = $method->invoke($chatService);

echo "Config: " . json_encode($config, JSON_PRETTY_PRINT) . "\n\n";

// Test 2: Test chat
echo "2. Testing chat()...\n";
try {
    $result = $chatService->chat(1, "Hello, test message", null);
    echo "Result: " . json_encode($result, JSON_PRETTY_PRINT) . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "Trace: " . $e->getTraceAsString() . "\n";
}
