const AITUTOR_SEED = [ { role: 'user', text: 'What is the difference between star and delta connection in a three-phase motor?', hi: 'तीन-चरण मोटर में स्टार और डेल्टा कनेक्शन में क्या अंतर है?' }, { role: 'ai', text: 'Great question, Rahul! Let me explain with a quick visual comparison.', cards: [ { kind: 'diagram', title: 'Star (Y) connection', body: 'Line voltage = √3 × Phase voltage · Line current = Phase current · Used for starting to reduce inrush current.' }, { kind: 'diagram', title: 'Delta (Δ) connection', body: 'Line voltage = Phase voltage · Line current = √3 × Phase current · Used at running/full load for maximum torque.' }, ], followup: [ 'Show me a 3D animation of the winding connections', 'When does a star-delta starter switch over?', 'What are typical starting current values?', ], }, { role: 'user', text: 'Show me a 3D animation of the winding connections' }, { role: 'ai', text: 'Here you go — I have found the exact 3D lesson in your Electrician trade library. It shows the winding termination inside the terminal box.', lesson: { title: 'L07 · Star-Delta Winding Termination', dur: '4:12', trade: 'Electrician · Sem 4' }, }, ]; // Canned tutor replies keyed by intent — keeps the demo responsive offline. function aiReplyFor(q) { const s = (q || '').toLowerCase(); if (s.includes('3d') || s.includes('animation') || s.includes('winding')) { return { role: 'ai', text: 'Here you go — I have found the matching 3D lesson in your Electrician trade library. It shows the winding termination inside the terminal box.', lesson: { title: 'L07 · Star-Delta Winding Termination', dur: '4:12', trade: 'Electrician · Sem 4' } }; } if (s.includes('star') || s.includes('delta')) { return { role: 'ai', text: 'Star vs Delta — here is the quick comparison you can revise before your viva.', cards: [ { kind: 'diagram', title: 'Star (Y) connection', body: 'Line voltage = √3 × Phase voltage · Line current = Phase current · Used for starting to reduce inrush current.' }, { kind: 'diagram', title: 'Delta (Δ) connection', body: 'Line voltage = Phase voltage · Line current = √3 × Phase current · Used at running/full load for maximum torque.' }, ], followup: ['Show me a 3D animation of the winding connections', 'When does a star-delta starter switch over?', 'What are typical starting current values?'] }; } if (s.includes('viva')) { return { role: 'ai', text: 'Let us prepare for viva. Try answering: (1) Why is a star-delta starter used? (2) State the relation between line and phase current in delta. (3) Name one protection device on a 3-phase motor. Reply and I will grade you.' }; } if (s.includes('example') || s.includes('practical')) { return { role: 'ai', text: 'Practical example: a 5 HP induction motor started in star draws ~1/3 of the delta starting current, protecting the windings. Once it reaches ~75% speed, the starter switches to delta for full torque.' }; } if (s.includes('sem 1') || s.includes('simple') || s.includes('explain like')) { return { role: 'ai', text: 'Simple version: Star connection = gentle start (less current). Delta connection = full power for running. We start in star, then switch to delta — like starting a bike in first gear, then shifting up.' }; } return { role: 'ai', text: 'Got it — I will pull the most relevant 3D lesson and notes for “' + (q || '').trim() + '”. Meanwhile, try one of the suggested prompts below to dig deeper.', followup: ['Give me a practical example', 'Explain like I\'m in Sem 1', 'Prepare me for viva'] }; } function AITutor({ onNavigate }) { const [input, setInput] = React.useState(''); const [messages, setMessages] = React.useState(AITUTOR_SEED); const scrollRef = React.useRef(null); React.useEffect(() => { const el = scrollRef.current; if (el) el.scrollTop = el.scrollHeight; }, [messages]); const send = (raw) => { const text = (raw != null ? raw : input).trim(); if (!text) return; setInput(''); setMessages(m => [...m, { role: 'user', text }]); // Simulate the tutor thinking, then answer. setTimeout(() => setMessages(m => [...m, aiReplyFor(text)]), 500); }; const clearChat = () => { setMessages([]); window.toast('Chat cleared'); }; return (
{/* Chat header */}
ShikshaTri AI Tutor
Online · Answering in English, हिंदी, தமிழ், తెలుగు
{/* Messages */}
{messages.length === 0 && (
Ask the AI Tutor anything about your trade to begin.
)} {messages.map((m, i) => ( m.role === 'user' ? (
{m.text}
{m.hi &&
{m.hi}
}
RK
) : (
{m.text}
{m.cards && (
{m.cards.map(c => (
{c.title}
{c.body}
))}
)} {m.lesson && (
{m.lesson.title}
{m.lesson.trade} · {m.lesson.dur}
)}
{m.followup && (
{m.followup.map(f => ( ))}
)}
) ))}
{/* Input */}