Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +31 -37
index.html
CHANGED
|
@@ -2,65 +2,59 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<
|
|
|
|
| 6 |
<style>
|
| 7 |
-
body { font-family:
|
| 8 |
-
.
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
</style>
|
| 15 |
</head>
|
| 16 |
<body>
|
| 17 |
|
| 18 |
-
<div class="
|
| 19 |
<h2>🏥 EthioDocs AI</h2>
|
| 20 |
-
<textarea id="
|
| 21 |
-
<button
|
| 22 |
-
<div id="
|
| 23 |
-
<div id="output">Waiting for your question...</div>
|
| 24 |
</div>
|
| 25 |
|
| 26 |
<script>
|
| 27 |
-
async function
|
| 28 |
const btn = document.getElementById('askBtn');
|
| 29 |
-
const
|
| 30 |
-
const
|
| 31 |
-
const text = document.getElementById('prompt').value;
|
| 32 |
|
| 33 |
-
if
|
| 34 |
|
|
|
|
| 35 |
btn.disabled = true;
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
try {
|
| 40 |
-
|
| 41 |
-
const response = await fetch("/ask", {
|
| 42 |
method: "POST",
|
| 43 |
headers: { "Content-Type": "application/json" },
|
| 44 |
-
body: JSON.stringify({ inputs:
|
| 45 |
});
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
btn.disabled = false;
|
| 49 |
-
|
| 50 |
if (data.error) {
|
| 51 |
-
|
| 52 |
-
output.innerText = "The model is still starting up. Please wait 15 seconds and try again.";
|
| 53 |
-
} else if (Array.isArray(data) && data[0].generated_text) {
|
| 54 |
-
status.innerText = "Success!";
|
| 55 |
-
output.innerText = data[0].generated_text;
|
| 56 |
} else {
|
| 57 |
-
|
| 58 |
-
output.innerText = JSON.stringify(data);
|
| 59 |
}
|
| 60 |
-
} catch (
|
|
|
|
|
|
|
|
|
|
| 61 |
btn.disabled = false;
|
| 62 |
-
status.innerText = "Bridge Error.";
|
| 63 |
-
output.innerText = "Could not reach app.py. Make sure your Space status is 'Running'.";
|
| 64 |
}
|
| 65 |
}
|
| 66 |
</script>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>EthioDocs AI</title>
|
| 7 |
<style>
|
| 8 |
+
body { font-family: 'Inter', sans-serif; background: #f4f7f6; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
|
| 9 |
+
.chat-container { width: 100%; max-width: 450px; background: white; padding: 25px; border-radius: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); }
|
| 10 |
+
h2 { color: #007bff; text-align: center; margin-bottom: 20px; }
|
| 11 |
+
textarea { width: 100%; height: 120px; border: 2px solid #eee; border-radius: 12px; padding: 15px; font-size: 16px; outline: none; transition: border 0.3s; box-sizing: border-box; }
|
| 12 |
+
textarea:focus { border-color: #007bff; }
|
| 13 |
+
button { width: 100%; background: #007bff; color: white; border: none; padding: 15px; border-radius: 12px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 15px; transition: transform 0.2s; }
|
| 14 |
+
button:active { transform: scale(0.98); }
|
| 15 |
+
#response { margin-top: 20px; padding: 15px; background: #f8f9fa; border-radius: 12px; font-size: 15px; color: #333; line-height: 1.5; display: none; }
|
| 16 |
</style>
|
| 17 |
</head>
|
| 18 |
<body>
|
| 19 |
|
| 20 |
+
<div class="chat-container">
|
| 21 |
<h2>🏥 EthioDocs AI</h2>
|
| 22 |
+
<textarea id="question" placeholder="Ask me any medical question..."></textarea>
|
| 23 |
+
<button onclick="askAI()" id="askBtn">Consult AI</button>
|
| 24 |
+
<div id="response"></div>
|
|
|
|
| 25 |
</div>
|
| 26 |
|
| 27 |
<script>
|
| 28 |
+
async function askAI() {
|
| 29 |
const btn = document.getElementById('askBtn');
|
| 30 |
+
const box = document.getElementById('response');
|
| 31 |
+
const input = document.getElementById('question').value;
|
|
|
|
| 32 |
|
| 33 |
+
if(!input) return;
|
| 34 |
|
| 35 |
+
btn.innerText = "Processing...";
|
| 36 |
btn.disabled = true;
|
| 37 |
+
box.style.display = "block";
|
| 38 |
+
box.innerText = "EthioDoc is analyzing your request...";
|
| 39 |
|
| 40 |
try {
|
| 41 |
+
const res = await fetch("/ask", {
|
|
|
|
| 42 |
method: "POST",
|
| 43 |
headers: { "Content-Type": "application/json" },
|
| 44 |
+
body: JSON.stringify({ inputs: input })
|
| 45 |
});
|
| 46 |
+
const data = await res.json();
|
| 47 |
+
|
|
|
|
|
|
|
| 48 |
if (data.error) {
|
| 49 |
+
box.innerText = "Model is waking up. Please wait 15 seconds and try again.";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
} else {
|
| 51 |
+
box.innerText = data[0].generated_text;
|
|
|
|
| 52 |
}
|
| 53 |
+
} catch (e) {
|
| 54 |
+
box.innerText = "Error connecting to the server.";
|
| 55 |
+
} finally {
|
| 56 |
+
btn.innerText = "Consult AI";
|
| 57 |
btn.disabled = false;
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
}
|
| 60 |
</script>
|