pvanand commited on
Commit
15d54c1
·
verified ·
1 Parent(s): 97c68cd

Update templates/apps-hub/digiyatra.html

Browse files
Files changed (1) hide show
  1. templates/apps-hub/digiyatra.html +30 -1
templates/apps-hub/digiyatra.html CHANGED
@@ -193,6 +193,7 @@
193
  .chat-container {
194
  position: relative;
195
  }
 
196
  .chat-header {
197
  position: absolute;
198
  top: 0;
@@ -201,6 +202,7 @@
201
  z-index: 10;
202
  transition: transform 0.3s ease;
203
  }
 
204
  .input-area {
205
  position: absolute;
206
  bottom: 0;
@@ -209,13 +211,16 @@
209
  z-index: 10;
210
  transition: transform 0.3s ease;
211
  }
 
212
  .messages {
213
  padding-top: 60px;
214
  padding-bottom: 80px;
215
  }
 
216
  .header-hidden {
217
  transform: translateY(-100%);
218
  }
 
219
  .input-hidden {
220
  transform: translateY(100%);
221
  }
@@ -279,6 +284,7 @@
279
  container.appendChild(dot);
280
  }
281
  }
 
282
  const app = new Vue({
283
  el: '#app',
284
  data: {
@@ -303,6 +309,7 @@
303
  this.$nextTick(() => {
304
  createTypingAnimation();
305
  });
 
306
  try {
307
  const response = await fetch('https://pvanand-rag-chat.hf.space/chat/', {
308
  method: 'POST',
@@ -337,7 +344,26 @@
337
  rawResponse = rawResponse.replace(/<interact>[\s\S]*?<\/interact>/g, '');
338
  rawResponse = rawResponse.replace(/<\/?response>/g, '');
339
 
340
- this.$set(this.messages[streamingIndex], 'content', marked.parse(rawResponse));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  }
342
  if (jsonData) {
343
  this.renderClarificationQuestions(jsonData.clarification, streamingIndex);
@@ -418,18 +444,21 @@
418
  this.userInput = '';
419
  this.isScrollingUp = false;
420
  this.lastScrollTop = 0;
 
421
  // Reset scroll position
422
  this.$nextTick(() => {
423
  if (this.$refs.messageContainer) {
424
  this.$refs.messageContainer.scrollTop = 0;
425
  }
426
  });
 
427
  // Ensure header and input area are visible
428
  const header = document.querySelector('.chat-header');
429
  const inputArea = document.querySelector('.input-area');
430
  if (header) header.classList.remove('header-hidden');
431
  if (inputArea) inputArea.classList.remove('input-hidden');
432
  },
 
433
  scrollToBottom() {
434
  const container = this.$refs.messageContainer;
435
  container.scrollTop = container.scrollHeight;
 
193
  .chat-container {
194
  position: relative;
195
  }
196
+
197
  .chat-header {
198
  position: absolute;
199
  top: 0;
 
202
  z-index: 10;
203
  transition: transform 0.3s ease;
204
  }
205
+
206
  .input-area {
207
  position: absolute;
208
  bottom: 0;
 
211
  z-index: 10;
212
  transition: transform 0.3s ease;
213
  }
214
+
215
  .messages {
216
  padding-top: 60px;
217
  padding-bottom: 80px;
218
  }
219
+
220
  .header-hidden {
221
  transform: translateY(-100%);
222
  }
223
+
224
  .input-hidden {
225
  transform: translateY(100%);
226
  }
 
284
  container.appendChild(dot);
285
  }
286
  }
287
+
288
  const app = new Vue({
289
  el: '#app',
290
  data: {
 
309
  this.$nextTick(() => {
310
  createTypingAnimation();
311
  });
312
+
313
  try {
314
  const response = await fetch('https://pvanand-rag-chat.hf.space/chat/', {
315
  method: 'POST',
 
344
  rawResponse = rawResponse.replace(/<interact>[\s\S]*?<\/interact>/g, '');
345
  rawResponse = rawResponse.replace(/<\/?response>/g, '');
346
 
347
+ const markdownLinkRegex = /\[([^\]]+)\]\(([^\)]+)\)/g;
348
+
349
+ const embedYouTube = (url) => {
350
+ return `<div style="padding: 10px 0;">
351
+ <iframe width="560" height="315" src="${url.replace('youtu.be', 'youtube.com/embed')}"
352
+ frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
353
+ allowfullscreen></iframe>
354
+ </div>`;
355
+ };
356
+
357
+ const parsedResponse = rawResponse.replace(markdownLinkRegex, (match, text, url) => {
358
+ if (url.includes('https://youtu')) {
359
+ return embedYouTube(url);
360
+ }
361
+ return match;
362
+ });
363
+
364
+ this.$set(this.messages[streamingIndex], 'content', marked.parse(parsedResponse));
365
+
366
+ this.$set(this.messages[streamingIndex], 'content', marked.parse(parsedResponse));
367
  }
368
  if (jsonData) {
369
  this.renderClarificationQuestions(jsonData.clarification, streamingIndex);
 
444
  this.userInput = '';
445
  this.isScrollingUp = false;
446
  this.lastScrollTop = 0;
447
+
448
  // Reset scroll position
449
  this.$nextTick(() => {
450
  if (this.$refs.messageContainer) {
451
  this.$refs.messageContainer.scrollTop = 0;
452
  }
453
  });
454
+
455
  // Ensure header and input area are visible
456
  const header = document.querySelector('.chat-header');
457
  const inputArea = document.querySelector('.input-area');
458
  if (header) header.classList.remove('header-hidden');
459
  if (inputArea) inputArea.classList.remove('input-hidden');
460
  },
461
+
462
  scrollToBottom() {
463
  const container = this.$refs.messageContainer;
464
  container.scrollTop = container.scrollHeight;