/**
 * Test Grok function calling / tool use
 */
import { callGrok4Fast } from '../src/lib/chat';

async function main() {
  // Test queries that should trigger tool calls
  const testQueries = [
    'What are the live NBA scores right now?',
    'What team does LeBron James play for?',
    'Backtest home underdogs strategy for NBA 2026 season'
  ];

  for (const query of testQueries) {
    console.log('\n' + '='.repeat(60));
    console.log(`Query: "${query}"`);
    console.log('='.repeat(60));

    try {
      const result = await callGrok4Fast(query, 'sports');

      console.log('\nResponse (first 500 chars):');
      console.log(result?.message?.content?.substring(0, 500));

      if (result?.backtestResults) {
        console.log('\nBacktest data attached:', {
          totalBets: result.backtestResults.totalBets,
          wins: result.backtestResults.wins
        });
      }
    } catch (error: any) {
      console.error('Error:', error.message);
    }

    // Small delay between queries
    await new Promise(r => setTimeout(r, 1000));
  }
}

main().catch(console.error);
