forked from prajwalcordiero/SoftWizz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
77 lines (67 loc) · 2.94 KB
/
index.html
File metadata and controls
77 lines (67 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<title>VNS</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: auto; }
textarea { width: 100%; height: 100px; margin-bottom: 10px; }
button { padding: 10px 20px; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
.section-title { margin-top: 30px; font-size: 1.2em; }
</style>
</head>
<body>
<h2>VNS: Workforce Query</h2>
<textarea id="prompt" placeholder="Ask something like 'Show all employees in HR' or 'Update status of employee 2'"></textarea><br>
<button onclick="sendPrompt()">Send</button>
<div id="output"></div>
<script>
async function sendPrompt() {
const prompt = document.getElementById('prompt').value;
const outputDiv = document.getElementById('output');
outputDiv.innerHTML = 'Loading...';
const response = await fetch('http://127.0.0.1:8000/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ prompt: prompt })
});
const data = await response.json();
outputDiv.innerHTML = '';
if (data.columns && data.result) {
outputDiv.innerHTML += `<div class='section-title'>Result:</div>` + createTable(data.columns, data.result);
}
if (data.before && data.after) {
outputDiv.innerHTML += `<div class='section-title'>Before:</div>` + createTable(data.columns, data.before);
outputDiv.innerHTML += `<div class='section-title'>After:</div>` + createTable(data.columns, data.after);
}
if (data.response) {
outputDiv.innerHTML += `<div class='section-title'>Response:</div><pre>${data.response}</pre>`;
}
if (data.error) {
outputDiv.innerHTML += `<div class='section-title'>Error:</div><pre>${data.error}</pre>`;
}
if (data.query) {
outputDiv.innerHTML += `<div class='section-title'>Executed Query:</div><pre>${data.query}</pre>`;
}
}
function createTable(columns, rows) {
let html = '<table><thead><tr>';
for (let col of columns) {
html += `<th>${col}</th>`;
}
html += '</tr></thead><tbody>';
for (let row of rows) {
html += '<tr>';
for (let cell of row) {
html += `<td>${cell !== null ? cell : ''}</td>`;
}
html += '</tr>';
}
html += '</tbody></table>';
return html;
}
</script>
</body>
</html>