74 lines
1.9 KiB
HTML
74 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Safira Chat</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<script src="chat.js"></script>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Safira AI Gateway</h1>
|
|
<p>This interface allows you to send prompts to the local Ollama models.</p>
|
|
|
|
<!-- 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>
|
|
|
|
<textarea id="prompt" placeholder="Type your message..."></textarea>
|
|
<button onclick="sendMessage()">Send</button>
|
|
<hr>
|
|
|
|
<label for="model">Model:</label>
|
|
<select id="model">
|
|
<option value="llama3.2">Llama 3.2</option>
|
|
<option value="gemma4">Gemma 4</option>
|
|
<option value="qwen2.5">Qwen 2.5</option>
|
|
</select>
|
|
|
|
<textarea id="prompt" placeholder="Type your prompt here..."></textarea>
|
|
|
|
<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;
|
|
|
|
document.getElementById("output").innerText = "Processing...";
|
|
|
|
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>
|