fix: Load highlight.js browser bundle and resolve template suggestion card string syntax error
Browse files- index.html +39 -24
index.html
CHANGED
|
@@ -13,13 +13,7 @@
|
|
| 13 |
<!-- Markdown Parser & Code Syntax Highlighter CDNs -->
|
| 14 |
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 15 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/styles/atom-one-dark.min.css">
|
| 16 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/
|
| 17 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/languages/python.min.js"></script>
|
| 18 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/languages/javascript.min.js"></script>
|
| 19 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/languages/bash.min.js"></script>
|
| 20 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/languages/css.min.js"></script>
|
| 21 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/languages/json.min.js"></script>
|
| 22 |
-
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/languages/markdown.min.js"></script>
|
| 23 |
|
| 24 |
<!-- Lucide Icons -->
|
| 25 |
<script src="https://unpkg.com/lucide@latest"></script>
|
|
@@ -1026,6 +1020,29 @@
|
|
| 1026 |
let isConfigTokenAvailable = false;
|
| 1027 |
let gradioClient = null;
|
| 1028 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1029 |
// Dom elements
|
| 1030 |
const chatInput = document.getElementById("chat-input");
|
| 1031 |
const sendBtn = document.getElementById("send-btn");
|
|
@@ -1304,6 +1321,18 @@
|
|
| 1304 |
// Render Empty state when there are no messages
|
| 1305 |
function renderEmptyState() {
|
| 1306 |
if (!messagesViewport) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1307 |
messagesViewport.innerHTML = `
|
| 1308 |
<div class="empty-chat-state">
|
| 1309 |
<div class="empty-icon-box">
|
|
@@ -1314,22 +1343,7 @@
|
|
| 1314 |
<p>Ask anything! This model is highly tuned for complex instructions, coding help, and deep reasoning. Powered by NVIDIA's 550B Ultra architecture.</p>
|
| 1315 |
</div>
|
| 1316 |
<div class="suggestions-grid">
|
| 1317 |
-
|
| 1318 |
-
<div class="suggestion-card-title">Explain AI Concepts</div>
|
| 1319 |
-
<div class="suggestion-card-desc">"SFT vs RLHF..."</div>
|
| 1320 |
-
</div>
|
| 1321 |
-
<div class="suggestion-card" data-prompt="Write a fast Python script to parallelize image loading using threads.">
|
| 1322 |
-
<div class="suggestion-card-title">Code Generation</div>
|
| 1323 |
-
<div class="suggestion-card-desc">"Parallel image loading in Python..."</div>
|
| 1324 |
-
</div>
|
| 1325 |
-
<div class="suggestion-card" data-prompt="Outline a comprehensive marketing strategy to launch a new SaaS developer tool.">
|
| 1326 |
-
<div class="suggestion-card-title">Design a Plan</div>
|
| 1327 |
-
<div class="suggestion-card-desc">"Marketing strategy for a SaaS tool..."</div>
|
| 1328 |
-
</div>
|
| 1329 |
-
<div class="suggestion-card" data-prompt="Review this code snippet for potential performance bottlenecks: \n\n```python\nfor i in range(len(list)):\n if list[i] in other_list: pass\n```">
|
| 1330 |
-
<div class="suggestion-card-title">Code Review</div>
|
| 1331 |
-
<div class="suggestion-card-desc">"Find optimization bottlenecks..."</div>
|
| 1332 |
-
</div>
|
| 1333 |
</div>
|
| 1334 |
</div>
|
| 1335 |
`;
|
|
@@ -1337,7 +1351,8 @@
|
|
| 1337 |
// Suggestion click listeners
|
| 1338 |
document.querySelectorAll(".suggestion-card").forEach(card => {
|
| 1339 |
card.addEventListener("click", () => {
|
| 1340 |
-
const
|
|
|
|
| 1341 |
if (chatInput) {
|
| 1342 |
chatInput.value = prompt;
|
| 1343 |
adjustTextareaHeight();
|
|
|
|
| 13 |
<!-- Markdown Parser & Code Syntax Highlighter CDNs -->
|
| 14 |
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 15 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/styles/atom-one-dark.min.css">
|
| 16 |
+
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/highlight.min.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
<!-- Lucide Icons -->
|
| 19 |
<script src="https://unpkg.com/lucide@latest"></script>
|
|
|
|
| 1020 |
let isConfigTokenAvailable = false;
|
| 1021 |
let gradioClient = null;
|
| 1022 |
|
| 1023 |
+
const suggestions = [
|
| 1024 |
+
{
|
| 1025 |
+
title: "Explain AI Concepts",
|
| 1026 |
+
desc: "SFT vs RLHF...",
|
| 1027 |
+
prompt: "Explain the difference between supervised fine-tuning (SFT) and reinforcement learning from human feedback (RLHF)."
|
| 1028 |
+
},
|
| 1029 |
+
{
|
| 1030 |
+
title: "Code Generation",
|
| 1031 |
+
desc: "Parallel image loading in Python...",
|
| 1032 |
+
prompt: "Write a fast Python script to parallelize image loading using threads."
|
| 1033 |
+
},
|
| 1034 |
+
{
|
| 1035 |
+
title: "Design a Plan",
|
| 1036 |
+
desc: "Marketing strategy for a SaaS tool...",
|
| 1037 |
+
prompt: "Outline a comprehensive marketing strategy to launch a new SaaS developer tool."
|
| 1038 |
+
},
|
| 1039 |
+
{
|
| 1040 |
+
title: "Code Review",
|
| 1041 |
+
desc: "Find optimization bottlenecks...",
|
| 1042 |
+
prompt: "Review this code snippet for potential performance bottlenecks:\n\n```python\nfor i in range(len(list)):\n if list[i] in other_list: pass\n```"
|
| 1043 |
+
}
|
| 1044 |
+
];
|
| 1045 |
+
|
| 1046 |
// Dom elements
|
| 1047 |
const chatInput = document.getElementById("chat-input");
|
| 1048 |
const sendBtn = document.getElementById("send-btn");
|
|
|
|
| 1321 |
// Render Empty state when there are no messages
|
| 1322 |
function renderEmptyState() {
|
| 1323 |
if (!messagesViewport) return;
|
| 1324 |
+
|
| 1325 |
+
// Build suggestions cards HTML dynamically to avoid nested quotes or escaping bugs
|
| 1326 |
+
let cardsHtml = "";
|
| 1327 |
+
suggestions.forEach((item, index) => {
|
| 1328 |
+
cardsHtml += `
|
| 1329 |
+
<div class="suggestion-card" data-index="${index}">
|
| 1330 |
+
<div class="suggestion-card-title">${escapeHtml(item.title)}</div>
|
| 1331 |
+
<div class="suggestion-card-desc">${escapeHtml(item.desc)}</div>
|
| 1332 |
+
</div>
|
| 1333 |
+
`;
|
| 1334 |
+
});
|
| 1335 |
+
|
| 1336 |
messagesViewport.innerHTML = `
|
| 1337 |
<div class="empty-chat-state">
|
| 1338 |
<div class="empty-icon-box">
|
|
|
|
| 1343 |
<p>Ask anything! This model is highly tuned for complex instructions, coding help, and deep reasoning. Powered by NVIDIA's 550B Ultra architecture.</p>
|
| 1344 |
</div>
|
| 1345 |
<div class="suggestions-grid">
|
| 1346 |
+
${cardsHtml}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1347 |
</div>
|
| 1348 |
</div>
|
| 1349 |
`;
|
|
|
|
| 1351 |
// Suggestion click listeners
|
| 1352 |
document.querySelectorAll(".suggestion-card").forEach(card => {
|
| 1353 |
card.addEventListener("click", () => {
|
| 1354 |
+
const idx = parseInt(card.dataset.index);
|
| 1355 |
+
const prompt = suggestions[idx].prompt;
|
| 1356 |
if (chatInput) {
|
| 1357 |
chatInput.value = prompt;
|
| 1358 |
adjustTextareaHeight();
|