Atualizar web/index.html

This commit is contained in:
2026-08-19 20:41:15 -03:00
parent 9e51cd7033
commit dc75c8639d
+24 -35
View File
@@ -4,19 +4,19 @@
<meta charset="UTF-8">
<title>Safira Chat</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="chat.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<body class="dark">
<h1>Safira AI Gateway</h1>
<p>This interface allows you to send prompts to the local Ollama models.</p>
<div class="top-bar">
<h1>Safira AI Chat</h1>
<button onclick="login()">Login</button>
<button onclick="toggleTheme()">Toggle theme</button>
</div>
<!-- Login button -->
<button onclick="window.location='/login'">Login with Google</button>
<button onclick="login()">Login with Google</button>
<button onclick="newConversation()">New Conversation</button>
<div id="chat"></div>
@@ -32,42 +32,31 @@
<option value="qwen2.5">Qwen 2.5</option>
</select>
<textarea id="prompt" placeholder="Type your prompt here..."></textarea>
<div class="tabs" id="tabs"></div>
<div class="chat-container">
<div id="chat"></div>
</div>
<div class="input-bar">
<input type="file" id="attachment">
<textarea id="prompt" placeholder="Type your message..."></textarea>
<button onclick="sendMessage()">Send</button>
</div>
<button onclick="sendPrompt()">Generate</button>
<div id="output"></div>
<script>
// All comments are in English.
// Sends the prompt to the backend API.
async function sendPrompt() {
const model = document.getElementById("model").value;
const prompt = document.getElementById("prompt").value;
</body>
</html>
document.getElementById("output").innerText = "Processing...";
<textarea id="prompt" placeholder="Type your prompt here..."></textarea>
try {
const response = await fetch("/api/generate", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({ model, prompt })
});
if (!response.ok) {
document.getElementById("output").innerText =
"Error: " + response.status + " " + response.statusText;
return;
}
const data = await response.json();
document.getElementById("output").innerText = data.output || "(no output)";
} catch (err) {
document.getElementById("output").innerText = "Request failed: " + err;
}
}
</script>
</body>
</html>