Spaces:
Sleeping
Sleeping
Create ui_html.py
Browse files- ui_html.py +70 -0
ui_html.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
HOME_HTML = """
|
| 2 |
+
<!doctype html>
|
| 3 |
+
<html>
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="utf-8">
|
| 6 |
+
<title>GMAT Solver v3</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: Arial, sans-serif; max-width: 900px; margin: 40px auto; padding: 0 16px; }
|
| 9 |
+
textarea { width: 100%; min-height: 220px; padding: 12px; font-size: 16px; }
|
| 10 |
+
.row { display: flex; gap: 16px; margin: 12px 0; flex-wrap: wrap; }
|
| 11 |
+
.card { border: 1px solid #ddd; border-radius: 10px; padding: 12px; flex: 1 1 220px; }
|
| 12 |
+
button { padding: 10px 16px; font-size: 16px; cursor: pointer; }
|
| 13 |
+
pre { white-space: pre-wrap; background: #f7f7f7; padding: 16px; border-radius: 10px; }
|
| 14 |
+
label { display: block; margin-bottom: 8px; font-weight: bold; }
|
| 15 |
+
select, input[type="range"] { width: 100%; }
|
| 16 |
+
</style>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
<h1>GMAT Solver v3</h1>
|
| 20 |
+
<p>This version supports natural chat and hidden Unity context.</p>
|
| 21 |
+
<label for="message">Message</label>
|
| 22 |
+
<textarea id="message" placeholder="Try:
|
| 23 |
+
why is it c
|
| 24 |
+
Or paste a whole question."></textarea>
|
| 25 |
+
<div class="row">
|
| 26 |
+
<div class="card">
|
| 27 |
+
<label for="help_mode">Help mode</label>
|
| 28 |
+
<select id="help_mode">
|
| 29 |
+
<option value="answer" selected>answer</option>
|
| 30 |
+
<option value="hint">hint</option>
|
| 31 |
+
<option value="walkthrough">walkthrough</option>
|
| 32 |
+
</select>
|
| 33 |
+
</div>
|
| 34 |
+
<div class="card">
|
| 35 |
+
<label for="tone">Tone</label>
|
| 36 |
+
<input id="tone" type="range" min="0" max="1" step="0.01" value="0.5">
|
| 37 |
+
</div>
|
| 38 |
+
<div class="card">
|
| 39 |
+
<label for="verbosity">Verbosity</label>
|
| 40 |
+
<input id="verbosity" type="range" min="0" max="1" step="0.01" value="0.5">
|
| 41 |
+
</div>
|
| 42 |
+
<div class="card">
|
| 43 |
+
<label for="transparency">Transparency</label>
|
| 44 |
+
<input id="transparency" type="range" min="0" max="1" step="0.01" value="0.5">
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
<button onclick="send()">Send</button>
|
| 48 |
+
<h2>Response</h2>
|
| 49 |
+
<pre id="out">Waiting...</pre>
|
| 50 |
+
<script>
|
| 51 |
+
async function send() {
|
| 52 |
+
const payload = {
|
| 53 |
+
message: document.getElementById('message').value,
|
| 54 |
+
help_mode: document.getElementById('help_mode').value,
|
| 55 |
+
tone: parseFloat(document.getElementById('tone').value),
|
| 56 |
+
verbosity: parseFloat(document.getElementById('verbosity').value),
|
| 57 |
+
transparency: parseFloat(document.getElementById('transparency').value)
|
| 58 |
+
};
|
| 59 |
+
const res = await fetch('/chat', {
|
| 60 |
+
method: 'POST',
|
| 61 |
+
headers: {'Content-Type': 'application/json'},
|
| 62 |
+
body: JSON.stringify(payload)
|
| 63 |
+
});
|
| 64 |
+
const data = await res.json();
|
| 65 |
+
document.getElementById('out').textContent = JSON.stringify(data, null, 2);
|
| 66 |
+
}
|
| 67 |
+
</script>
|
| 68 |
+
</body>
|
| 69 |
+
</html>
|
| 70 |
+
"""
|