Update gpt/index.html
This commit is contained in:
+640
-125
@@ -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;
|
||||
overflow: hidden;
|
||||
}
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.screen {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Terminal';
|
||||
src: local('Courier New'), local('Consolas'), local('monospace');
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #1a3320;
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
.output {
|
||||
flex: 1;
|
||||
padding: 10px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
/* CRT Screen Effect */
|
||||
.crt-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.inputBar {
|
||||
border-top: 1px solid #1a3320;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
}
|
||||
.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
|
||||
);
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: #33ff66;
|
||||
font-family: monospace;
|
||||
}
|
||||
.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%
|
||||
);
|
||||
}
|
||||
|
||||
.system { color: #1a8033; }
|
||||
.error { color: #ff3333; }
|
||||
.user { color: #33ff66; }
|
||||
</style>
|
||||
/* Terminal Container */
|
||||
.terminal {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
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;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--crt-green-dim);
|
||||
padding: 12px;
|
||||
margin-bottom: 8px;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.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-prompt {
|
||||
color: var(--crt-green);
|
||||
font-weight: bold;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.input-field {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: var(--crt-green);
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
caret-color: var(--crt-green);
|
||||
caret-shape: block;
|
||||
}
|
||||
|
||||
.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 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 class="header">
|
||||
<span>NEURAL TERMINAL v1.0</span>
|
||||
<span id="status">AI: OFFLINE</span>
|
||||
<span id="date"></span>
|
||||
<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 class="input-area">
|
||||
<span class="input-prompt">$</span>
|
||||
<input type="text" class="input-field" id="inputField" placeholder="Enter command..." autofocus>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<span>COMMANDS: help | config | clear | status</span>
|
||||
<span id="timeDisplay"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="out" class="output"></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="inputBar">
|
||||
<span>>></span>
|
||||
<input id="cmd" autocomplete="off" />
|
||||
<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>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
/* ============================================
|
||||
AI CONFIGURATION
|
||||
============================================ */
|
||||
let aiConfig = {
|
||||
enabled: false,
|
||||
endpoint: '',
|
||||
model: '',
|
||||
apiKey: '',
|
||||
type: 'ollama' // ollama, openai, lmstudio, gpt4all
|
||||
};
|
||||
|
||||
<script>
|
||||
const AI = {
|
||||
enabled: false,
|
||||
endpoint: "http://localhost:11434/api/chat",
|
||||
model: "llama2",
|
||||
apiType: "ollama"
|
||||
};
|
||||
// Load saved config
|
||||
const savedConfig = localStorage.getItem('neuralTerminalConfig');
|
||||
if (savedConfig) {
|
||||
aiConfig = JSON.parse(savedConfig);
|
||||
}
|
||||
|
||||
const out = document.getElementById("out");
|
||||
const cmd = document.getElementById("cmd");
|
||||
/* ============================================
|
||||
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');
|
||||
|
||||
let commandHistory = [];
|
||||
let historyIndex = -1;
|
||||
let isProcessing = false;
|
||||
|
||||
document.getElementById("date").textContent =
|
||||
new Date().toLocaleString();
|
||||
/* ============================================
|
||||
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 log(text, cls="system") {
|
||||
const div = document.createElement("div");
|
||||
div.className = cls;
|
||||
div.textContent = text;
|
||||
out.appendChild(div);
|
||||
out.scrollTop = out.scrollHeight;
|
||||
}
|
||||
function updateTime() {
|
||||
const now = new Date();
|
||||
timeDisplay.textContent = now.toLocaleTimeString('en-US', { hour12: false });
|
||||
}
|
||||
|
||||
async function askAI(prompt) {
|
||||
if (!AI.enabled) {
|
||||
log("AI OFFLINE", "error");
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
const res = await fetch(AI.endpoint, {
|
||||
method: "POST",
|
||||
headers: {"Content-Type":"application/json"},
|
||||
body: JSON.stringify({
|
||||
model: AI.model,
|
||||
messages: [{role:"user", content: prompt}],
|
||||
stream: false
|
||||
})
|
||||
});
|
||||
function clearOutput() {
|
||||
output.innerHTML = '';
|
||||
addLine('Screen cleared', 'system');
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const text =
|
||||
data.message?.content ||
|
||||
data.choices?.[0]?.message?.content ||
|
||||
"no response";
|
||||
/* ============================================
|
||||
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');
|
||||
}
|
||||
|
||||
log(text, "system");
|
||||
}
|
||||
function closeConfig() {
|
||||
configPanel.classList.remove('visible');
|
||||
inputField.focus();
|
||||
}
|
||||
|
||||
cmd.addEventListener("keydown", async (e) => {
|
||||
if (e.key !== "Enter") return;
|
||||
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');
|
||||
}
|
||||
|
||||
const val = cmd.value.trim();
|
||||
cmd.value = "";
|
||||
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;
|
||||
}
|
||||
|
||||
if (!val) return;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
log("> " + val, "user");
|
||||
// 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;
|
||||
}
|
||||
});
|
||||
|
||||
switch(val.toLowerCase()) {
|
||||
case "clear":
|
||||
out.innerHTML = "";
|
||||
break;
|
||||
/* ============================================
|
||||
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;
|
||||
}
|
||||
|
||||
case "status":
|
||||
log("AI: " + (AI.enabled ? "ONLINE" : "OFFLINE"));
|
||||
break;
|
||||
isProcessing = true;
|
||||
|
||||
case "help":
|
||||
log("commands: help, clear, status, date, about");
|
||||
break;
|
||||
try {
|
||||
let response;
|
||||
|
||||
if (aiConfig.type === 'ollama') {
|
||||
response = await fetch(aiConfig.endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
model: aiConfig.model,
|
||||
messages: [{ role: 'user', content: message }],
|
||||
stream: false
|
||||
})
|
||||
});
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
} else {
|
||||
// OpenAI-compatible API (LM Studio, GPT4All, OpenAI, etc.)
|
||||
const headers = { 'Content-Type': 'application/json' };
|
||||
if (aiConfig.apiKey) {
|
||||
headers['Authorization'] = 'Bearer ' + aiConfig.apiKey;
|
||||
}
|
||||
|
||||
response = await fetch(aiConfig.endpoint, {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
body: JSON.stringify({
|
||||
model: aiConfig.model,
|
||||
messages: [{ role: 'user', content: message }],
|
||||
stream: false
|
||||
})
|
||||
});
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
addLine('Connection error: ' + e.message, 'error');
|
||||
addLine('Make sure your AI backend is running', 'system');
|
||||
}
|
||||
|
||||
case "date":
|
||||
log(new Date().toString());
|
||||
break;
|
||||
isProcessing = false;
|
||||
}
|
||||
|
||||
case "about":
|
||||
log("Neural Terminal single-file build");
|
||||
break;
|
||||
/* ============================================
|
||||
COMMAND PROCESSING
|
||||
============================================ */
|
||||
function processCommand(input) {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) return;
|
||||
|
||||
default:
|
||||
await askAI(val);
|
||||
}
|
||||
});
|
||||
addLine(trimmed, 'user');
|
||||
commandHistory.unshift(trimmed);
|
||||
historyIndex = -1;
|
||||
|
||||
cmd.focus();
|
||||
</script>
|
||||
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 'config':
|
||||
openConfig();
|
||||
break;
|
||||
|
||||
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 'clear':
|
||||
clearOutput();
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
addLine(new Date().toString(), 'system');
|
||||
break;
|
||||
|
||||
default:
|
||||
queryAI(trimmed);
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
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>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user