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} from 'lucide-react';
|
| 4 |
+
|
| 5 |
+
export default function HermesDirective() {
|
| 6 |
+
const [prompt, setPrompt] = useState('');
|
| 7 |
+
const [voiceMatrix, setVoiceMatrix] = useState('neutral');
|
| 8 |
+
const [affectVector, setAffectVector] = useState('informative');
|
| 9 |
+
const [intentField, setIntentField] = useState('technical');
|
| 10 |
+
const [targetStack, setTargetStack] = useState('gradio+fastapi');
|
| 11 |
+
const [output, setOutput] = useState('');
|
| 12 |
+
const [loading, setLoading] = useState(false);
|
| 13 |
+
const [isListening, setIsListening] = useState(false);
|
| 14 |
+
const [interimTranscript, setInterimTranscript] = useState('');
|
| 15 |
+
|
| 16 |
+
const recognitionRef = useRef(null);
|
| 17 |
+
|
| 18 |
+
// Initialize Web Speech API
|
| 19 |
+
useEffect(() => {
|
| 20 |
+
if (typeof window !== 'undefined' && 'webkitSpeechRecognition' in window) {
|
| 21 |
+
const SpeechRecognition = window.webkitSpeechRecognition;
|
| 22 |
+
recognitionRef.current = new SpeechRecognition();
|
| 23 |
+
recognitionRef.current.continuous = true;
|
| 24 |
+
recognitionRef.current.interimResults = true;
|
| 25 |
+
recognitionRef.current.lang = 'en-US';
|
| 26 |
+
|
| 27 |
+
recognitionRef.current.onresult = (event) => {
|
| 28 |
+
let finalTranscript = '';
|
| 29 |
+
let interim = '';
|
| 30 |
+
|
| 31 |
+
for (let i = event.resultIndex; i < event.results.length; ++i) {
|
| 32 |
+
if (event.results[i].isFinal) {
|
| 33 |
+
finalTranscript += event.results[i][0].transcript;
|
| 34 |
+
} else {
|
| 35 |
+
interim += event.results[i][0].transcript;
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
if (finalTranscript) {
|
| 40 |
+
setPrompt(prev => prev + (prev ? ' ' : '') + finalTranscript);
|
| 41 |
+
}
|
| 42 |
+
setInterimTranscript(interim);
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
recognitionRef.current.onerror = (event) => {
|
| 46 |
+
console.error('Speech recognition error', event.error);
|
| 47 |
+
setIsListening(false);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
recognitionRef.current.onend = () => {
|
| 51 |
+
setIsListening(false);
|
| 52 |
+
};
|
| 53 |
+
}
|
| 54 |
+
}, []);
|
| 55 |
+
|
| 56 |
+
const toggleListening = () => {
|
| 57 |
+
if (!recognitionRef.current) {
|
| 58 |
+
alert('Speech recognition is not supported in this browser. Try Chrome on Android (Termux) or Desktop.');
|
| 59 |
+
return;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
if (isListening) {
|
| 63 |
+
recognitionRef.current.stop();
|
| 64 |
+
setIsListening(false);
|
| 65 |
+
setInterimTranscript('');
|
| 66 |
+
} else {
|
| 67 |
+
recognitionRef.current.start();
|
| 68 |
+
setIsListening(true);
|
| 69 |
+
}
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
const handleGenerate = async () => {
|
| 73 |
+
if (!prompt.trim()) return;
|
| 74 |
+
|
| 75 |
+
setLoading(true);
|
| 76 |
+
setOutput('');
|
| 77 |
+
|
| 78 |
+
// Simulate API latency and generation
|
| 79 |
+
setTimeout(() => {
|
| 80 |
+
const mockResponse = `# Generated by Dolphin 2.9 Hermes Directive
|
| 81 |
+
# Stack: ${targetStack} | Voice: ${voiceMatrix} | Intent: ${intentField}
|
| 82 |
+
|
| 83 |
+
import gradio as gr
|
| 84 |
+
import torch
|
| 85 |
+
from transformers import pipeline
|
| 86 |
+
|
| 87 |
+
# Optimized for mobile deployment
|
| 88 |
+
def execute_directive(user_input):
|
| 89 |
+
"""
|
| 90 |
+
Generated based on prompt: "${prompt.substring(0, 50)}..."
|
| 91 |
+
"""
|
| 92 |
+
# Placeholder for actual inference logic
|
| 93 |
+
return "Hermes Directive Executed Successfully.\\nCode generated for ${intentField} context."
|
| 94 |
+
|
| 95 |
+
# Gradio Interface Mobile Optimized
|
| 96 |
+
with gr.Blocks(theme=gr.themes.Dark()) as demo:
|
| 97 |
+
gr.Markdown("# Mobile Vibe Coding Interface")
|
| 98 |
+
inp = gr.Textbox(label="Command", placeholder="Enter directive...")
|
| 99 |
+
out = gr.Textbox(label="Result")
|
| 100 |
+
btn = gr.Button("Execute")
|
| 101 |
+
btn.click(fn=execute_directive, inputs=inp, outputs=out)
|
| 102 |
+
|
| 103 |
+
if __name__ == "__main__":
|
| 104 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)`;
|
| 105 |
+
|
| 106 |
+
setOutput(mockResponse);
|
| 107 |
+
setLoading(false);
|
| 108 |
+
}, 2000);
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
return (
|
| 112 |
+
<div className="min-h-screen bg-dolphin-900 text-slate-100 font-sans selection:bg-dolphin-accent selection:text-dolphin-900">
|
| 113 |
+
<Head>
|
| 114 |
+
<title>Hermes Directive Engine | Mobile Optimized</title>
|
| 115 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
| 116 |
+
<meta name="description" content="Uncensored Full-Stack Vibe Coding Interface" />
|
| 117 |
+
</Head>
|
| 118 |
+
|
| 119 |
+
{/* Header */}
|
| 120 |
+
<header className="border-b border-dolphin-700 bg-dolphin-800/50 backdrop-blur-sm sticky top-0 z-50">
|
| 121 |
+
<div className="max-w-7xl mx-auto px-4 py-3 flex justify-between items-center">
|
| 122 |
+
<div className="flex items-center gap-2">
|
| 123 |
+
<Cpu className="w-6 h-6 text-dolphin-accent" />
|
| 124 |
+
<h1 className="font-bold text-lg sm:text-xl tracking-tight">
|
| 125 |
+
Hermes Directive <span className="text-dolphin-accent">Engine</span>
|
| 126 |
+
</h1>
|
| 127 |
+
</div>
|
| 128 |
+
<a
|
| 129 |
+
href="https://huggingface.co/spaces/akhaliq/anycoder"
|
| 130 |
+
target="_blank"
|
| 131 |
+
rel="noopener noreferrer"
|
| 132 |
+
className="text-xs sm:text-sm text-slate-400 hover:text-dolphin-accent transition-colors"
|
| 133 |
+
>
|
| 134 |
+
Built with anycoder
|
| 135 |
+
</a>
|
| 136 |
+
</div>
|
| 137 |
+
</header>
|
| 138 |
+
|
| 139 |
+
<main className="max-w-7xl mx-auto px-4 py-6 pb-24">
|
| 140 |
+
{/* Hero Section */}
|
| 141 |
+
<div className="mb-8 text-center sm:text-left">
|
| 142 |
+
<h2 className="text-3xl sm:text-4xl font-extrabold mb-2 bg-clip-text text-transparent bg-gradient-to-r from-dolphin-accent to-purple-400">
|
| 143 |
+
Dolphin 2.9 Mobile
|
| 144 |
+
</h2>
|
| 145 |
+
<p className="text-slate-400 text-sm sm:text-base">
|
| 146 |
+
Uncensored full-stack vibe coding optimized for Termux & mobile environments.
|
| 147 |
+
</p>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
| 151 |
+
{/* Input Column */}
|
| 152 |
+
<div className="space-y-6">
|
| 153 |
+
{/* Voice Input Section */}
|
| 154 |
+
<div className="bg-dolphin-800 rounded-xl p-4 border border-dolphin-700 shadow-lg">
|
| 155 |
+
<label className="block text-sm font-medium text-slate-300 mb-2 flex items-center gap-2">
|
| 156 |
+
<Terminal className="w-4 h-4" />
|
| 157 |
+
Directive Input
|
| 158 |
+
</label>
|
| 159 |
+
|
| 160 |
+
<div className="relative">
|
| 161 |
+
<textarea
|
| 162 |
+
value={prompt}
|
| 163 |
+
onChange={(e) => setPrompt(e.target.value)}
|
| 164 |
+
placeholder="Describe your app (e.g., 'Build a secure E2EE chat app with DeltaChat integration')..."
|
| 165 |
+
className="w-full h-32 bg-dolphin-900 border border-dolphin-700 rounded-lg p-3 text-slate-100 placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-dolphin-accent focus:border-transparent resize-none text-sm"
|
| 166 |
+
/>
|
| 167 |
+
{interimTranscript && (
|
| 168 |
+
<div className="absolute bottom-2 right-2 text-dolphin-accent text-xs italic bg-dolphin-900/90 px-2 py-1 rounded">
|
| 169 |
+
{interimTranscript}
|
| 170 |
+
</div>
|
| 171 |
+
)}
|
| 172 |
+
</div>
|
| 173 |
+
|
| 174 |
+
<div className="mt-3 flex gap-3">
|
| 175 |
+
<button
|
| 176 |
+
onClick={toggleListening}
|
| 177 |
+
disabled={!recognitionRef.current}
|
| 178 |
+
className={`
|
| 179 |
+
flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-lg font-medium transition-all duration-200 active:scale-95
|
| 180 |
+
${isListening
|
| 181 |
+
? 'bg-red-500/20 text-red-400 border border-red-500/50 animate-pulse'
|
| 182 |
+
: 'bg-dolphin-700 text-slate-200 border border-dolphin-600 hover:bg-dolphin-600'}
|
| 183 |
+
${!recognitionRef.current ? 'opacity-50 cursor-not-allowed' : ''}
|
| 184 |
+
`}
|
| 185 |
+
>
|
| 186 |
+
{isListening ? <MicOff className="w-5 h-5" /> : <Mic className="w-5 h-5" />}
|
| 187 |
+
{isListening ? 'Stop Listening' : 'Voice Input'}
|
| 188 |
+
</button>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
{/* Configuration Matrix */}
|
| 193 |
+
<div className="bg-dolphin-800 rounded-xl p-4 border border-dolphin-700 shadow-lg">
|
| 194 |
+
<h3 className="text-sm font-medium text-slate-300 mb-4 flex items-center gap-2">
|
| 195 |
+
<Shield className="w-4 h-4" />
|
| 196 |
+
Configuration Matrix
|
| 197 |
+
</h3>
|
| 198 |
+
|
| 199 |
+
<div className="grid grid-cols-2 gap-4">
|
| 200 |
+
{/* Voice Matrix */}
|
| 201 |
+
<div className="space-y-1">
|
| 202 |
+
<label className="text-xs text-slate-500 uppercase tracking-wider">Voice Matrix</label>
|
| 203 |
+
<select
|
| 204 |
+
value={voiceMatrix}
|
| 205 |
+
onChange={(e) => setVoiceMatrix(e.target.value)}
|
| 206 |
+
className="w-full bg-dolphin-900 border border-dolphin-700 rounded-md p-2 text-sm text-slate-200 focus:outline-none focus:ring-1 focus:ring-dolphin-accent"
|
| 207 |
+
>
|
| 208 |
+
<option value="neutral">Neutral</option>
|
| 209 |
+
<option value="assertive">Assertive</option>
|
| 210 |
+
<option value="playful">Playful</option>
|
| 211 |
+
<option value="technical">Technical</option>
|
| 212 |
+
</select>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
{/* Affect Vector */}
|
| 216 |
+
<div className="space-y-1">
|
| 217 |
+
<label className="text-xs text-slate-500 uppercase tracking-wider">Affect Vector</label>
|
| 218 |
+
<select
|
| 219 |
+
value={affectVector}
|
| 220 |
+
onChange={(e) => setAffectVector(e.target.value)}
|
| 221 |
+
className="w-full bg-dolphin-900 border border-dolphin-700 rounded-md p-2 text-sm text-slate-200 focus:outline-none focus:ring-1 focus:ring-dolphin-accent"
|
| 222 |
+
>
|
| 223 |
+
<option value="informative">Informative</option>
|
| 224 |
+
<option value="persuasive">Persuasive</option>
|
| 225 |
+
<option value="narrative">Narrative</option>
|
| 226 |
+
<option value="directive">Directive</option>
|
| 227 |
+
</select>
|
| 228 |
+
</div>
|
| 229 |
+
|
| 230 |
+
{/* Intent Field */}
|
| 231 |
+
<div className="space-y-1">
|
| 232 |
+
<label className="text-xs text-slate-500 uppercase tracking-wider">Intent Field</label>
|
| 233 |
+
<select
|
| 234 |
+
value={intentField}
|
| 235 |
+
onChange={(e) => setIntentField(e.target.value)}
|
| 236 |
+
className="w-full bg-dolphin-900 border border-dolphin-700 rounded-md p-2 text-sm text-slate-200 focus:outline-none focus:ring-1 focus:ring-dolphin-accent"
|
| 237 |
+
>
|
| 238 |
+
<option value="technical">Technical</option>
|
| 239 |
+
<option value="creative">Creative</option>
|
| 240 |
+
<option value="cybersecurity">Cybersecurity</option>
|
| 241 |
+
<option value="nsfw">NSFW</option>
|
| 242 |
+
</select>
|
| 243 |
+
</div>
|
| 244 |
+
|
| 245 |
+
{/* Target Stack */}
|
| 246 |
+
<div className="space-y-1">
|
| 247 |
+
<label className="text-xs text-slate-500 uppercase tracking-wider">Target Stack</label>
|
| 248 |
+
<select
|
| 249 |
+
value={targetStack}
|
| 250 |
+
onChange={(e) => setTargetStack(e.target.value)}
|
| 251 |
+
className="w-full bg-dolphin-900 border border-dolphin-700 rounded-md p-2 text-sm text-slate-200 focus:outline-none focus:ring-1 focus:ring-dolphin-accent"
|
| 252 |
+
>
|
| 253 |
+
<option value="gradio+fastapi">Gradio + FastAPI</option>
|
| 254 |
+
<option value="react+django">React + Django</option>
|
| 255 |
+
<option value="streamlit+flask">Streamlit + Flask</option>
|
| 256 |
+
<option value="next+python">Next.js + Python API</option>
|
| 257 |
+
</select>
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
|
| 261 |
+
<button
|
| 262 |
+
onClick={handleGenerate}
|
| 263 |
+
disabled={loading || !prompt.trim()}
|
| 264 |
+
className="mt-6 w-full bg-gradient-to-r from-dolphin-accent to-blue-500 hover:from-blue-400 hover:to-dolphin-accent text-dolphin-900 font-bold py-3 px-4 rounded-lg shadow-lg shadow-blue-500/20 transition-all duration-200 active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
|
| 265 |
+
>
|
| 266 |
+
{loading ? (
|
| 267 |
+
<>
|
| 268 |
+
<div className="w-5 h-5 border-2 border-dolphin-900 border-t-transparent rounded-full animate-spin" />
|
| 269 |
+
Processing Directive...
|
| 270 |
+
</>
|
| 271 |
+
) : (
|
| 272 |
+
<>
|
| 273 |
+
<Rocket className="w-5 h-5" />
|
| 274 |
+
Generate Full Stack
|
| 275 |
+
</>
|
| 276 |
+
)}
|
| 277 |
+
</button>
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
|
| 281 |
+
{/* Output Column */}
|
| 282 |
+
<div className="bg-dolphin-800 rounded-xl border border-dolphin-700 shadow-lg flex flex-col h-full min-h-[500px]">
|
| 283 |
+
<div className="p-4 border-b border-dolphin-700 flex justify-between items-center bg-dolphin-800/50 rounded-t-xl">
|
| 284 |
+
<h3 className="text-sm font-medium text-slate-300 flex items-center gap-2">
|
| 285 |
+
<Code className="w-4 h-4" />
|
| 286 |
+
Production Output
|
| 287 |
+
</h3>
|
| 288 |
+
{loading && (
|
| 289 |
+
<span className="text-xs text-dolphin-accent animate-pulse">Generating via Dolphin 2.9...</span>
|
| 290 |
+
)}
|
| 291 |
+
</div>
|
| 292 |
+
|
| 293 |
+
<div className="flex-1 p-4 overflow-auto bg-[#0d1117] rounded-b-xl">
|
| 294 |
+
{output ? (
|
| 295 |
+
<pre className="text-xs sm:text-sm font-mono text-green-400 whitespace-pre-wrap leading-relaxed">
|
| 296 |
+
{output}
|
| 297 |
+
</pre>
|
| 298 |
+
) : (
|
| 299 |
+
<div className="h-full flex flex-col items-center justify-center text-slate-600">
|
| 300 |
+
<Terminal className="w-12 h-12 mb-3 opacity-50" />
|
| 301 |
+
<p className="text-sm">Output will appear here</p>
|
| 302 |
+
<p className="text-xs mt-1 opacity-70">Ready for Termux deployment</p>
|
| 303 |
+
</div>
|
| 304 |
+
)}
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
</div>
|
| 308 |
+
</main>
|
| 309 |
+
</div>
|
| 310 |
+
);
|
| 311 |
+
}
|