import { PrismaClient } from '@prisma/client'; import * as dotenv from 'dotenv'; import axios from 'axios'; dotenv.config(); // BigInt serialization fix (BigInt.prototype as any).toJSON = function () { return this.toString(); }; const prisma = new PrismaClient(); const matchId = '30gnuehy43on5orc9n3sh8pw4'; // Valencia vs Celta Vigo - HT/FT test async function getPrediction() { console.log('šŸ”® VQWEN v3 PREDICTION'); console.log('='.repeat(80)); // Fetch match from database const match = await prisma.liveMatch.findUnique({ where: { id: matchId }, include: { homeTeam: true, awayTeam: true, league: true, }, }); if (!match) { console.log(`āŒ Match not found: ${matchId}`); await prisma.$disconnect(); return; } console.log(`\nšŸ“Š ${match.homeTeam?.name} vs ${match.awayTeam?.name}`); console.log(`šŸ† League: ${match.league?.name}`); console.log(`šŸ“… Match Time: ${new Date(Number(match.mstUtc)).toISOString()}`); console.log(`šŸ“ Status: ${match.state} / ${match.substate}`); // Check data availability console.log(`\nšŸ“¦ DATA CHECK:`); console.log(` Odds: ${match.odds ? 'āœ…' : 'āŒ'}`); console.log(` Lineups: ${match.lineups ? 'āœ…' : 'āŒ'}`); console.log(` Sidelined: ${match.sidelined ? 'āœ…' : 'āŒ'}`); console.log(` Referee: ${match.refereeName || 'N/A'}`); // Send prediction request const aiEngineUrl = 'http://localhost:8007'; const predictionUrl = `${aiEngineUrl}/v20plus/analyze/${matchId}`; console.log(`\nšŸ¤– Sending to AI Engine...`); const startTime = Date.now(); const response = await axios.post(predictionUrl, {}, { timeout: 120000, }); const elapsed = ((Date.now() - startTime) / 1000).toFixed(2); console.log(`āœ… Prediction received in ${elapsed}s\n`); const pkg = response.data; // Print full JSON console.log('='.repeat(80)); console.log('šŸ“Š FULL PREDICTION JSON:'); console.log('='.repeat(80)); console.log(JSON.stringify(pkg, null, 2)); // Summary console.log(`\n${'='.repeat(80)}`); console.log('šŸŽÆ PREDICTION SUMMARY:'); console.log('='.repeat(80)); const dq = pkg.data_quality; console.log(`\nšŸ“¦ Data Quality: ${dq.label} (${dq.score})`); console.log(` Home lineup: ${dq.home_lineup_count}`); console.log(` Away lineup: ${dq.away_lineup_count}`); console.log(` Source: ${dq.lineup_source}`); const eb = pkg.engine_breakdown; console.log(`\nšŸ“ˆ Engine Signals:`); console.log(` Team: ${eb.team}%`); console.log(` Player: ${eb.player}%`); console.log(` Odds: ${eb.odds}%`); console.log(` Referee: ${eb.referee}%`); const mp = pkg.main_pick; console.log(`\nšŸ„‡ Main Pick:`); console.log(` Market: ${mp.market}`); console.log(` Pick: ${mp.pick}`); console.log(` Confidence: ${mp.confidence}%`); console.log(` Odds: ${mp.odds}`); console.log(` Edge: ${(mp.edge * 100).toFixed(2)}%`); console.log(` Grade: ${mp.bet_grade}`); console.log(` Playable: ${mp.playable}`); console.log(` Stake: ${mp.stake_units} units`); if (pkg.value_pick) { const vp = pkg.value_pick; console.log(`\nšŸ’Ž Value Pick:`); console.log(` Market: ${vp.market}`); console.log(` Pick: ${vp.pick}`); console.log(` Confidence: ${vp.confidence}%`); console.log(` Odds: ${vp.odds}`); console.log(` Edge: ${(vp.edge * 100).toFixed(2)}%`); } const sp = pkg.score_prediction; console.log(`\n⚽ Score Prediction:`); console.log(` FT: ${sp.ft}`); console.log(` HT: ${sp.ht}`); console.log(` xG: ${sp.xg_home} - ${sp.xg_away} (Total: ${sp.xg_total})`); console.log(`\nšŸŽ² Top 5 Scores:`); pkg.scenario_top5.forEach((s: any, i: number) => { console.log(` ${i + 1}. ${s.score} (${s.prob}%)`); }); const risk = pkg.risk; console.log(`\nāš ļø Risk: ${risk.level} (${risk.score}/10)`); if (risk.warnings?.length > 0) { console.log(` Warnings: ${risk.warnings.join(', ')}`); } console.log(`\nšŸ’¬ Reasoning:`); pkg.reasoning_factors.forEach((f: string) => console.log(` - ${f}`)); if (pkg.ai_commentary) { console.log(`\nšŸ’¬ AI Commentary:`); console.log(` ${pkg.ai_commentary}`); } // HT/FT specific check console.log(`\nšŸ” HT/FT CHECK:`); const htft = pkg.market_board?.HTFT; if (htft && htft.probs && Object.keys(htft.probs).length > 0) { console.log(` āœ… HT/FT PROBS PRESENT:`); Object.entries(htft.probs).forEach(([key, val]) => { console.log(` ${key}: ${(val as number * 100).toFixed(2)}%`); }); // Find best HT/FT const best = Object.entries(htft.probs).reduce((a, b) => (b[1] as number) > (a[1] as number) ? b : a); console.log(`\n šŸŽÆ BEST HT/FT: ${best[0]} (${(best[1] as number * 100).toFixed(2)}%)`); } else { console.log(` āŒ HT/FT PROBS EMPTY`); } await prisma.$disconnect(); } getPrediction().catch(console.error);