Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
@@ -1,22 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
document.getElementById('submit-query').addEventListener('click', () => {
|
2 |
-
const query = document.getElementById('query-input').value;
|
3 |
-
if (query
|
4 |
-
document.getElementById('response-output').innerHTML = `<p>Processing query: ${query}...</p>`;
|
5 |
-
document.getElementById('context-output').innerHTML = `<p>Retrieving relevant context...</p>`;
|
6 |
-
// Simulate API call (replace with actual backend integration)
|
7 |
-
setTimeout(() => {
|
8 |
-
document.getElementById('response-output').innerHTML = `<p>Sample response for: ${query}</p>`;
|
9 |
-
document.getElementById('context-output').innerHTML = `<p>Sample context retrieved for: ${query}</p>`;
|
10 |
-
}, 1000);
|
11 |
-
} else {
|
12 |
alert('Please enter a query.');
|
|
|
13 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
});
|
15 |
|
|
|
16 |
document.getElementById('apply-settings').addEventListener('click', () => {
|
17 |
const model = document.getElementById('model-select').value;
|
18 |
const topK = document.getElementById('top-k').value;
|
19 |
const temperature = document.getElementById('temperature').value;
|
20 |
const contextLength = document.getElementById('context-length').value;
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
});
|
|
|
1 |
+
// Theme Toggle
|
2 |
+
const themeSwitch = document.getElementById('theme-switch');
|
3 |
+
themeSwitch.addEventListener('click', () => {
|
4 |
+
document.body.classList.toggle('light');
|
5 |
+
themeSwitch.textContent = document.body.classList.contains('light') ? '☀️' : '🌙';
|
6 |
+
});
|
7 |
+
|
8 |
+
// Query Submission
|
9 |
document.getElementById('submit-query').addEventListener('click', () => {
|
10 |
+
const query = document.getElementById('query-input').value.trim();
|
11 |
+
if (!query) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
alert('Please enter a query.');
|
13 |
+
return;
|
14 |
}
|
15 |
+
|
16 |
+
// Simulate loading state
|
17 |
+
const responseOutput = document.getElementById('response-output');
|
18 |
+
const contextOutput = document.getElementById('context-output');
|
19 |
+
responseOutput.innerHTML = '<p class="loading">Generating response...</p>';
|
20 |
+
contextOutput.innerHTML = '<p class="loading">Retrieving context...</p>';
|
21 |
+
|
22 |
+
// Simulate API response (replace with actual backend integration)
|
23 |
+
setTimeout(() => {
|
24 |
+
responseOutput.innerHTML = `<p>Response to: ${query}</p>`;
|
25 |
+
contextOutput.innerHTML = `<p>Context for: ${query}</p>`;
|
26 |
+
}, 1500);
|
27 |
});
|
28 |
|
29 |
+
// Apply Settings
|
30 |
document.getElementById('apply-settings').addEventListener('click', () => {
|
31 |
const model = document.getElementById('model-select').value;
|
32 |
const topK = document.getElementById('top-k').value;
|
33 |
const temperature = document.getElementById('temperature').value;
|
34 |
const contextLength = document.getElementById('context-length').value;
|
35 |
+
|
36 |
+
// Simulate settings application
|
37 |
+
const settingsOutput = `Settings applied: Model=${model}, Top-K=${topK}, Temperature=${temperature}, Context Length=${contextLength}`;
|
38 |
+
console.log(settingsOutput);
|
39 |
+
alert(settingsOutput);
|
40 |
+
});
|
41 |
+
|
42 |
+
// Smooth scroll for better UX
|
43 |
+
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
44 |
+
anchor.addEventListener('click', (e) => {
|
45 |
+
e.preventDefault();
|
46 |
+
document.querySelector(anchor.getAttribute('href')).scrollIntoView({
|
47 |
+
behavior: 'smooth'
|
48 |
+
});
|
49 |
+
});
|
50 |
});
|