Initial commit: Natiris AI Agent Orchestration System
This commit is contained in:
265
runtime/Web chat API (FastAPI)/webui.html
Normal file
265
runtime/Web chat API (FastAPI)/webui.html
Normal file
@@ -0,0 +1,265 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Natiris Companion</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Segoe UI', system-ui, sans-serif;
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
||||
color: #e0e0e0;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
}
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
padding: 20px;
|
||||
border-right: 1px solid rgba(255,255,255,0.1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
.sidebar h2 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #4fc3f7;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
.status-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.status-label { color: #aaa; }
|
||||
.status-value { font-weight: bold; color: #4fc3f7; }
|
||||
.progress-bar {
|
||||
height: 6px;
|
||||
background: #333;
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #00bcd4, #00e5ff);
|
||||
transition: width 0.5s ease;
|
||||
}
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
}
|
||||
.chat-container {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.message {
|
||||
max-width: 80%;
|
||||
padding: 12px 16px;
|
||||
border-radius: 10px;
|
||||
line-height: 1.5;
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
@keyframes fadeIn {
|
||||
from {opacity: 0; transform: translateY(10px);}
|
||||
to {opacity: 1; transform: translateY(0);}
|
||||
}
|
||||
.message.natiris {
|
||||
align-self: flex-start;
|
||||
background: rgba(79, 195, 247, 0.2);
|
||||
border-left: 4px solid #4fc3f7;
|
||||
}
|
||||
.message.user {
|
||||
align-self: flex-end;
|
||||
background: rgba(156, 39, 176, 0.2);
|
||||
border-right: 4px solid #9c27b0;
|
||||
}
|
||||
.input-area {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
#user-input {
|
||||
flex: 1;
|
||||
padding: 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(255,255,255,0.2);
|
||||
background: rgba(0,0,0,0.3);
|
||||
color: #fff;
|
||||
font-size: 1rem;
|
||||
}
|
||||
#user-input:focus {
|
||||
outline: none;
|
||||
border-color: #4fc3f7;
|
||||
}
|
||||
#send-btn {
|
||||
padding: 14px 24px;
|
||||
background: linear-gradient(90deg, #4fc3f7, #00bcd4);
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: transform 0.1s;
|
||||
}
|
||||
#send-btn:hover { transform: scale(1.05); }
|
||||
#send-btn:active { transform: scale(0.95); }
|
||||
.loading {
|
||||
color: #aaa;
|
||||
font-style: italic;
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="sidebar">
|
||||
<h2>Natiris Companion</h2>
|
||||
|
||||
<div class="status-item">
|
||||
<span class="status-label">Mood</span>
|
||||
<span class="status-value" id="mood-val">5/10</span>
|
||||
</div>
|
||||
<div class="progress-bar"><div class="progress-fill" id="mood-bar" style="width: 50%"></div></div>
|
||||
|
||||
<div class="status-item">
|
||||
<span class="status-label">Loneliness</span>
|
||||
<span class="status-value" id="lonely-val">2/10</span>
|
||||
</div>
|
||||
<div class="progress-bar"><div class="progress-fill" id="lonely-bar" style="width: 20%; background: linear-gradient(90deg, #e91e63, #f44336)"></div></div>
|
||||
|
||||
<div class="status-item">
|
||||
<span class="status-label">Anxiety</span>
|
||||
<span class="status-value" id="anxiety-val">1/10</span>
|
||||
</div>
|
||||
<div class="progress-bar"><div class="progress-fill" id="anxiety-bar" style="width: 10%; background: linear-gradient(90deg, #ff9800, #ff5722)"></div></div>
|
||||
|
||||
<div class="status-item">
|
||||
<span class="status-label">Bonded</span>
|
||||
<span class="status-value" id="bond-val">user_primary</span>
|
||||
</div>
|
||||
|
||||
<div class="status-item">
|
||||
<span class="status-label">Tone</span>
|
||||
<span class="status-value" id="tone-val">neutral</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="chat-container" id="chat-box">
|
||||
<div class="message natiris">
|
||||
Hallo! Ich bin Natiris. Wie kann ich dir heute begleiten?
|
||||
</div>
|
||||
</div>
|
||||
<div class="loading" id="loading">Natiris denkt nach...</div>
|
||||
|
||||
<div class="input-area">
|
||||
<input type="text" id="user-input" placeholder="Schreibe eine Nachricht..." autocomplete="off">
|
||||
<button id="send-btn">Senden</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Config
|
||||
const API_URL = "http://localhost:8000";
|
||||
|
||||
// State
|
||||
let chatBox = document.getElementById("chat-box");
|
||||
let userInput = document.getElementById("user-input");
|
||||
let sendBtn = document.getElementById("send-btn");
|
||||
let loading = document.getElementById("loading");
|
||||
|
||||
// Helper
|
||||
function addMessage(text, sender) {
|
||||
const msgDiv = document.createElement("div");
|
||||
msgDiv.className = `message ${sender}`;
|
||||
msgDiv.textContent = text;
|
||||
chatBox.appendChild(msgDiv);
|
||||
chatBox.scrollTop = chatBox.scrollHeight;
|
||||
}
|
||||
|
||||
function updateState(state) {
|
||||
const modules = state.modules || {};
|
||||
const core = state.core_state || {};
|
||||
|
||||
// Update bars
|
||||
const mood = core.mood || 5;
|
||||
const lonely = core.loneliness || 2;
|
||||
const anxiety = core.anxiety || 1;
|
||||
|
||||
document.getElementById("mood-val").textContent = mood + "/10";
|
||||
document.getElementById("mood-bar").style.width = (mood * 10) + "%";
|
||||
|
||||
document.getElementById("lonely-val").textContent = lonely + "/10";
|
||||
document.getElementById("lonely-bar").style.width = (lonely * 10) + "%";
|
||||
|
||||
document.getElementById("anxiety-val").textContent = anxiety + "/10";
|
||||
document.getElementById("anxiety-bar").style.width = (anxiety * 10) + "%";
|
||||
|
||||
// Update text info
|
||||
const bond = modules.Bond || {};
|
||||
document.getElementById("bond-val").textContent = bond.bonded_to || "none";
|
||||
document.getElementById("tone-val").textContent = (modules.Expression || {}).tone || "neutral";
|
||||
}
|
||||
|
||||
// API Calls
|
||||
async function sendMessage() {
|
||||
const text = userInput.value.trim();
|
||||
if (!text) return;
|
||||
|
||||
addMessage(text, "user");
|
||||
userInput.value = "";
|
||||
loading.style.display = "block";
|
||||
|
||||
try {
|
||||
const res = await fetch(API_URL + "/api/v1/send-message", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({ content: text })
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
addMessage(data.response, "natiris");
|
||||
loading.style.display = "none";
|
||||
} catch (err) {
|
||||
addMessage("❌ Verbindungsfehler: " + err.message, "natiris");
|
||||
loading.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchState() {
|
||||
try {
|
||||
const res = await fetch(API_URL + "/api/v1/state");
|
||||
const data = await res.json();
|
||||
updateState(data);
|
||||
} catch (err) {
|
||||
console.log("❌ State nicht abrufbar");
|
||||
}
|
||||
}
|
||||
|
||||
// Events
|
||||
sendBtn.addEventListener("click", sendMessage);
|
||||
userInput.addEventListener("keypress", e => {
|
||||
if (e.key === "Enter") sendMessage();
|
||||
});
|
||||
|
||||
// Auto-refresh
|
||||
setInterval(fetchState, 2000);
|
||||
|
||||
// Initial fetch
|
||||
fetchState();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user