Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Bharat AI</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <style> | |
| body { | |
| margin: 0; | |
| background: #121212; | |
| font-family: 'Segoe UI', sans-serif; | |
| color: #fff; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| padding-top: 20px; | |
| } | |
| img.logo { | |
| max-width: 180px; | |
| border-radius: 12px; | |
| margin-bottom: 20px; | |
| } | |
| h1 { | |
| color: #00ffc8; | |
| } | |
| .chatbox { | |
| width: 90%; | |
| max-width: 700px; | |
| background: #1e1e1e; | |
| border-radius: 10px; | |
| padding: 15px; | |
| margin-bottom: 20px; | |
| overflow-y: auto; | |
| height: 400px; | |
| box-shadow: 0 0 10px rgba(0, 255, 200, 0.4); | |
| } | |
| .input-area, .upload-area { | |
| display: flex; | |
| width: 90%; | |
| max-width: 700px; | |
| margin-bottom: 10px; | |
| } | |
| input[type="text"], input[type="file"], input[type="password"], input[type="email"] { | |
| flex: 1; | |
| padding: 10px; | |
| border: none; | |
| border-radius: 8px; | |
| font-size: 16px; | |
| margin-right: 10px; | |
| } | |
| button { | |
| background: #00ffc8; | |
| border: none; | |
| padding: 10px 15px; | |
| cursor: pointer; | |
| border-radius: 8px; | |
| font-size: 16px; | |
| } | |
| #authSection, #mainApp { display: none; } | |
| </style> | |
| </head> | |
| <body> | |
| <img src="logo.jpg" alt="Bharat AI Logo" class="logo"> | |
| <h1>BHARAT AI</h1> | |
| <div id="authSection"> | |
| <input type="email" id="email" placeholder="Enter email"> | |
| <input type="password" id="password" placeholder="Create a password"> | |
| <button onclick="registerUser()">Register & Login</button> | |
| </div> | |
| <div id="mainApp"> | |
| <div class="chatbox" id="chatbox"></div> | |
| <div class="input-area"> | |
| <input type="text" id="userInput" placeholder="Ask something..." /> | |
| <button onclick="sendMessage()">Send</button> | |
| </div> | |
| <div class="upload-area"> | |
| <input type="file" id="mediaInput" /> | |
| <button onclick="uploadMedia()">Upload</button> | |
| </div> | |
| <div class="input-area"> | |
| <button onclick="generateImage()">🖼 Generate Image</button> | |
| <button onclick="generateVideo()">🎥 Generate Video</button> | |
| </div> | |
| </div> | |
| <script> | |
| window.onload = () => { | |
| document.getElementById('authSection').style.display = 'block'; | |
| }; | |
| function registerUser() { | |
| const email = document.getElementById('email').value; | |
| const pass = document.getElementById('password').value; | |
| if (email && pass) { | |
| localStorage.setItem('user', JSON.stringify({ email, pass })); | |
| document.getElementById('authSection').style.display = 'none'; | |
| document.getElementById('mainApp').style.display = 'block'; | |
| } else { | |
| alert("Enter both email and password."); | |
| } | |
| } | |
| async function sendMessage() { | |
| const input = document.getElementById('userInput'); | |
| const chatbox = document.getElementById('chatbox'); | |
| const userMessage = input.value.trim(); | |
| if (!userMessage) return; | |
| chatbox.innerHTML += `<div><strong>You:</strong> ${userMessage}</div>`; | |
| input.value = ""; | |
| const response = await fetch("https://api-inference.huggingface.co/models/microsoft/Phi-3-mini-4k-instruct", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| "Authorization": "Bearer hf_HF_TOKEN_HERE" | |
| }, | |
| body: JSON.stringify({ | |
| inputs: userMessage | |
| }) | |
| }); | |
| const data = await response.json(); | |
| const reply = data?.[0]?.generated_text || "Sorry, no response."; | |
| chatbox.innerHTML += `<div><strong>Bharat AI:</strong> ${reply}</div>`; | |
| chatbox.scrollTop = chatbox.scrollHeight; | |
| } | |
| function uploadMedia() { | |
| const file = document.getElementById('mediaInput').files[0]; | |
| if (!file) return alert("Select a file first."); | |
| alert(`Media '${file.name}' uploaded successfully.`); // Simulated | |
| } | |
| function generateImage() { | |
| alert("Image generation will be added soon. This is a placeholder."); | |
| } | |
| function generateVideo() { | |
| alert("Video generation requires advanced setup. Coming soon!"); | |
| } | |
| </script> | |
| </body> | |
| </html> | |