import { useState } from 'react'; import { useDropzone } from 'react-dropzone'; import { Upload, FileText, AlertCircle } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from './ui/Card'; import { Button } from './ui/Button'; export default function NotebookParser() { const [file, setFile] = useState(null); const [parsing, setParsing] = useState(false); const [results, setResults] = useState([]); const [error, setError] = useState(null); const onDrop = (acceptedFiles) => { const notebookFile = acceptedFiles.find(f => f.name.endsWith('.ipynb')); if (notebookFile) { setFile(notebookFile); setError(null); } else { setError('Please upload a valid .ipynb file'); } }; const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, accept: { 'application/json': ['.ipynb'] }, maxFiles: 1, }); const parseNotebook = async () => { if (!file) return; setParsing(true); const formData = new FormData(); formData.append('file', file); try { const response = await fetch('/api/parse-notebook', { method: 'POST', body: formData, }); if (!response.ok) throw new Error('Parse failed'); const data = await response.json(); setResults(data.parameters || []); } catch (err) { setError(err.message); } finally { setParsing(false); } }; return (
Drag & drop your .ipynb file here
or click to browse
| Parameter | Value | Confidence | Source |
|---|---|---|---|
| {param.param} | {JSON.stringify(param.value)} |
|
{param.source} |