const { useState } = React; const { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } = Recharts; function App() { const [data, setData] = useState(null); const [query, setQuery] = useState(''); const [insights, setInsights] = useState([]); const handleFileUpload = async (event) => { const file = event.target.files[0]; const formData = new FormData(); formData.append('file', file); const response = await fetch('/api/process-file', { method: 'POST', body: formData, }); const result = await response.json(); setData(result); }; const handleQuery = async () => { if (!data || !query) return; const response = await fetch('/api/query', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query, embeddings: data.embeddings }), }); const result = await response.json(); const newInsights = result.similar_indices.map(idx => data.raw_data[idx]); setInsights(newInsights); }; return (
{data && (
setQuery(e.target.value)} placeholder="Ask a question about your data..." className="w-full p-2 border rounded" />
{insights.length > 0 && (

Related Insights

{Object.keys(insights[0] || {}).map((key) => ( ))}
{insights.map((insight, idx) => (
{Object.entries(insight).map(([key, value]) => (
{key}: {value}
))}
))}
)}
)}
); } ReactDOM.render(, document.getElementById('root'));