rahul-02 commited on
Commit
1cc4015
·
verified ·
1 Parent(s): 2d6f313

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +42 -57
templates/index.html CHANGED
@@ -9,9 +9,8 @@
9
  :root {
10
  --bg-dark: #020617;
11
  --sidebar-bg: #0f172a;
12
- --accent-primary: #38bdf8;
13
  --accent-glow: rgba(56, 189, 248, 0.3);
14
- --glass-white: rgba(255, 255, 255, 0.03);
15
  --border: rgba(255, 255, 255, 0.08);
16
  --text-main: #f8fafc;
17
  --text-dim: #94a3b8;
@@ -28,7 +27,7 @@
28
  overflow: hidden;
29
  }
30
 
31
- /* SaaS Sidebar */
32
  aside {
33
  width: 260px;
34
  background: var(--sidebar-bg);
@@ -41,7 +40,7 @@
41
  .logo {
42
  font-size: 1.5rem;
43
  font-weight: 700;
44
- color: var(--accent-primary);
45
  margin-bottom: 40px;
46
  letter-spacing: -1px;
47
  }
@@ -52,22 +51,14 @@
52
  color: var(--text-dim);
53
  text-decoration: none;
54
  margin-bottom: 8px;
55
- transition: 0.2s;
56
  font-weight: 500;
 
57
  }
58
 
59
- .nav-item.active, .nav-item:hover {
60
- background: var(--glass-white);
61
- color: var(--text-main);
62
- }
63
 
64
- /* Main Workspace */
65
- main {
66
- flex: 1;
67
- display: flex;
68
- flex-direction: column;
69
- position: relative;
70
- }
71
 
72
  header {
73
  padding: 20px 40px;
@@ -86,7 +77,6 @@
86
  border: 1px solid rgba(34, 197, 94, 0.2);
87
  }
88
 
89
- /* Chat Area Design */
90
  #chat-window {
91
  flex: 1;
92
  overflow-y: auto;
@@ -94,7 +84,6 @@
94
  display: flex;
95
  flex-direction: column;
96
  gap: 24px;
97
- mask-image: linear-gradient(to bottom, transparent, black 5%, black 95%, transparent);
98
  }
99
 
100
  .message {
@@ -106,11 +95,11 @@
106
  animation: slideUp 0.4s ease-out;
107
  }
108
 
109
- @keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
110
 
111
  .user-msg {
112
  align-self: flex-end;
113
- background: var(--accent-primary);
114
  color: #000;
115
  border-bottom-right-radius: 4px;
116
  box-shadow: 0 10px 20px -10px var(--accent-glow);
@@ -118,20 +107,20 @@
118
 
119
  .ai-msg {
120
  align-self: flex-start;
121
- background: var(--glass-white);
122
  border: 1px solid var(--border);
123
  border-bottom-left-radius: 4px;
124
  }
125
 
126
- .typing { color: var(--text-dim); font-size: 0.85rem; padding-left: 10px; }
127
 
128
- /* SaaS Input Bar */
129
- .input-container {
130
  padding: 30px 40px;
131
  background: linear-gradient(to top, var(--bg-dark), transparent);
132
  }
133
 
134
- .input-wrapper {
135
  max-width: 900px;
136
  margin: 0 auto;
137
  background: rgba(255, 255, 255, 0.05);
@@ -139,8 +128,7 @@
139
  border-radius: 16px;
140
  padding: 8px;
141
  display: flex;
142
- align-items: center;
143
- box-shadow: 0 0 0 1px var(--border), 0 20px 40px -20px rgba(0,0,0,0.5);
144
  }
145
 
146
  input {
@@ -148,24 +136,24 @@
148
  background: transparent;
149
  border: none;
150
  color: white;
151
- padding: 12px 16px;
152
  outline: none;
153
  font-size: 1rem;
154
  }
155
 
156
  button {
157
- background: var(--accent-primary);
158
  color: #000;
159
  border: none;
160
  padding: 10px 24px;
161
  border-radius: 10px;
162
  font-weight: 700;
163
  cursor: pointer;
164
- transition: 0.3s;
165
  }
166
 
167
- button:hover { transform: translateY(-2px); box-shadow: 0 5px 15px var(--accent-glow); }
168
- button:disabled { background: #334155; color: #94a3b8; transform: none; box-shadow: none; }
169
  </style>
170
  </head>
171
  <body>
@@ -174,33 +162,29 @@
174
  <div class="logo">Nexus AI</div>
175
  <a href="#" class="nav-item active">Dashboard</a>
176
  <a href="#" class="nav-item">Research Vault</a>
177
- <a href="#" class="nav-item">Integrations</a>
178
- <a href="#" class="nav-item">Settings</a>
179
-
180
- <div style="margin-top: auto; padding: 20px; background: var(--glass-white); border-radius: 16px;">
181
- <p style="font-size: 0.75rem; color: var(--text-dim);">Usage Plan</p>
182
- <p style="font-size: 0.9rem; margin-top: 4px;">Pro - Enterprise</p>
183
  </div>
184
  </aside>
185
 
186
  <main>
187
  <header>
188
  <div>
189
- <h1 style="font-size: 1.1rem;">Research Assistant</h1>
190
- <p style="font-size: 0.8rem; color: var(--text-dim);">Llama 3.2 Model Active</p>
191
  </div>
192
- <div class="status-pill">● System Online</div>
193
  </header>
194
 
195
  <div id="chat-window">
196
- <div class="message ai-msg">
197
- Welcome back. I have access to real-time search and the Llama 3.2 inference engine. How can I assist your research today?
198
- </div>
199
  </div>
200
 
201
- <div class="input-container">
202
- <div class="input-wrapper">
203
- <input type="text" id="user-input" placeholder="Enter research prompt or URL..." autocomplete="off">
204
  <button id="send-btn">Generate</button>
205
  </div>
206
  </div>
@@ -227,29 +211,30 @@
227
  userInput.value = '';
228
 
229
  sendBtn.disabled = true;
230
- const typingIndicator = document.createElement('div');
231
- typingIndicator.className = 'typing';
232
- typingIndicator.innerText = 'Nexus AI is searching the web...';
233
- chatWindow.appendChild(typingIndicator);
234
- chatWindow.scrollTop = chatWindow.scrollHeight;
235
 
236
  try {
 
237
  const response = await fetch(`${window.location.origin}/ask`, {
238
  method: 'POST',
239
  headers: { 'Content-Type': 'application/json' },
240
  body: JSON.stringify({ query: query })
241
  });
242
 
243
- if (!response.ok) throw new Error(`HTTP ${response.status}`);
244
 
245
  const data = await response.json();
246
- chatWindow.removeChild(typingIndicator);
247
  appendMessage(data.answer, false);
248
- } catch (error) {
249
- if (chatWindow.contains(typingIndicator)) chatWindow.removeChild(typingIndicator);
250
- appendMessage(`Error: ${error.message}. Please verify the Space is awake and running.`, false);
251
  } finally {
252
  sendBtn.disabled = false;
 
253
  }
254
  }
255
 
 
9
  :root {
10
  --bg-dark: #020617;
11
  --sidebar-bg: #0f172a;
12
+ --accent: #38bdf8;
13
  --accent-glow: rgba(56, 189, 248, 0.3);
 
14
  --border: rgba(255, 255, 255, 0.08);
15
  --text-main: #f8fafc;
16
  --text-dim: #94a3b8;
 
27
  overflow: hidden;
28
  }
29
 
30
+ /* Sidebar Navigation */
31
  aside {
32
  width: 260px;
33
  background: var(--sidebar-bg);
 
40
  .logo {
41
  font-size: 1.5rem;
42
  font-weight: 700;
43
+ color: var(--accent);
44
  margin-bottom: 40px;
45
  letter-spacing: -1px;
46
  }
 
51
  color: var(--text-dim);
52
  text-decoration: none;
53
  margin-bottom: 8px;
 
54
  font-weight: 500;
55
+ transition: 0.2s;
56
  }
57
 
58
+ .nav-item.active { background: rgba(255,255,255,0.05); color: white; }
 
 
 
59
 
60
+ /* Main Canvas */
61
+ main { flex: 1; display: flex; flex-direction: column; position: relative; }
 
 
 
 
 
62
 
63
  header {
64
  padding: 20px 40px;
 
77
  border: 1px solid rgba(34, 197, 94, 0.2);
78
  }
79
 
 
80
  #chat-window {
81
  flex: 1;
82
  overflow-y: auto;
 
84
  display: flex;
85
  flex-direction: column;
86
  gap: 24px;
 
87
  }
88
 
89
  .message {
 
95
  animation: slideUp 0.4s ease-out;
96
  }
97
 
98
+ @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
99
 
100
  .user-msg {
101
  align-self: flex-end;
102
+ background: var(--accent);
103
  color: #000;
104
  border-bottom-right-radius: 4px;
105
  box-shadow: 0 10px 20px -10px var(--accent-glow);
 
107
 
108
  .ai-msg {
109
  align-self: flex-start;
110
+ background: rgba(255,255,255,0.03);
111
  border: 1px solid var(--border);
112
  border-bottom-left-radius: 4px;
113
  }
114
 
115
+ .typing { color: var(--text-dim); font-size: 0.85rem; font-style: italic; }
116
 
117
+ /* Input Deck */
118
+ .input-area {
119
  padding: 30px 40px;
120
  background: linear-gradient(to top, var(--bg-dark), transparent);
121
  }
122
 
123
+ .input-box {
124
  max-width: 900px;
125
  margin: 0 auto;
126
  background: rgba(255, 255, 255, 0.05);
 
128
  border-radius: 16px;
129
  padding: 8px;
130
  display: flex;
131
+ gap: 10px;
 
132
  }
133
 
134
  input {
 
136
  background: transparent;
137
  border: none;
138
  color: white;
139
+ padding: 12px;
140
  outline: none;
141
  font-size: 1rem;
142
  }
143
 
144
  button {
145
+ background: var(--accent);
146
  color: #000;
147
  border: none;
148
  padding: 10px 24px;
149
  border-radius: 10px;
150
  font-weight: 700;
151
  cursor: pointer;
152
+ transition: 0.2s;
153
  }
154
 
155
+ button:hover { transform: translateY(-1px); box-shadow: 0 5px 15px var(--accent-glow); }
156
+ button:disabled { background: #334155; color: #94a3b8; cursor: not-allowed; }
157
  </style>
158
  </head>
159
  <body>
 
162
  <div class="logo">Nexus AI</div>
163
  <a href="#" class="nav-item active">Dashboard</a>
164
  <a href="#" class="nav-item">Research Vault</a>
165
+ <a href="#" class="nav-item">API Keys</a>
166
+ <div style="margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border);">
167
+ <p style="font-size: 0.75rem; color: var(--text-dim);">SYSTEM STATUS</p>
168
+ <p style="font-size: 0.85rem; margin-top: 4px;">Llama 3.2 3B Instruct</p>
 
 
169
  </div>
170
  </aside>
171
 
172
  <main>
173
  <header>
174
  <div>
175
+ <h1 style="font-size: 1.1rem; font-weight: 700;">Research Assistant</h1>
176
+ <p style="font-size: 0.8rem; color: var(--text-dim);">Real-time web search enabled</p>
177
  </div>
178
+ <div class="status-pill">● Online</div>
179
  </header>
180
 
181
  <div id="chat-window">
182
+ <div class="message ai-msg">Welcome to Nexus. Type a research query to begin.</div>
 
 
183
  </div>
184
 
185
+ <div class="input-area">
186
+ <div class="input-box">
187
+ <input type="text" id="user-input" placeholder="What would you like to research today?" autocomplete="off">
188
  <button id="send-btn">Generate</button>
189
  </div>
190
  </div>
 
211
  userInput.value = '';
212
 
213
  sendBtn.disabled = true;
214
+ const typing = document.createElement('div');
215
+ typing.className = 'typing';
216
+ typing.innerText = 'Nexus AI is thinking...';
217
+ chatWindow.appendChild(typing);
 
218
 
219
  try {
220
+ // IMPORTANT: window.location.origin ensures absolute routing on HF Spaces
221
  const response = await fetch(`${window.location.origin}/ask`, {
222
  method: 'POST',
223
  headers: { 'Content-Type': 'application/json' },
224
  body: JSON.stringify({ query: query })
225
  });
226
 
227
+ if (!response.ok) throw new Error(`Server Error: ${response.status}`);
228
 
229
  const data = await response.json();
230
+ chatWindow.removeChild(typing);
231
  appendMessage(data.answer, false);
232
+ } catch (err) {
233
+ if (chatWindow.contains(typing)) chatWindow.removeChild(typing);
234
+ appendMessage(`Connection Error: ${err.message}. Please check Space logs.`, false);
235
  } finally {
236
  sendBtn.disabled = false;
237
+ chatWindow.scrollTop = chatWindow.scrollHeight;
238
  }
239
  }
240