Atualizar web/index.html
This commit is contained in:
+24
-35
@@ -4,19 +4,19 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Safira Chat</title>
|
<title>Safira Chat</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<script src="chat.js"></script>
|
<script src="chat.js"></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class="dark">
|
||||||
|
|
||||||
<h1>Safira AI Gateway</h1>
|
<div class="top-bar">
|
||||||
<p>This interface allows you to send prompts to the local Ollama models.</p>
|
<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>
|
<button onclick="newConversation()">New Conversation</button>
|
||||||
|
|
||||||
<div id="chat"></div>
|
<div id="chat"></div>
|
||||||
@@ -32,42 +32,31 @@
|
|||||||
<option value="qwen2.5">Qwen 2.5</option>
|
<option value="qwen2.5">Qwen 2.5</option>
|
||||||
</select>
|
</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>
|
<button onclick="sendPrompt()">Generate</button>
|
||||||
|
|
||||||
<div id="output"></div>
|
<div id="output"></div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// All comments are in English.
|
|
||||||
|
|
||||||
// Sends the prompt to the backend API.
|
</body>
|
||||||
async function sendPrompt() {
|
</html>
|
||||||
const model = document.getElementById("model").value;
|
|
||||||
const prompt = document.getElementById("prompt").value;
|
|
||||||
|
|
||||||
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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user