|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Vision AI</title> |
| 7 | + <script src="https://cdn.tailwindcss.com"></script> |
| 8 | + <style> |
| 9 | + body { background: #000; color: #fff; font-family: 'Inter', sans-serif; margin: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; } |
| 10 | + .chat-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: none; } |
| 11 | + .chat-container::-webkit-scrollbar { display: none; } |
| 12 | + .msg { max-width: 85%; padding: 12px 16px; border-radius: 18px; font-size: 13px; line-height: 1.5; } |
| 13 | + .msg.user { background: #1c1c1e; align-self: flex-end; border-bottom-right-radius: 4px; color: #e4e4e7; } |
| 14 | + .msg.ai { background: rgba(139, 92, 246, 0.1); align-self: flex-start; border-bottom-left-radius: 4px; border: 1px solid rgba(139, 92, 246, 0.2); } |
| 15 | + .input-area { padding: 20px; border-top: 1px solid rgba(255,255,255,0.05); background: #000; } |
| 16 | + .input-box { width: 100%; background: #1c1c1e; border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 12px 16px; color: #fff; outline: none; transition: border-color 0.2s; } |
| 17 | + .input-box:focus { border-color: #8b5cf6; } |
| 18 | + </style> |
| 19 | +</head> |
| 20 | +<body> |
| 21 | + <div class="chat-container" id="chat"> |
| 22 | + <div class="msg ai">Welcome to Vision AI. I'm your browsing assistant. Ask me to summarize a page, find information, or just chat.</div> |
| 23 | + </div> |
| 24 | + <div class="input-area"> |
| 25 | + <input type="text" id="input" class="input-box" placeholder="Message Vision AI..." autocomplete="off"> |
| 26 | + </div> |
| 27 | + |
| 28 | + <script type="module"> |
| 29 | + import { GoogleGenAI } from "@google/genai"; |
| 30 | + const input = document.getElementById('input'); |
| 31 | + const chat = document.getElementById('chat'); |
| 32 | + |
| 33 | + function addMsg(text, sender) { |
| 34 | + const el = document.createElement('div'); |
| 35 | + el.className = `msg ${sender}`; |
| 36 | + el.textContent = text; |
| 37 | + chat.appendChild(el); |
| 38 | + chat.scrollTop = chat.scrollHeight; |
| 39 | + return el; |
| 40 | + } |
| 41 | + |
| 42 | + input.onkeydown = async (e) => { |
| 43 | + if (e.key === 'Enter' && input.value.trim()) { |
| 44 | + const query = input.value.trim(); |
| 45 | + input.value = ''; |
| 46 | + addMsg(query, 'user'); |
| 47 | + |
| 48 | + const aiMsg = addMsg('Thinking...', 'ai'); |
| 49 | + |
| 50 | + try { |
| 51 | + const aiClient = new GoogleGenAI({ apiKey: window.process?.env?.API_KEY }); |
| 52 | + const response = await aiClient.models.generateContent({ |
| 53 | + model: 'gemini-2.5-flash-lite-latest', |
| 54 | + contents: query, |
| 55 | + config: { systemInstruction: "You are Vision AI, a helpful browser assistant built into the Vision Browser. Be concise and friendly." } |
| 56 | + }); |
| 57 | + aiMsg.textContent = response.text || "I'm sorry, I couldn't generate a response."; |
| 58 | + } catch (err) { |
| 59 | + aiMsg.textContent = "Error: System connection restricted."; |
| 60 | + console.error(err); |
| 61 | + } |
| 62 | + } |
| 63 | + }; |
| 64 | + </script> |
| 65 | +</body> |
| 66 | +</html> |
0 commit comments