pvanand commited on
Commit
6a14077
·
verified ·
1 Parent(s): e727ed4

Update static/multi-agent.html

Browse files
Files changed (1) hide show
  1. static/multi-agent.html +93 -13
static/multi-agent.html CHANGED
@@ -12,7 +12,7 @@
12
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/atom-one-dark.min.css">
13
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
14
  <style>
15
- :root {
16
  --primary-color: #304b76;;
17
  --secondary-color: #f0f8ff;
18
  --text-color: #333;
@@ -48,6 +48,7 @@ body {
48
  padding: 20px;
49
  display: flex;
50
  flex-direction: column;
 
51
  }
52
  .message {
53
  max-width: 80%;
@@ -268,7 +269,58 @@ transform: translateY(100%);
268
  background-color: #e0e0e0;
269
  color: #000;
270
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
 
 
 
 
 
 
 
 
 
 
 
272
  </style>
273
  </head>
274
  <body>
@@ -296,12 +348,11 @@ transform: translateY(100%);
296
  </div>
297
  </div>
298
  <div class="input-area" :class="{ 'input-hidden': isScrollingUp }">
299
- <div v-if="showToolOptions" class="tool-options">
300
- <button @click="selectTool('web')">/web</button>
301
- <button @click="selectTool('news')">/news</button>
302
- </div>
303
- <input type="text" id="user-input" v-model="userInput" @keyup.enter="sendMessage" @input="handleInput($event)" placeholder="Type your message... (type / to see available tools)">
304
-
305
  <button class="send-button" @click="sendMessage">
306
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
307
  <line x1="22" y1="2" x2="11" y2="13"></line>
@@ -384,6 +435,7 @@ transform: translateY(100%);
384
  const reader = response.body.getReader();
385
  let rawResponse = '';
386
  let jsonData = null;
 
387
  while (true) {
388
  const { done, value } = await reader.read();
389
  if (done) break;
@@ -392,15 +444,41 @@ transform: translateY(100%);
392
  const [textPart, jsonPart] = chunk.split('<json>');
393
  rawResponse += textPart;
394
  const jsonString = jsonPart.split('</json>')[0];
395
- try {
396
- jsonData = JSON.parse(jsonString);
397
- } catch (error) {
398
- console.error("JSON parsing error:", error);
399
- console.log("Raw JSON string:", jsonString);
 
 
 
 
 
 
400
  }
401
  } else {
402
  rawResponse += chunk;
403
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
 
405
  rawResponse = rawResponse.replace(/<\/?response>/g, '');
406
  rawResponse = rawResponse.replace(/<tools>[\s\S]*?<\/tools>/g, '');
@@ -563,7 +641,6 @@ transform: translateY(100%);
563
  message.isPlaying = !message.isPlaying;
564
  this.$forceUpdate();
565
  },
566
- // remove alert
567
  copyMarkdownToClipboard(rawResponse) {
568
  navigator.clipboard.writeText(rawResponse).then(() => {
569
  // remove alert
@@ -605,6 +682,9 @@ transform: translateY(100%);
605
  }
606
  }
607
  },
 
 
 
608
  },
609
  mounted() {
610
  this.resetConversation();
 
12
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/atom-one-dark.min.css">
13
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
14
  <style>
15
+ :root {
16
  --primary-color: #304b76;;
17
  --secondary-color: #f0f8ff;
18
  --text-color: #333;
 
48
  padding: 20px;
49
  display: flex;
50
  flex-direction: column;
51
+
52
  }
53
  .message {
54
  max-width: 80%;
 
269
  background-color: #e0e0e0;
270
  color: #000;
271
  }
272
+ /* ... Reference styles ... */
273
+
274
+ details {
275
+ margin-top: 10px;
276
+ border-radius: 4px;
277
+ padding: 5px;
278
+
279
+ }
280
+
281
+ summary {
282
+ cursor: pointer;
283
+ font-weight: bold;
284
+ }
285
+
286
+ .ref-content {
287
+ margin-top: 10px;
288
+ justify-content: center;
289
+ }
290
+
291
+ .ref-item {
292
+ margin-bottom: 0px;
293
+
294
+
295
+ }
296
+
297
+ .ref-item small {
298
+ color: #666;
299
+ }
300
+
301
+ hr {
302
+ margin: 10px 0;
303
+ border: none;
304
+ border-top: 1px solid #eee;
305
+ }
306
+ .ref-link {
307
+ text-decoration: none;
308
+ color: inherit;
309
+ display: block;
310
+ padding: 5px;
311
+ border-radius: 4px;
312
+ transition: background-color 0.2s;
313
 
314
+ }
315
+
316
+ .ref-link:hover {
317
+ background-color: #e3e3ea;
318
+ color: inherit;
319
+ }
320
+
321
+ .ref-link:visited {
322
+ color: inherit;
323
+ }
324
  </style>
325
  </head>
326
  <body>
 
348
  </div>
349
  </div>
350
  <div class="input-area" :class="{ 'input-hidden': isScrollingUp }">
351
+ <input type="text" id="user-input" v-model="userInput" @keyup.enter="sendMessage" @input="handleInput($event)" placeholder="Type your message...">
352
+ <div v-if="showToolOptions" class="tool-options">
353
+ <button @click="selectTool('web')">/web</button>
354
+ <button @click="selectTool('news')">/news</button>
355
+ </div>
 
356
  <button class="send-button" @click="sendMessage">
357
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
358
  <line x1="22" y1="2" x2="11" y2="13"></line>
 
435
  const reader = response.body.getReader();
436
  let rawResponse = '';
437
  let jsonData = null;
438
+ let refData = null; // New variable to hold reference data
439
  while (true) {
440
  const { done, value } = await reader.read();
441
  if (done) break;
 
444
  const [textPart, jsonPart] = chunk.split('<json>');
445
  rawResponse += textPart;
446
  const jsonString = jsonPart.split('</json>')[0];
447
+ // Check for <ref> tag first
448
+ const refMatch = jsonString.match(/<ref>(.*?)<\/ref>/);
449
+ if (refMatch) {
450
+ refData = JSON.parse(refMatch[1]); // Parse the reference data
451
+ } else {
452
+ try {
453
+ jsonData = JSON.parse(jsonString); // Parse JSON only if <ref> is not present
454
+ } catch (error) {
455
+ console.error("JSON parsing error:", error);
456
+ console.log("Raw JSON string:", jsonString);
457
+ }
458
  }
459
  } else {
460
  rawResponse += chunk;
461
  }
462
+ // After processing, display the refData if it exists
463
+ if (refData) {
464
+ const refMessage = `
465
+ <details>
466
+ <summary>Reference Information</summary>
467
+ <div class="ref-content">
468
+ ${refData.map(item => `
469
+ <div class="ref-item">
470
+ <a href="${item.url}" target="_blank" class="ref-link">
471
+ <strong>${item.title}</strong>: ${item.snippet}
472
+ </a>
473
+ <br>
474
+ <small>Last updated: ${item.last_updated}</small>
475
+ </div>
476
+ `).join('<hr>')}
477
+ </div>
478
+ </details>
479
+ `;
480
+ this.messages.push({ type: 'bot', content: refMessage });
481
+ }
482
 
483
  rawResponse = rawResponse.replace(/<\/?response>/g, '');
484
  rawResponse = rawResponse.replace(/<tools>[\s\S]*?<\/tools>/g, '');
 
641
  message.isPlaying = !message.isPlaying;
642
  this.$forceUpdate();
643
  },
 
644
  copyMarkdownToClipboard(rawResponse) {
645
  navigator.clipboard.writeText(rawResponse).then(() => {
646
  // remove alert
 
682
  }
683
  }
684
  },
685
+ toggleSnippet(index) {
686
+ this.$set(this.expandedSnippets, index, !this.expandedSnippets[index]);
687
+ },
688
  },
689
  mounted() {
690
  this.resetConversation();