Spaces:
Sleeping
Sleeping
fix: dashboard inputs, logic and layout alignment
Browse files- static/docs.html +82 -59
static/docs.html
CHANGED
|
@@ -303,9 +303,17 @@
|
|
| 303 |
display: none;
|
| 304 |
max-height: 500px;
|
| 305 |
/* Scrollable */
|
|
|
|
| 306 |
overflow-y: auto;
|
| 307 |
}
|
| 308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
.demo-response.visible {
|
| 310 |
display: block;
|
| 311 |
}
|
|
@@ -422,6 +430,7 @@
|
|
| 422 |
<textarea id="chat-basic-input" class="demo-input" rows="3"
|
| 423 |
placeholder='{"message": "What is AI?"}'>What is the capital of France?</textarea>
|
| 424 |
<button class="demo-btn" onclick="runDemo('chat-basic')">Run Request ▶</button>
|
|
|
|
| 425 |
<div id="chat-basic-res" class="demo-response"></div>
|
| 426 |
</div>
|
| 427 |
</div>
|
|
@@ -475,6 +484,7 @@
|
|
| 475 |
<option value="midijourney">midijourney</option>
|
| 476 |
</select>
|
| 477 |
<button class="demo-btn" onclick="runDemo('chat-adv')">Run Request ▶</button>
|
|
|
|
| 478 |
<div id="chat-adv-res" class="demo-response"></div>
|
| 479 |
</div>
|
| 480 |
</div>
|
|
@@ -604,79 +614,92 @@
|
|
| 604 |
// Global flag for Pie Chart
|
| 605 |
window.pieChartRendered = false;
|
| 606 |
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
resBox.className = 'demo-response visible';
|
| 610 |
-
resBox.style.display = 'block';
|
| 611 |
-
resBox.innerHTML = 'Sending Request... <span class="loading-spin"></span>';
|
| 612 |
|
| 613 |
-
|
|
|
|
|
|
|
| 614 |
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
messages: [{ role: "user", content: "Hello! Who are you?" }]
|
| 628 |
-
};
|
| 629 |
-
}
|
| 630 |
-
else if (type === 'chat-adv') {
|
| 631 |
-
// Advanced Chat
|
| 632 |
-
const model = document.getElementById('chat-adv-model').value || "gemini-3-flash";
|
| 633 |
-
const userMsg = document.getElementById('chat-adv-msg').value;
|
| 634 |
-
|
| 635 |
-
if (!userMsg) { alert("Please enter a message"); return; }
|
| 636 |
-
|
| 637 |
-
url = '/v1/chat/completions';
|
| 638 |
-
body = {
|
| 639 |
-
model: model,
|
| 640 |
-
messages: [
|
| 641 |
-
{ role: "user", content: userMsg }
|
| 642 |
-
]
|
| 643 |
-
};
|
| 644 |
-
}
|
| 645 |
-
else if (type === 'models') {
|
| 646 |
-
// List Models
|
| 647 |
-
url = '/models'; // This is GET, no body
|
| 648 |
-
method = 'GET';
|
| 649 |
-
body = undefined;
|
| 650 |
-
// Keep models as public? Or require auth?
|
| 651 |
-
// Usually /models is authenticated in OpenAI but let's keep it open for now or add auth.
|
| 652 |
-
}
|
| 653 |
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
headers: headers,
|
| 657 |
-
body: body ? JSON.stringify(body) : undefined
|
| 658 |
-
});
|
| 659 |
|
| 660 |
-
|
| 661 |
-
const duration = Date.now() - startTime;
|
| 662 |
|
| 663 |
-
|
| 664 |
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
<pre>${JSON.stringify(data, null, 2)}</pre>
|
| 670 |
-
`;
|
| 671 |
|
| 672 |
-
|
| 673 |
-
|
|
|
|
|
|
|
|
|
|
| 674 |
<div style="margin-bottom:5px; font-weight:bold; color:var(--error);">
|
| 675 |
Error
|
| 676 |
</div>
|
| 677 |
<pre>${err.message}</pre>
|
| 678 |
`;
|
| 679 |
-
|
| 680 |
}
|
| 681 |
|
| 682 |
async function runSearch() {
|
|
|
|
| 303 |
display: none;
|
| 304 |
max-height: 500px;
|
| 305 |
/* Scrollable */
|
| 306 |
+
/* Scrollable */
|
| 307 |
overflow-y: auto;
|
| 308 |
}
|
| 309 |
|
| 310 |
+
.demo-status {
|
| 311 |
+
margin-top: 12px;
|
| 312 |
+
font-weight: 600;
|
| 313 |
+
font-size: 13px;
|
| 314 |
+
display: none;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
.demo-response.visible {
|
| 318 |
display: block;
|
| 319 |
}
|
|
|
|
| 430 |
<textarea id="chat-basic-input" class="demo-input" rows="3"
|
| 431 |
placeholder='{"message": "What is AI?"}'>What is the capital of France?</textarea>
|
| 432 |
<button class="demo-btn" onclick="runDemo('chat-basic')">Run Request ▶</button>
|
| 433 |
+
<div id="chat-basic-status" class="demo-status"></div>
|
| 434 |
<div id="chat-basic-res" class="demo-response"></div>
|
| 435 |
</div>
|
| 436 |
</div>
|
|
|
|
| 484 |
<option value="midijourney">midijourney</option>
|
| 485 |
</select>
|
| 486 |
<button class="demo-btn" onclick="runDemo('chat-adv')">Run Request ▶</button>
|
| 487 |
+
<div id="chat-adv-status" class="demo-status"></div>
|
| 488 |
<div id="chat-adv-res" class="demo-response"></div>
|
| 489 |
</div>
|
| 490 |
</div>
|
|
|
|
| 614 |
// Global flag for Pie Chart
|
| 615 |
window.pieChartRendered = false;
|
| 616 |
|
| 617 |
+
const resBox = document.getElementById(type + '-res');
|
| 618 |
+
const statusBox = document.getElementById(type + '-status');
|
|
|
|
|
|
|
|
|
|
| 619 |
|
| 620 |
+
resBox.className = 'demo-response visible';
|
| 621 |
+
resBox.style.display = 'none'; // Hide content while loading
|
| 622 |
+
resBox.innerHTML = '';
|
| 623 |
|
| 624 |
+
if (statusBox) {
|
| 625 |
+
statusBox.style.display = 'block';
|
| 626 |
+
statusBox.innerHTML = 'Sending Request... <span class="loading-spin"></span>';
|
| 627 |
+
statusBox.style.color = 'var(--text-muted)';
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
const startTime = Date.now();
|
| 631 |
+
|
| 632 |
+
try {
|
| 633 |
+
let url, body, method = 'POST';
|
| 634 |
+
let headers = {
|
| 635 |
+
'Content-Type': 'application/json',
|
| 636 |
+
'Authorization': 'Bearer sk-kai-demo-public' // Use Demo Key for Dashboard
|
| 637 |
+
};
|
| 638 |
+
|
| 639 |
+
if (type === 'chat-basic') {
|
| 640 |
+
// Simple Chat
|
| 641 |
+
const inputVal = document.getElementById('chat-basic-input').value;
|
| 642 |
+
if (!inputVal) { alert("Please enter a message"); return; }
|
| 643 |
+
|
| 644 |
+
url = '/v1/chat/completions';
|
| 645 |
+
body = {
|
| 646 |
+
model: "gemini-3-flash",
|
| 647 |
+
messages: [{ role: "user", content: inputVal }]
|
| 648 |
+
};
|
| 649 |
+
}
|
| 650 |
+
else if (type === 'chat-adv') {
|
| 651 |
+
// Advanced Chat
|
| 652 |
+
const model = document.getElementById('chat-adv-model').value || "gemini-3-flash";
|
| 653 |
+
const userMsg = document.getElementById('chat-adv-msg').value;
|
| 654 |
+
|
| 655 |
+
if (!userMsg) { alert("Please enter a message"); return; }
|
| 656 |
+
|
| 657 |
+
url = '/v1/chat/completions';
|
| 658 |
+
body = {
|
| 659 |
+
model: model,
|
| 660 |
+
messages: [
|
| 661 |
+
{ role: "user", content: userMsg }
|
| 662 |
+
]
|
| 663 |
};
|
| 664 |
+
}
|
| 665 |
+
else if (type === 'models') {
|
| 666 |
+
// List Models
|
| 667 |
+
url = '/models'; // This is GET, no body
|
| 668 |
+
method = 'GET';
|
| 669 |
+
body = undefined;
|
| 670 |
+
// Keep models as public? Or require auth?
|
| 671 |
+
// Usually /models is authenticated in OpenAI but let's keep it open for now or add auth.
|
| 672 |
+
}
|
| 673 |
|
| 674 |
+
const response = await fetch(url, {
|
| 675 |
+
method: method,
|
| 676 |
+
headers: headers,
|
| 677 |
+
body: body ? JSON.stringify(body) : undefined
|
| 678 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 679 |
|
| 680 |
+
const data = await response.json();
|
| 681 |
+
const duration = Date.now() - startTime;
|
|
|
|
|
|
|
|
|
|
| 682 |
|
| 683 |
+
if (!response.ok) throw new Error(data.detail || 'Request failed');
|
|
|
|
| 684 |
|
| 685 |
+
if (!response.ok) throw new Error(data.detail || 'Request failed');
|
| 686 |
|
| 687 |
+
if (statusBox) {
|
| 688 |
+
statusBox.innerHTML = `Success (${duration}ms)`;
|
| 689 |
+
statusBox.style.color = 'var(--success)';
|
| 690 |
+
}
|
|
|
|
|
|
|
| 691 |
|
| 692 |
+
resBox.style.display = 'block';
|
| 693 |
+
resBox.innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
|
| 694 |
+
|
| 695 |
+
} catch (err) {
|
| 696 |
+
resBox.innerHTML = `
|
| 697 |
<div style="margin-bottom:5px; font-weight:bold; color:var(--error);">
|
| 698 |
Error
|
| 699 |
</div>
|
| 700 |
<pre>${err.message}</pre>
|
| 701 |
`;
|
| 702 |
+
}
|
| 703 |
}
|
| 704 |
|
| 705 |
async function runSearch() {
|