Update gpt/index.html

This commit is contained in:
2026-05-10 17:12:52 +02:00
parent d868576b65
commit 86572e0842
+603 -88
View File
@@ -1,164 +1,679 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Neural Terminal</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEURAL-NET TERMINAL v2.1</title>
<style>
/* ============================================
AI BACKEND CONFIGURATION
Edit these settings to connect your AI
============================================ */
:root {
--crt-green: #33ff66;
--crt-green-dim: #1a8033;
--crt-green-bright: #66ff99;
--crt-bg: #0a0a0a;
--crt-bg-light: #0f1a0f;
--crt-border: #1a3d1a;
}
<style>
body {
* {
margin: 0;
background: #050805;
color: #33ff66;
font-family: monospace;
padding: 0;
box-sizing: border-box;
}
@font-face {
font-family: 'Terminal';
src: local('Courier New'), local('Consolas'), local('monospace');
}
body {
background: var(--crt-bg);
color: var(--crt-green);
font-family: 'Courier New', Consolas, monospace;
font-size: 14px;
line-height: 1.4;
min-height: 100vh;
overflow: hidden;
}
.screen {
/* CRT Screen Effect */
.crt-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
z-index: 1000;
}
.crt-overlay::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: repeating-linear-gradient(
0deg,
rgba(0, 0, 0, 0.15) 0px,
rgba(0, 0, 0, 0.15) 1px,
transparent 1px,
transparent 2px
);
}
.crt-overlay::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(
ellipse at center,
transparent 0%,
rgba(0, 0, 0, 0.3) 100%
);
}
/* Terminal Container */
.terminal {
height: 100vh;
display: flex;
flex-direction: column;
padding: 8px;
}
/* Header */
.header {
padding: 8px;
border-bottom: 1px solid #1a3320;
font-size: 12px;
border: 1px solid var(--crt-green-dim);
padding: 8px 12px;
margin-bottom: 8px;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
}
.header-title {
font-weight: bold;
letter-spacing: 2px;
}
.header-status {
display: flex;
gap: 16px;
font-size: 12px;
color: var(--crt-green-dim);
}
.status-indicator {
display: flex;
align-items: center;
gap: 6px;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--crt-green-dim);
}
.status-dot.online {
background: var(--crt-green);
box-shadow: 0 0 6px var(--crt-green);
}
.status-dot.offline {
background: #ff3333;
box-shadow: 0 0 6px #ff3333;
}
/* Output Area */
.output {
flex: 1;
padding: 10px;
overflow-y: auto;
white-space: pre-wrap;
border: 1px solid var(--crt-green-dim);
padding: 12px;
margin-bottom: 8px;
scrollbar-width: none;
}
.inputBar {
border-top: 1px solid #1a3320;
padding: 10px;
.output::-webkit-scrollbar {
display: none;
}
.output-line {
margin-bottom: 4px;
word-wrap: break-word;
}
.output-line.user {
color: var(--crt-green-bright);
}
.output-line.user::before {
content: '> ';
color: var(--crt-green-dim);
}
.output-line.system {
color: var(--crt-green-dim);
font-style: italic;
}
.output-line.ai {
color: var(--crt-green);
padding-left: 2ch;
}
.output-line.error {
color: #ff6666;
}
/* Input Area */
.input-area {
border: 1px solid var(--crt-green-dim);
padding: 8px 12px;
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
input {
.input-prompt {
color: var(--crt-green);
font-weight: bold;
flex-shrink: 0;
}
.input-field {
flex: 1;
background: transparent;
border: none;
outline: none;
color: #33ff66;
font-family: monospace;
color: var(--crt-green);
font-family: inherit;
font-size: inherit;
caret-color: var(--crt-green);
caret-shape: block;
}
.system { color: #1a8033; }
.error { color: #ff3333; }
.user { color: #33ff66; }
</style>
.input-field::placeholder {
color: var(--crt-green-dim);
}
/* Footer */
.footer {
display: flex;
justify-content: space-between;
padding: 4px 0;
font-size: 11px;
color: var(--crt-green-dim);
flex-shrink: 0;
}
/* Config Panel */
.config-panel {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: var(--crt-bg);
border: 2px solid var(--crt-green);
padding: 20px;
z-index: 100;
min-width: 400px;
max-width: 90vw;
}
.config-panel.visible {
display: block;
}
.config-panel h2 {
margin-bottom: 16px;
font-size: 14px;
letter-spacing: 2px;
}
.config-group {
margin-bottom: 12px;
}
.config-group label {
display: block;
margin-bottom: 4px;
color: var(--crt-green-dim);
font-size: 12px;
}
.config-group input,
.config-group select {
width: 100%;
background: var(--crt-bg-light);
border: 1px solid var(--crt-green-dim);
color: var(--crt-green);
padding: 6px 8px;
font-family: inherit;
font-size: 13px;
}
.config-group input:focus,
.config-group select:focus {
outline: none;
border-color: var(--crt-green);
}
.config-buttons {
display: flex;
gap: 8px;
margin-top: 16px;
}
.config-btn {
flex: 1;
background: transparent;
border: 1px solid var(--crt-green-dim);
color: var(--crt-green);
padding: 8px;
font-family: inherit;
cursor: pointer;
}
.config-btn:hover {
background: var(--crt-green-dim);
color: var(--crt-bg);
}
.config-btn.primary {
border-color: var(--crt-green);
}
/* Screen flicker animation */
@keyframes flicker {
0%, 100% { opacity: 1; }
92% { opacity: 1; }
93% { opacity: 0.8; }
94% { opacity: 1; }
}
.terminal {
animation: flicker 8s infinite;
}
</style>
</head>
<body>
<div class="screen">
<div class="crt-overlay"></div>
<div class="terminal">
<div class="header">
<span>NEURAL TERMINAL v1.0</span>
<span id="status">AI: OFFLINE</span>
<span id="date"></span>
<span class="header-title">NEURAL-NET TERMINAL v2.1</span>
<div class="header-status">
<div class="status-indicator">
<span class="status-dot" id="statusDot"></span>
<span id="statusText">OFFLINE</span>
</div>
</div>
</div>
<div id="out" class="output"></div>
<div class="inputBar">
<span>>></span>
<input id="cmd" autocomplete="off" />
<div class="output" id="output">
<div class="output-line system">NEURAL-NET TERMINAL v2.1 initialized</div>
<div class="output-line system">Type 'help' for available commands</div>
<div class="output-line system">Type 'config' to configure AI backend</div>
<div class="output-line system">─────────────────────────────────────</div>
</div>
</div>
<div class="input-area">
<span class="input-prompt">$</span>
<input type="text" class="input-field" id="inputField" placeholder="Enter command..." autofocus>
</div>
<script>
const AI = {
<div class="footer">
<span>COMMANDS: help | config | clear | status</span>
<span id="timeDisplay"></span>
</div>
</div>
<!-- Config Panel -->
<div class="config-panel" id="configPanel">
<h2>[ AI BACKEND CONFIGURATION ]</h2>
<div class="config-group">
<label>PRESET</label>
<select id="presetSelect">
<option value="custom">Custom</option>
<option value="ollama">Ollama (localhost:11434)</option>
<option value="lmstudio">LM Studio (localhost:1234)</option>
<option value="gpt4all">GPT4All (localhost:4891)</option>
<option value="openai">OpenAI API</option>
</select>
</div>
<div class="config-group">
<label>ENDPOINT URL</label>
<input type="text" id="endpointInput" placeholder="http://localhost:11434/api/chat">
</div>
<div class="config-group">
<label>MODEL NAME</label>
<input type="text" id="modelInput" placeholder="llama2">
</div>
<div class="config-group">
<label>API KEY (optional)</label>
<input type="password" id="apiKeyInput" placeholder="Leave empty for local models">
</div>
<div class="config-buttons">
<button class="config-btn" onclick="closeConfig()">CANCEL</button>
<button class="config-btn" onclick="testConnection()">TEST</button>
<button class="config-btn primary" onclick="saveConfig()">SAVE</button>
</div>
</div>
<script>
/* ============================================
AI CONFIGURATION
============================================ */
let aiConfig = {
enabled: false,
endpoint: "http://localhost:11434/api/chat",
model: "llama2",
apiType: "ollama"
};
endpoint: '',
model: '',
apiKey: '',
type: 'ollama' // ollama, openai, lmstudio, gpt4all
};
const out = document.getElementById("out");
const cmd = document.getElementById("cmd");
// Load saved config
const savedConfig = localStorage.getItem('neuralTerminalConfig');
if (savedConfig) {
aiConfig = JSON.parse(savedConfig);
}
document.getElementById("date").textContent =
new Date().toLocaleString();
/* ============================================
TERMINAL STATE
============================================ */
const output = document.getElementById('output');
const inputField = document.getElementById('inputField');
const statusDot = document.getElementById('statusDot');
const statusText = document.getElementById('statusText');
const timeDisplay = document.getElementById('timeDisplay');
const configPanel = document.getElementById('configPanel');
function log(text, cls="system") {
const div = document.createElement("div");
div.className = cls;
div.textContent = text;
out.appendChild(div);
out.scrollTop = out.scrollHeight;
}
let commandHistory = [];
let historyIndex = -1;
let isProcessing = false;
async function askAI(prompt) {
if (!AI.enabled) {
log("AI OFFLINE", "error");
/* ============================================
UI FUNCTIONS
============================================ */
function updateStatus() {
if (aiConfig.enabled) {
statusDot.className = 'status-dot online';
statusText.textContent = 'ONLINE';
} else {
statusDot.className = 'status-dot offline';
statusText.textContent = 'OFFLINE';
}
}
function updateTime() {
const now = new Date();
timeDisplay.textContent = now.toLocaleTimeString('en-US', { hour12: false });
}
function addLine(text, type = '') {
const line = document.createElement('div');
line.className = 'output-line' + (type ? ' ' + type : '');
line.textContent = text;
output.appendChild(line);
output.scrollTop = output.scrollHeight;
}
function clearOutput() {
output.innerHTML = '';
addLine('Screen cleared', 'system');
}
/* ============================================
CONFIG PANEL
============================================ */
function openConfig() {
document.getElementById('endpointInput').value = aiConfig.endpoint;
document.getElementById('modelInput').value = aiConfig.model;
document.getElementById('apiKeyInput').value = aiConfig.apiKey;
configPanel.classList.add('visible');
}
function closeConfig() {
configPanel.classList.remove('visible');
inputField.focus();
}
function saveConfig() {
aiConfig.endpoint = document.getElementById('endpointInput').value.trim();
aiConfig.model = document.getElementById('modelInput').value.trim();
aiConfig.apiKey = document.getElementById('apiKeyInput').value.trim();
aiConfig.enabled = aiConfig.endpoint !== '' && aiConfig.model !== '';
localStorage.setItem('neuralTerminalConfig', JSON.stringify(aiConfig));
updateStatus();
closeConfig();
addLine('Configuration saved', 'system');
}
async function testConnection() {
const endpoint = document.getElementById('endpointInput').value.trim();
const model = document.getElementById('modelInput').value.trim();
if (!endpoint || !model) {
alert('Please enter endpoint and model name');
return;
}
const res = await fetch(AI.endpoint, {
method: "POST",
headers: {"Content-Type":"application/json"},
try {
// Try a simple request based on detected type
const testEndpoint = endpoint.replace('/chat', '/tags').replace('/completions', '/models');
const response = await fetch(testEndpoint, {
method: 'GET',
headers: aiConfig.apiKey ? { 'Authorization': 'Bearer ' + aiConfig.apiKey } : {}
});
if (response.ok) {
alert('Connection successful!');
} else {
alert('Connection failed: ' + response.status);
}
} catch (e) {
alert('Connection error: ' + e.message);
}
}
// Preset handling
document.getElementById('presetSelect').addEventListener('change', function() {
const presets = {
ollama: { endpoint: 'http://localhost:11434/api/chat', model: 'llama2', type: 'ollama' },
lmstudio: { endpoint: 'http://localhost:1234/v1/chat/completions', model: 'local-model', type: 'openai' },
gpt4all: { endpoint: 'http://localhost:4891/v1/chat/completions', model: 'gpt4all-model', type: 'openai' },
openai: { endpoint: 'https://api.openai.com/v1/chat/completions', model: 'gpt-3.5-turbo', type: 'openai' }
};
const preset = presets[this.value];
if (preset) {
document.getElementById('endpointInput').value = preset.endpoint;
document.getElementById('modelInput').value = preset.model;
aiConfig.type = preset.type;
}
});
/* ============================================
AI COMMUNICATION
============================================ */
async function queryAI(message) {
if (!aiConfig.enabled) {
addLine('', '');
addLine('The AI you are trying to reach is not online at the moment.', 'error');
addLine('', '');
addLine('To connect an AI backend:', 'system');
addLine(' 1. Type "config" to open settings', 'system');
addLine(' 2. Choose a preset or enter custom endpoint', 'system');
addLine(' 3. Supported: Ollama, LM Studio, GPT4All, OpenAI', 'system');
return;
}
isProcessing = true;
try {
let response;
if (aiConfig.type === 'ollama') {
response = await fetch(aiConfig.endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: AI.model,
messages: [{role:"user", content: prompt}],
model: aiConfig.model,
messages: [{ role: 'user', content: message }],
stream: false
})
});
const data = await res.json();
const text =
data.message?.content ||
data.choices?.[0]?.message?.content ||
"no response";
const data = await response.json();
if (data.message && data.message.content) {
addLine(data.message.content, 'ai');
} else if (data.error) {
addLine('Error: ' + data.error, 'error');
}
log(text, "system");
}
} else {
// OpenAI-compatible API (LM Studio, GPT4All, OpenAI, etc.)
const headers = { 'Content-Type': 'application/json' };
if (aiConfig.apiKey) {
headers['Authorization'] = 'Bearer ' + aiConfig.apiKey;
}
cmd.addEventListener("keydown", async (e) => {
if (e.key !== "Enter") return;
response = await fetch(aiConfig.endpoint, {
method: 'POST',
headers: headers,
body: JSON.stringify({
model: aiConfig.model,
messages: [{ role: 'user', content: message }],
stream: false
})
});
const val = cmd.value.trim();
cmd.value = "";
const data = await response.json();
if (data.choices && data.choices[0]) {
addLine(data.choices[0].message.content, 'ai');
} else if (data.error) {
addLine('Error: ' + (data.error.message || data.error), 'error');
}
}
if (!val) return;
} catch (e) {
addLine('Connection error: ' + e.message, 'error');
addLine('Make sure your AI backend is running', 'system');
}
log("> " + val, "user");
isProcessing = false;
}
switch(val.toLowerCase()) {
case "clear":
out.innerHTML = "";
/* ============================================
COMMAND PROCESSING
============================================ */
function processCommand(input) {
const trimmed = input.trim();
if (!trimmed) return;
addLine(trimmed, 'user');
commandHistory.unshift(trimmed);
historyIndex = -1;
const cmd = trimmed.toLowerCase();
switch (cmd) {
case 'help':
addLine('', '');
addLine('Available commands:', 'system');
addLine(' help - Show this help', 'system');
addLine(' config - Configure AI backend', 'system');
addLine(' status - Show connection status', 'system');
addLine(' clear - Clear screen', 'system');
addLine(' date - Show current date/time', 'system');
addLine('', '');
addLine('Any other input is sent to the AI', 'system');
break;
case "status":
log("AI: " + (AI.enabled ? "ONLINE" : "OFFLINE"));
case 'config':
openConfig();
break;
case "help":
log("commands: help, clear, status, date, about");
case 'status':
addLine('', '');
addLine('CONNECTION STATUS:', 'system');
addLine(' Enabled: ' + (aiConfig.enabled ? 'YES' : 'NO'), 'system');
addLine(' Endpoint: ' + (aiConfig.endpoint || 'Not configured'), 'system');
addLine(' Model: ' + (aiConfig.model || 'Not configured'), 'system');
addLine(' Type: ' + (aiConfig.type || 'unknown'), 'system');
break;
case "date":
log(new Date().toString());
case 'clear':
clearOutput();
break;
case "about":
log("Neural Terminal single-file build");
case 'date':
addLine(new Date().toString(), 'system');
break;
default:
await askAI(val);
queryAI(trimmed);
}
}
});
cmd.focus();
</script>
/* ============================================
INPUT HANDLING
============================================ */
inputField.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !isProcessing) {
processCommand(this.value);
this.value = '';
} else if (e.key === 'ArrowUp') {
e.preventDefault();
if (historyIndex < commandHistory.length - 1) {
historyIndex++;
this.value = commandHistory[historyIndex];
}
} else if (e.key === 'ArrowDown') {
e.preventDefault();
if (historyIndex > 0) {
historyIndex--;
this.value = commandHistory[historyIndex];
} else {
historyIndex = -1;
this.value = '';
}
}
});
/* ============================================
INITIALIZATION
============================================ */
updateStatus();
updateTime();
setInterval(updateTime, 1000);
inputField.focus();
// Click anywhere to focus input
document.addEventListener('click', function(e) {
if (!configPanel.contains(e.target)) {
inputField.focus();
}
});
</script>
</body>
</html>