Spaces:
Build error
Build error
Mehdi commited on
Upload pages/index.js with huggingface_hub
Browse files- pages/index.js +54 -192
pages/index.js
CHANGED
|
@@ -1,212 +1,74 @@
|
|
| 1 |
-
import { useState, useEffect
|
| 2 |
-
import
|
| 3 |
-
import {
|
| 4 |
-
import ChatInterface from '../components/ChatInterface'
|
| 5 |
import CodeEditor from '../components/CodeEditor'
|
| 6 |
-
import
|
| 7 |
-
import
|
| 8 |
-
import
|
| 9 |
-
import AgentDashboard from '../components/AgentDashboard'
|
| 10 |
-
import FileExplorer from '../components/FileExplorer'
|
| 11 |
|
| 12 |
export default function Home() {
|
| 13 |
const [activeTab, setActiveTab] = useState('chat')
|
| 14 |
-
const [isListening, setIsListening] = useState(false)
|
| 15 |
const [language, setLanguage] = useState('fa')
|
| 16 |
-
const [theme, setTheme] = useState('dark')
|
| 17 |
-
const [isProcessing, setIsProcessing] = useState(false)
|
| 18 |
-
const [notifications, setNotifications] = useState([])
|
| 19 |
-
const [systemStatus, setSystemStatus] = useState({
|
| 20 |
-
aiModel: 'local',
|
| 21 |
-
internetAccess: false,
|
| 22 |
-
privacyMode: true,
|
| 23 |
-
gpuEnabled: false
|
| 24 |
-
})
|
| 25 |
-
|
| 26 |
-
const tabs = [
|
| 27 |
-
{ id: 'chat', name: language === 'fa' ? 'چت هوشمند' : 'Smart Chat', icon: FaRobot },
|
| 28 |
-
{ id: 'code', name: language === 'fa' ? 'کدنویسی' : 'Coding', icon: FaCode },
|
| 29 |
-
{ id: 'media', name: language === 'fa' ? 'استودیو رسانه' : 'Media Studio', icon: FaImage },
|
| 30 |
-
{ id: 'voice', name: language === 'fa' ? 'کنسول صوتی' : 'Voice Console', icon: FaMicrophone },
|
| 31 |
-
{ id: 'agent', name: language === 'fa' ? 'عامل خودکار' : 'Autonomous Agent', icon: FaBrain },
|
| 32 |
-
{ id: 'files', name: language === 'fa' ? 'مدیریت فایل' : 'File Manager', icon: FaDatabase },
|
| 33 |
-
{ id: 'settings', name: language === 'fa' ? 'تنظیمات' : 'Settings', icon: FaCog },
|
| 34 |
-
]
|
| 35 |
-
|
| 36 |
-
const addNotification = (message, type = 'info') => {
|
| 37 |
-
const id = Date.now()
|
| 38 |
-
setNotifications(prev => [...prev, { id, message, type }])
|
| 39 |
-
setTimeout(() => {
|
| 40 |
-
setNotifications(prev => prev.filter(n => n.id !== id))
|
| 41 |
-
}, 5000)
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
useEffect(() => {
|
| 45 |
-
// Initialize system
|
| 46 |
-
addNotification(language === 'fa' ? 'به GhadirSync-AI خوش آمدید!' : 'Welcome to GhadirSync-AI!', 'success')
|
| 47 |
-
}, [language])
|
| 48 |
|
| 49 |
return (
|
| 50 |
-
<div className=
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
<
|
| 54 |
-
|
| 55 |
-
<div className="flex items-center space-x-reverse space-x-4">
|
| 56 |
-
<motion.div
|
| 57 |
-
animate={{ rotate: isProcessing ? 360 : 0 }}
|
| 58 |
-
transition={{ duration: 2, repeat: isProcessing ? Infinity : 0, ease: "linear" }}
|
| 59 |
-
>
|
| 60 |
-
<FaRobot className="w-8 h-8 text-white" />
|
| 61 |
-
</motion.div>
|
| 62 |
-
<div>
|
| 63 |
-
<h1 className="text-2xl font-bold">GhadirSync-AI</h1>
|
| 64 |
-
<p className="text-xs opacity-90">
|
| 65 |
-
{language === 'fa' ? 'دستیار هوشمند چندوجهی' : 'Multimodal AI Assistant'}
|
| 66 |
-
</p>
|
| 67 |
-
</div>
|
| 68 |
-
</div>
|
| 69 |
-
|
| 70 |
-
<div className="flex items-center space-x-reverse space-x-4">
|
| 71 |
-
{/* Status Indicators */}
|
| 72 |
-
<div className="flex items-center space-x-reverse space-x-2">
|
| 73 |
-
<div className={`w-2 h-2 rounded-full ${systemStatus.aiModel === 'local' ? 'bg-green-400' : 'bg-yellow-400'}`} />
|
| 74 |
-
<span className="text-xs">
|
| 75 |
-
{language === 'fa' ? 'مدل محلی' : 'Local Model'}
|
| 76 |
-
</span>
|
| 77 |
-
</div>
|
| 78 |
-
|
| 79 |
-
<div className="flex items-center space-x-reverse space-x-2">
|
| 80 |
-
<FaGlobe className={`w-4 h-4 ${systemStatus.internetAccess ? 'text-green-400' : 'text-gray-400'}`} />
|
| 81 |
-
<span className="text-xs">
|
| 82 |
-
{systemStatus.internetAccess ? (language === 'fa' ? 'آنلاین' : 'Online') : (language === 'fa' ? 'آفلاین' : 'Offline')}
|
| 83 |
-
</span>
|
| 84 |
-
</div>
|
| 85 |
-
|
| 86 |
-
<div className="flex items-center space-x-reverse space-x-2">
|
| 87 |
-
<FaShieldAlt className={`w-4 h-4 ${systemStatus.privacyMode ? 'text-green-400' : 'text-gray-400'}`} />
|
| 88 |
-
<span className="text-xs">
|
| 89 |
-
{language === 'fa' ? 'حریم خصوصی' : 'Privacy'}
|
| 90 |
-
</span>
|
| 91 |
-
</div>
|
| 92 |
-
|
| 93 |
-
{/* Language Toggle */}
|
| 94 |
-
<button
|
| 95 |
-
onClick={() => setLanguage(language === 'fa' ? 'en' : 'fa')}
|
| 96 |
-
className="flex items-center space-x-reverse space-x-2 px-3 py-1 bg-white bg-opacity-20 rounded-lg hover:bg-opacity-30 transition-all"
|
| 97 |
-
>
|
| 98 |
-
<FaLanguage className="w-4 h-4" />
|
| 99 |
-
<span className="text-sm font-medium">
|
| 100 |
-
{language === 'fa' ? 'فا' : 'EN'}
|
| 101 |
-
</span>
|
| 102 |
-
</button>
|
| 103 |
-
</div>
|
| 104 |
-
</div>
|
| 105 |
-
</div>
|
| 106 |
-
</header>
|
| 107 |
-
|
| 108 |
-
{/* Navigation Tabs */}
|
| 109 |
-
<div className="border-b border-gray-700 bg-gray-800">
|
| 110 |
-
<div className="container mx-auto px-4">
|
| 111 |
-
<div className="flex space-x-reverse space-x-1 overflow-x-auto">
|
| 112 |
-
{tabs.map((tab) => {
|
| 113 |
-
const Icon = tab.icon
|
| 114 |
-
return (
|
| 115 |
-
<button
|
| 116 |
-
key={tab.id}
|
| 117 |
-
onClick={() => setActiveTab(tab.id)}
|
| 118 |
-
className={`flex items-center space-x-reverse space-x-2 px-4 py-3 border-b-2 transition-all whitespace-nowrap ${
|
| 119 |
-
activeTab === tab.id
|
| 120 |
-
? 'border-primary-500 text-primary-400 bg-gray-700'
|
| 121 |
-
: 'border-transparent text-gray-400 hover:text-white hover:bg-gray-700'
|
| 122 |
-
}`}
|
| 123 |
-
>
|
| 124 |
-
<Icon className="w-4 h-4" />
|
| 125 |
-
<span className="text-sm font-medium">{tab.name}</span>
|
| 126 |
-
</button>
|
| 127 |
-
)
|
| 128 |
-
})}
|
| 129 |
-
</div>
|
| 130 |
-
</div>
|
| 131 |
-
</div>
|
| 132 |
-
|
| 133 |
-
{/* Main Content */}
|
| 134 |
-
<main className="container mx-auto px-4 py-6">
|
| 135 |
-
<AnimatePresence mode="wait">
|
| 136 |
-
<motion.div
|
| 137 |
-
key={activeTab}
|
| 138 |
-
initial={{ opacity: 0, y: 20 }}
|
| 139 |
-
animate={{ opacity: 1, y: 0 }}
|
| 140 |
-
exit={{ opacity: 0, y: -20 }}
|
| 141 |
-
transition={{ duration: 0.3 }}
|
| 142 |
-
>
|
| 143 |
-
{activeTab === 'chat' && <ChatInterface language={language} theme={theme} />}
|
| 144 |
-
{activeTab === 'code' && <CodeEditor language={language} theme={theme} />}
|
| 145 |
-
{activeTab === 'media' && <MediaStudio language={language} theme={theme} />}
|
| 146 |
-
{activeTab === 'voice' && <VoiceConsole language={language} theme={theme} />}
|
| 147 |
-
{activeTab === 'agent' && <AgentDashboard language={language} theme={theme} />}
|
| 148 |
-
{activeTab === 'files' && <FileExplorer language={language} theme={theme} />}
|
| 149 |
-
{activeTab === 'settings' && <SettingsPanel language={language} theme={theme} />}
|
| 150 |
-
</motion.div>
|
| 151 |
-
</AnimatePresence>
|
| 152 |
-
</main>
|
| 153 |
-
|
| 154 |
-
{/* Floating Action Button */}
|
| 155 |
-
<motion.button
|
| 156 |
-
whileHover={{ scale: 1.1 }}
|
| 157 |
-
whileTap={{ scale: 0.95 }}
|
| 158 |
-
onClick={() => setIsListening(!isListening)}
|
| 159 |
-
className={`fixed bottom-6 left-6 w-14 h-14 rounded-full shadow-lg flex items-center justify-center transition-all ${
|
| 160 |
-
isListening
|
| 161 |
-
? 'bg-red-500 hover:bg-red-600 animate-pulse'
|
| 162 |
-
: 'bg-primary-500 hover:bg-primary-600'
|
| 163 |
-
}`}
|
| 164 |
-
>
|
| 165 |
-
{isListening ? <FaStop className="w-6 h-6 text-white" /> : <FaMicrophone className="w-6 h-6 text-white" />}
|
| 166 |
-
</motion.button>
|
| 167 |
-
|
| 168 |
-
{/* Notifications */}
|
| 169 |
-
<div className="fixed top-20 left-4 z-50 space-y-2">
|
| 170 |
-
{notifications.map((notification) => (
|
| 171 |
-
<motion.div
|
| 172 |
-
key={notification.id}
|
| 173 |
-
initial={{ opacity: 0, x: 100 }}
|
| 174 |
-
animate={{ opacity: 1, x: 0 }}
|
| 175 |
-
exit={{ opacity: 0, x: 100 }}
|
| 176 |
-
className={`flex items-center space-x-reverse space-x-2 px-4 py-3 rounded-lg shadow-lg ${
|
| 177 |
-
notification.type === 'success' ? 'bg-green-500' :
|
| 178 |
-
notification.type === 'error' ? 'bg-red-500' :
|
| 179 |
-
notification.type === 'warning' ? 'bg-yellow-500' :
|
| 180 |
-
'bg-blue-500'
|
| 181 |
-
} text-white`}
|
| 182 |
-
>
|
| 183 |
-
{notification.type === 'success' && <FaCheckCircle className="w-5 h-5" />}
|
| 184 |
-
{notification.type === 'error' && <FaExclamationTriangle className="w-5 h-5" />}
|
| 185 |
-
{notification.type === 'warning' && <FaExclamationTriangle className="w-5 h-5" />}
|
| 186 |
-
{notification.type === 'info' && <FaInfoCircle className="w-5 h-5" />}
|
| 187 |
-
<span className="text-sm font-medium">{notification.message}</span>
|
| 188 |
-
</motion.div>
|
| 189 |
-
))}
|
| 190 |
-
</div>
|
| 191 |
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
<div className="flex items-center
|
| 196 |
-
<
|
| 197 |
-
{language === 'fa' ? '
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
<a
|
| 200 |
href="https://huggingface.co/spaces/akhaliq/anycoder"
|
| 201 |
target="_blank"
|
| 202 |
rel="noopener noreferrer"
|
| 203 |
-
className="text-sm
|
| 204 |
>
|
| 205 |
Built with anycoder
|
| 206 |
</a>
|
| 207 |
</div>
|
| 208 |
</div>
|
| 209 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
</div>
|
| 211 |
)
|
| 212 |
}
|
|
|
|
| 1 |
+
import { useState, useEffect } from 'react'
|
| 2 |
+
import Head from 'next/head'
|
| 3 |
+
import { FaCode, FaRobot, FaMicrophone, FaLanguage } from 'react-icons/fa'
|
|
|
|
| 4 |
import CodeEditor from '../components/CodeEditor'
|
| 5 |
+
import ChatInterface from '../components/ChatInterface'
|
| 6 |
+
import VoiceControl from '../components/VoiceControl'
|
| 7 |
+
import AgentWorkflow from '../components/AgentWorkflow'
|
|
|
|
|
|
|
| 8 |
|
| 9 |
export default function Home() {
|
| 10 |
const [activeTab, setActiveTab] = useState('chat')
|
|
|
|
| 11 |
const [language, setLanguage] = useState('fa')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
return (
|
| 14 |
+
<div className="min-h-screen bg-gray-100">
|
| 15 |
+
<Head>
|
| 16 |
+
<title>GhadirSync-AI | برنامهنویسی هوشمند</title>
|
| 17 |
+
<meta name="description" content="دستیار هوشمند برنامهنویسی با قابلیتهای پیشرفته" />
|
| 18 |
+
</Head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
<header className="bg-blue-600 text-white p-4 shadow-md">
|
| 21 |
+
<div className="container mx-auto flex justify-between items-center">
|
| 22 |
+
<h1 className="text-2xl font-bold">GhadirSync-AI</h1>
|
| 23 |
+
<div className="flex items-center space-x-4">
|
| 24 |
+
<button
|
| 25 |
+
onClick={() => setLanguage(language === 'fa' ? 'en' : 'fa')}
|
| 26 |
+
className="flex items-center px-3 py-1 rounded bg-blue-700 hover:bg-blue-800"
|
| 27 |
+
>
|
| 28 |
+
<FaLanguage className="ml-1" />
|
| 29 |
+
{language === 'fa' ? 'English' : 'فارسی'}
|
| 30 |
+
</button>
|
| 31 |
<a
|
| 32 |
href="https://huggingface.co/spaces/akhaliq/anycoder"
|
| 33 |
target="_blank"
|
| 34 |
rel="noopener noreferrer"
|
| 35 |
+
className="text-sm hover:underline"
|
| 36 |
>
|
| 37 |
Built with anycoder
|
| 38 |
</a>
|
| 39 |
</div>
|
| 40 |
</div>
|
| 41 |
+
</header>
|
| 42 |
+
|
| 43 |
+
<main className="container mx-auto p-4">
|
| 44 |
+
<div className="flex mb-4 border-b border-gray-300">
|
| 45 |
+
<button
|
| 46 |
+
className={`px-4 py-2 font-medium ${activeTab === 'chat' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-600'}`}
|
| 47 |
+
onClick={() => setActiveTab('chat')}
|
| 48 |
+
>
|
| 49 |
+
<FaRobot className="inline ml-1" />
|
| 50 |
+
{language === 'fa' ? 'چت هوشمند' : 'AI Chat'}
|
| 51 |
+
</button>
|
| 52 |
+
<button
|
| 53 |
+
className={`px-4 py-2 font-medium ${activeTab === 'code' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-600'}`}
|
| 54 |
+
onClick={() => setActiveTab('code')}
|
| 55 |
+
>
|
| 56 |
+
<FaCode className="inline ml-1" />
|
| 57 |
+
{language === 'fa' ? 'ویرایشگر کد' : 'Code Editor'}
|
| 58 |
+
</button>
|
| 59 |
+
<button
|
| 60 |
+
className={`px-4 py-2 font-medium ${activeTab === 'agent' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-600'}`}
|
| 61 |
+
onClick={() => setActiveTab('agent')}
|
| 62 |
+
>
|
| 63 |
+
<FaMicrophone className="inline ml-1" />
|
| 64 |
+
{language === 'fa' ? 'عامل هوشمند' : 'AI Agent'}
|
| 65 |
+
</button>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
{activeTab === 'chat' && <ChatInterface language={language} />}
|
| 69 |
+
{activeTab === 'code' && <CodeEditor language={language} />}
|
| 70 |
+
{activeTab === 'agent' && <AgentWorkflow language={language} />}
|
| 71 |
+
</main>
|
| 72 |
</div>
|
| 73 |
)
|
| 74 |
}
|