import React, { useState } from 'react' export default function App(){ const [prompt, setPrompt] = useState(''); const [out, setOut] = useState(''); const [loading, setLoading] = useState(false); const callServer = async () => { setLoading(true); setOut(''); try{ const resp = await fetch('/api/ask', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ prompt, model: 'gpt-4o-mini' }) }); const j = await resp.json(); if(j.ok) setOut(j.answer); else setOut('Error: ' + (j.error||JSON.stringify(j))); }catch(e){ setOut('Network error: ' + e.message) } setLoading(false); } return (
Type a question for the marketing expert (server-side AI).