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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState, useEffect, useRef } from 'react';
|
| 2 |
+
import './index.css';
|
| 3 |
+
|
| 4 |
+
// --- Mock AI Service ---
|
| 5 |
+
// In a real scenario, this would call an OpenAI-compatible API
|
| 6 |
+
const mockAIService = async (prompt) => {
|
| 7 |
+
return new Promise((resolve) => {
|
| 8 |
+
setTimeout(() => {
|
| 9 |
+
resolve(`This is a simulated response to: "${prompt}".\n\nThis response demonstrates the **modern UI** and **clean layout** provided by the Docker container.`);
|
| 10 |
+
}, 1500);
|
| 11 |
+
});
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
const App = () => {
|
| 15 |
+
const [messages, setMessages] = useState([
|
| 16 |
+
{ id: 1, role: 'assistant', content: 'Hello! I am your AI assistant. How can I help you today?' }
|
| 17 |
+
]);
|
| 18 |
+
const [input, setInput] = useState('');
|
| 19 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 20 |
+
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
| 21 |
+
const messagesEndRef = useRef(null);
|
| 22 |
+
|
| 23 |
+
const scrollToBottom = () => {
|
| 24 |
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
useEffect(() => {
|
| 28 |
+
scrollToBottom();
|
| 29 |
+
}, [messages]);
|
| 30 |
+
|
| 31 |
+
const handleSend = async (e) => {
|
| 32 |
+
e.preventDefault();
|
| 33 |
+
if (!input.trim()) return;
|
| 34 |
+
|
| 35 |
+
const userMessage = { id: Date.now(), role: 'user', content: input };
|
| 36 |
+
setMessages(prev => [...prev, userMessage]);
|
| 37 |
+
setInput('');
|
| 38 |
+
setIsLoading(true);
|
| 39 |
+
|
| 40 |
+
// Simulate AI typing
|
| 41 |
+
const aiResponse = await mockAIService(input);
|
| 42 |
+
setMessages(prev => [...prev, { id: Date.now() + 1, role: 'assistant', content: aiResponse }]);
|
| 43 |
+
setIsLoading(false);
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
return (
|
| 47 |
+
<div className="flex h-screen w-full bg-slate-50 font-sans text-slate-800 overflow-hidden">
|
| 48 |
+
|
| 49 |
+
{/* --- Sidebar (Desktop) --- */}
|
| 50 |
+
<aside className="hidden md:flex flex-col w-64 bg-white border-r border-slate-200 h-full transition-all duration-300">
|
| 51 |
+
<div className="p-6 border-b border-slate-100">
|
| 52 |
+
<h1 className="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-indigo-600">
|
| 53 |
+
AI Playground
|
| 54 |
+
</h1>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<nav className="flex-1 overflow-y-auto p-4 space-y-2">
|
| 58 |
+
{/* Navigation Items */}
|
| 59 |
+
<a href="#" className="flex items-center gap-3 px-4 py-3 bg-blue-50 text-blue-700 rounded-xl font-medium transition-colors">
|
| 60 |
+
<span className="w-2 h-2 rounded-full bg-blue-500"></span>
|
| 61 |
+
New Chat
|
| 62 |
+
</a>
|
| 63 |
+
<a href="#" className="flex items-center gap-3 px-4 py-3 text-slate-600 hover:bg-slate-50 rounded-xl font-medium transition-colors">
|
| 64 |
+
<span className="w-2 h-2 rounded-full bg-slate-300"></span>
|
| 65 |
+
History
|
| 66 |
+
</a>
|
| 67 |
+
<a href="#" className="flex items-center gap-3 px-4 py-3 text-slate-600 hover:bg-slate-50 rounded-xl font-medium transition-colors">
|
| 68 |
+
<span className="w-2 h-2 rounded-full bg-slate-300"></span>
|
| 69 |
+
Settings
|
| 70 |
+
</a>
|
| 71 |
+
</nav>
|
| 72 |
+
|
| 73 |
+
<div className="p-4 border-t border-slate-100">
|
| 74 |
+
<div className="flex items-center gap-3 px-4 py-2 text-sm text-slate-500">
|
| 75 |
+
<div className="w-8 h-8 rounded-full bg-slate-200 flex items-center justify-center">U</div>
|
| 76 |
+
<span>User</span>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
</aside>
|
| 80 |
+
|
| 81 |
+
{/* --- Main Content --- */}
|
| 82 |
+
<main className="flex-1 flex flex-col h-full relative">
|
| 83 |
+
|
| 84 |
+
{/* --- Header (Mobile/Desktop) --- */}
|
| 85 |
+
<header className="h-16 flex items-center justify-between px-4 md:px-8 border-b border-slate-200 bg-white/80 backdrop-blur-md sticky top-0 z-10">
|
| 86 |
+
<button
|
| 87 |
+
className="md:hidden p-2 -ml-2 text-slate-600"
|
| 88 |
+
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
|
| 89 |
+
>
|
| 90 |
+
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" /></svg>
|
| 91 |
+
</button>
|
| 92 |
+
<div className="text-sm font-semibold text-slate-500">Model: DeepSeek-R1 (Simulated)</div>
|
| 93 |
+
<div className="w-8 h-8 rounded-full bg-gradient-to-br from-indigo-500 to-purple-500 flex items-center justify-center text-white text-xs font-bold">
|
| 94 |
+
AI
|
| 95 |
+
</div>
|
| 96 |
+
</header>
|
| 97 |
+
|
| 98 |
+
{/* --- Chat Area --- */}
|
| 99 |
+
<div className="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 scroll-smooth">
|
| 100 |
+
{messages.length === 0 && (
|
| 101 |
+
<div className="h-full flex flex-col items-center justify-center text-slate-400">
|
| 102 |
+
<svg className="w-16 h-16 mb-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" /></svg>
|
| 103 |
+
<p>Start a new conversation</p>
|
| 104 |
+
</div>
|
| 105 |
+
)}
|
| 106 |
+
|
| 107 |
+
{messages.map((msg) => (
|
| 108 |
+
<div
|
| 109 |
+
key={msg.id}
|
| 110 |
+
className={`flex gap-4 max-w-3xl mx-auto w-full ${msg.role === 'user' ? 'flex-row-reverse' : ''}`}
|
| 111 |
+
>
|
| 112 |
+
{/* Avatar */}
|
| 113 |
+
<div className={`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold text-white ${msg.role === 'user' ? 'bg-indigo-500' : 'bg-blue-500'}`}>
|
| 114 |
+
{msg.role === 'user' ? 'U' : 'AI'}
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
{/* Message Bubble */}
|
| 118 |
+
<div className={`flex-1 rounded-2xl px-5 py-3 shadow-sm text-sm md:text-base leading-relaxed ${
|
| 119 |
+
msg.role === 'user'
|
| 120 |
+
? 'bg-indigo-600 text-white rounded-tr-sm'
|
| 121 |
+
: 'bg-white border border-slate-200 text-slate-800 rounded-tl-sm'
|
| 122 |
+
}`}>
|
| 123 |
+
<div className="whitespace-pre-wrap">{msg.content}</div>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
))}
|
| 127 |
+
|
| 128 |
+
{isLoading && (
|
| 129 |
+
<div className="flex gap-4 max-w-3xl mx-auto w-full">
|
| 130 |
+
<div className="flex-shrink-0 w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-xs font-bold text-white">AI</div>
|
| 131 |
+
<div className="bg-white border border-slate-200 rounded-2xl px-5 py-3 shadow-sm flex items-center gap-1">
|
| 132 |
+
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce"></span>
|
| 133 |
+
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce delay-75"></span>
|
| 134 |
+
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce delay-150"></span>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
)}
|
| 138 |
+
|
| 139 |
+
<div ref={messagesEndRef} />
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
{/* --- Input Area --- */}
|
| 143 |
+
<div className="p-4 md:p-8 bg-white border-t border-slate-200">
|
| 144 |
+
<form onSubmit={handleSend} className="max-w-3xl mx-auto relative">
|
| 145 |
+
<div className="relative flex items-center bg-slate-100 rounded-2xl border border-slate-200 focus-within:border-indigo-500 focus-within:ring-2 focus-within:ring-indigo-100 transition-all">
|
| 146 |
+
<input
|
| 147 |
+
type="text"
|
| 148 |
+
value={input}
|
| 149 |
+
onChange={(e) => setInput(e.target.value)}
|
| 150 |
+
placeholder="Type a message..."
|
| 151 |
+
className="w-full bg-transparent border-none outline-none px-6 py-4 text-slate-700 placeholder:text-slate-400"
|
| 152 |
+
disabled={isLoading}
|
| 153 |
+
/>
|
| 154 |
+
<button
|
| 155 |
+
type="submit"
|
| 156 |
+
disabled={isLoading || !input.trim()}
|
| 157 |
+
className="absolute right-2 p-2 bg-indigo-600 hover:bg-indigo-700 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl transition-colors"
|
| 158 |
+
>
|
| 159 |
+
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" /></svg>
|
| 160 |
+
</button>
|
| 161 |
+
</div>
|
| 162 |
+
<div className="text-center mt-3">
|
| 163 |
+
<p className="text-xs text-slate-400">AI can make mistakes. Consider checking important information.</p>
|
| 164 |
+
</div>
|
| 165 |
+
</form>
|
| 166 |
+
</div>
|
| 167 |
+
</main>
|
| 168 |
+
|
| 169 |
+
{/* --- Mobile Menu Overlay --- */}
|
| 170 |
+
{isMobileMenuOpen && (
|
| 171 |
+
<div className="fixed inset-0 bg-black/50 z-20 md:hidden" onClick={() => setIsMobileMenuOpen(false)}></div>
|
| 172 |
+
)}
|
| 173 |
+
<aside className={`fixed top-0 left-0 h-full w-64 bg-white z-30 transform transition-transform duration-300 md:hidden ${isMobileMenuOpen ? 'translate-x-0' : '-translate-x-full'}`}>
|
| 174 |
+
<div className="p-6 border-b border-slate-100 flex justify-between items-center">
|
| 175 |
+
<h1 className="text-xl font-bold">AI Playground</h1>
|
| 176 |
+
<button onClick={() => setIsMobileMenuOpen(false)} className="text-slate-500">
|
| 177 |
+
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" /></svg>
|
| 178 |
+
</button>
|
| 179 |
+
</div>
|
| 180 |
+
<nav className="p-4 space-y-2">
|
| 181 |
+
<a href="#" className="block px-4 py-3 bg-blue-50 text-blue-700 rounded-xl font-medium">New Chat</a>
|
| 182 |
+
<a href="#" className="block px-4 py-3 text-slate-600 hover:bg-slate-50 rounded-xl font-medium">History</a>
|
| 183 |
+
<a href="#" className="block px-4 py-3 text-slate-600 hover:bg-slate-50 rounded-xl font-medium">Settings</a>
|
| 184 |
+
</nav>
|
| 185 |
+
</aside>
|
| 186 |
+
</div>
|
| 187 |
+
);
|
| 188 |
+
};
|
| 189 |
+
|
| 190 |
+
export default App;
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# No additional dependencies required
|