Ai_project / index.html
Pro-Creator-16's picture
Update index.html
d815908 verified
Raw
History Blame Contribute Delete
3.84 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Real Browser AI</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background-color: #0b0f19;
color: #f3f4f6;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
margin: 0;
}
.container {
background: #111827;
padding: 30px;
border-radius: 20px;
box-shadow: 0 10px 25px rgba(0,0,0,0.5);
max-width: 500px;
width: 100%;
text-align: center;
border: 1px solid #1f2937;
}
h1 { color: #10b981; margin-top: 0; text-shadow: 0 0 15px rgba(16,185,129,0.3); }
p { color: #9ca3af; font-size: 14px; }
input, button {
width: 100%;
padding: 14px;
margin: 12px 0;
border-radius: 10px;
border: 1px solid #374151;
box-sizing: border-box;
font-size: 16px;
background: #1f2937;
color: white;
outline: none;
}
button {
background-color: #10b981;
color: white;
font-weight: bold;
border: none;
cursor: pointer;
}
button:hover { background-color: #059669; }
#output {
margin-top: 20px;
padding: 18px;
background: #1f2937;
border-radius: 10px;
border-left: 5px solid #10b981;
text-align: left;
min-height: 60px;
white-space: pre-wrap;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="container">
<h1>🧠 In-Browser AI Engine</h1>
<p>Loading a real AI model directly into your iPad's memory!</p>
<input type="text" id="userInput" placeholder="Type absolutely anything...">
<button id="aiBtn" onclick="askBrowserAI()" disabled>Loading AI Brain...</button>
<div id="output">Please wait about 10 seconds for the AI brain to load into your browser memory...</div>
</div>
<!-- Loads the official Hugging Face web model runner -->
<script type="module">
import { pipeline } from 'https://jsdelivr.net';
let generator;
const outputDiv = document.getElementById('output');
const aiBtn = document.getElementById('aiBtn');
// Automatically load a tiny 100% real text model into the iPad browser memory
async function initAI() {
try {
generator = await pipeline('text-generation', 'Xenova/Qwen1.5-0.5B-Chat');
outputDiv.innerText = "✨ AI Brain loaded completely offline! Type your prompt and test it out.";
aiBtn.innerText = "Generate Response";
aiBtn.disabled = false;
} catch (e) {
outputDiv.innerText = "Error loading browser memory model. Refresh the page to try again.";
}
}
initAI();
window.askBrowserAI = async function() {
const input = document.getElementById('userInput').value.trim();
if (!input || !generator) return;
outputDiv.innerText = "⚡ Your iPad chip is generating text right now...";
try {
// Run the actual neural network text generation locally
const result = await generator(input, {
max_new_tokens: 40,
temperature: 0.7
});
outputDiv.innerText = result[0].generated_text;
} catch (error) {
outputDiv.innerText = "Memory crunch error. Keep your prompt shorter!";
}
}
</script>
</body>
</html>