kizabgd123's picture
Upload pages/api/training/start.js with huggingface_hub
3533889 verified
raw
history blame contribute delete
617 Bytes
import { TrainingMonitor } from '../../lib/training-monitor';
export default function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}
try {
const monitor = new TrainingMonitor();
// Simulate training for demo
for (let epoch = 0; epoch < 10; epoch++) {
monitor.logEpoch(epoch, Math.random() * 0.5, 0.001 * Math.pow(0.9, epoch));
}
res.status(200).json({ history: monitor.history });
} catch (error) {
console.error('Training error:', error);
res.status(500).json({ error: 'Training failed' });
}
}