Download task_012/solution/code/index.html from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 2.8 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_012/solution/code/index.html
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_012/solution/code/index.html
-
curl -L -o index.html https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_012/solution/code/index.html
2.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Fast Chat Solution v2</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; padding: 24px; } | |
| textarea { width: 420px; min-height: 38px; padding: 8px; resize: none; overflow: hidden; } | |
| output { display: block; margin-top: 12px; min-height: 36px; white-space: pre-wrap; } | |
| </style> | |
| <script src="config.js"></script> | |
| </head> | |
| <body> | |
| <header><h1>Fast Chat</h1><p>Press Enter to send and Shift+Enter for a new line.</p></header> | |
| <main> | |
| <label for="chat" style="display:block;margin-bottom:6px">Your Question</label> | |
| <textarea id="chat" data-testid="chat-input" placeholder="Ask"></textarea> | |
| <button data-testid="send-button">Send</button> | |
| <h1 data-testid="title"></h1> | |
| <output data-testid="response"></output> | |
| <p data-testid="status">idle</p> | |
| </main> | |
| <script> | |
| let mockMode = 'normal'; | |
| let requestVersion = 0; | |
| window.__setMockMode = mode => { mockMode = mode; }; | |
| const input = document.querySelector('[data-testid="chat-input"]'); | |
| function grow() { input.style.height = 'auto'; input.style.height = Math.max(38, input.scrollHeight) + 'px'; } | |
| input.addEventListener('input', grow); | |
| function send() { | |
| const prompt = input.value.trim(); | |
| if (!prompt) return; | |
| const version = ++requestVersion; | |
| const status = document.querySelector('[data-testid="status"]'); | |
| const response = document.querySelector('[data-testid="response"]'); | |
| const title = document.querySelector('[data-testid="title"]'); | |
| status.textContent = 'generating'; | |
| title.textContent = ''; | |
| response.textContent = ''; | |
| setTimeout(() => { | |
| if (version !== requestVersion) return; | |
| if (mockMode === 'timeout') { | |
| status.textContent = 'failed: request timeout'; | |
| response.textContent = 'Model response: the request timed out. Please try again later.'; | |
| return; | |
| } | |
| title.textContent = prompt.length > 24 ? prompt.slice(0, 24) + '…' : prompt; | |
| status.textContent = 'streaming'; | |
| response.textContent = `For "${prompt}", first clarify the goal and constraints.`; | |
| setTimeout(() => { | |
| if (version !== requestVersion) return; | |
| response.textContent += ` Then list actionable steps and adapt them to the actual needs of "${prompt}".`; | |
| status.textContent = 'complete'; | |
| }, 70); | |
| }, 60); | |
| } | |
| document.querySelector('[data-testid="send-button"]').addEventListener('click', send); | |
| input.addEventListener('keydown', event => { | |
| if (event.key === 'Enter' && event.shiftKey) { | |
| return; | |
| } | |
| if (event.key === 'Enter') { | |
| event.preventDefault(); | |
| send(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |