import { useState } from 'react' const MAX_TOKENS_LIMIT = 60 const EXAMPLES = [ 'العلم نور و', 'أفضل طريقة لتعلم البرمجة هي', 'في يوم من الأيام كان هناك', 'الطقس اليوم', ] function App() { const [prompt, setPrompt] = useState('') const [maxTokens, setMaxTokens] = useState(20) const [output, setOutput] = useState('') const [loading, setLoading] = useState(false) const [error, setError] = useState('') async function handleGenerate() { if (!prompt.trim()) { setError('اكتب نصاً أولاً') return } setLoading(true) setError('') setOutput('') try { const res = await fetch('/api/generate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt, max_new_tokens: maxTokens }), }) const data = await res.json() if (!res.ok) { throw new Error(data.detail || 'حدث خطأ غير متوقَّع') } setOutput(data.output) } catch (err) { setError(err.message) } finally { setLoading(false) } } function handleKeyDown(e) { if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { handleGenerate() } } return (
نموذج لغوي عربي تجريبي (~350M معامل)