/** * XML COMPILER PANEL * Natural language → valid XML system prompts * Control mini models (Granite, Nemotron, etc.) via XML-derived prompts */ import React, { useState } from 'react'; interface CompilationResult { mode: string; xmlOutput: string; validationStatus: 'VALID' | 'INVALID' | 'PARTIAL'; metadata: { timestamp: number; executionTimeMs: number; }; } interface ModelResponse { model: string; response: string; promptUsed: string; executionTimeMs: number; } export function XMLCompilerPanel() { const [mode, setMode] = useState<'gbnf' | 'skeleton' | 'dual-pass'>('skeleton'); const [naturalLanguage, setNaturalLanguage] = useState(''); const [xmlResult, setXmlResult] = useState(null); const [modelSelection, setModelSelection] = useState('nemotron'); const [userQuery, setUserQuery] = useState(''); const [modelResponse, setModelResponse] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); async function compileToXML() { setLoading(true); setError(null); try { const res = await fetch('/api/xml/compile', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ mode, naturalLanguage, temperature: 0.3, }), }); const data = await res.json(); if (data.ok) { setXmlResult(data); } else { setError(data.error || 'Compilation failed'); } } catch (e: any) { setError(e.message); } finally { setLoading(false); } } async function controlModel() { if (!xmlResult) { setError('Compile natural language to XML first'); return; } setLoading(true); setError(null); try { const res = await fetch('/api/xml/control-model', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ xmlPrompt: xmlResult.xmlOutput, model: modelSelection, userQuery, temperature: 0.7, maxTokens: 512, }), }); const data = await res.json(); if (data.ok) { setModelResponse(data); } else { setError(data.error || 'Model control failed'); } } catch (e: any) { setError(e.message); } finally { setLoading(false); } } return (
🔮 XML Compiler
{/* ===== STEP 1: COMPILE ===== */}
Step 1: Natural Language → XML