Repository navigation
Expand file tree
/
Copy pathai-research-assistant-user-guideline.html
More file actions
585 lines (542 loc) · 33.4 KB
/
Copy pathai-research-assistant-user-guideline.html
File metadata and controls
585 lines (542 loc) · 33.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Research Assistant - User Guideline</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.gradient-bg {
background: linear-gradient(to bottom right, #eef2ff, #f0f9ff, #faf5ff);
}
.step-blue { background-color: #dbeafe; color: #1e40af; }
.step-yellow { background-color: #fef3c7; color: #78350f; }
.step-purple { background-color: #e9d5ff; color: #6b21a8; }
.step-green { background-color: #d1fae5; color: #065f46; }
/* Citation marker */
.cite-btn {
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
font-weight: 600;
color: #4338ca;
background: #e0e7ff;
border: 1px solid #c7d2fe;
border-radius: 4px;
padding: 0 4px;
margin: 0 1px;
vertical-align: super;
line-height: 1.2;
cursor: pointer;
transition: background-color 0.15s;
}
.cite-btn:hover { background: #c7d2fe; }
.cite-btn.open { background: #4f46e5; color: #ffffff; border-color: #4f46e5; }
</style>
</head>
<body class="min-h-screen gradient-bg">
<!-- Hero Section -->
<div class="bg-white shadow-sm border-b">
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<a href="index.html" class="inline-flex items-center gap-2 text-sm font-medium text-indigo-700 bg-indigo-50 hover:bg-indigo-100 rounded-lg px-3 py-2 mb-6 transition-colors">
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
Back to Home
</a>
<div class="text-center">
<div class="inline-block mb-6">
<div class="text-4xl font-bold text-indigo-600 mb-2" style="letter-spacing: 2px;">
DEMO LOGO
</div>
<div class="text-sm text-gray-500 font-medium" style="letter-spacing: 4px;">
AI RESEARCH ASSISTANT
</div>
</div>
<h1 class="text-4xl font-bold text-gray-900 mb-3">
AI Research Assistant
</h1>
<p class="text-xl text-gray-600 max-w-3xl mx-auto mb-5">
Ask questions, summarize findings, and compare information across research documents—with references to the original sources.
</p>
<div class="inline-flex items-center gap-2 text-sm font-medium text-amber-800 bg-amber-50 border border-amber-200 rounded-lg px-4 py-2">
<svg class="h-4 w-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
Interactive demo using sample documents and predefined responses
</div>
</div>
</div>
</div>
<!-- Main Content -->
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-12 space-y-8">
<!-- Overview -->
<section class="bg-white rounded-xl shadow-lg p-6">
<h2 class="text-2xl font-bold text-gray-900 mb-4 flex items-center">
<svg class="h-6 w-6 mr-2 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" />
</svg>
Overview
</h2>
<p class="text-gray-600 mb-4">
The AI Research Assistant works on top of the document library showcased in the
<a href="ai-knowledge-base-user-guideline.html" class="text-indigo-600 font-medium hover:text-indigo-700 hover:underline">AI Knowledge Base</a>.
Instead of returning matching passages, it composes an answer from the retrieved content: researchers can ask questions,
request summaries, or compare information across documents. Answers include references to supporting passages,
so key statements can be checked against the original documents.
</p>
<div class="grid grid-cols-2 md:grid-cols-4 gap-2 text-sm">
<div class="flex items-center gap-2 border border-gray-200 rounded-lg px-3 py-2 text-gray-700">
<svg class="w-4 h-4 text-indigo-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span class="font-medium">Document Q&A</span>
</div>
<div class="flex items-center gap-2 border border-gray-200 rounded-lg px-3 py-2 text-gray-700">
<svg class="w-4 h-4 text-indigo-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h10M4 18h6" />
</svg>
<span class="font-medium">Summarization</span>
</div>
<div class="flex items-center gap-2 border border-gray-200 rounded-lg px-3 py-2 text-gray-700">
<svg class="w-4 h-4 text-indigo-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7" />
</svg>
<span class="font-medium">Comparison</span>
</div>
<div class="flex items-center gap-2 border border-gray-200 rounded-lg px-3 py-2 text-gray-700">
<svg class="w-4 h-4 text-indigo-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" />
</svg>
<span class="font-medium">Source references</span>
</div>
</div>
</section>
<!-- Interactive Demo -->
<section id="demo" class="bg-white rounded-xl shadow-lg p-6">
<div class="flex items-center justify-between flex-wrap gap-2 mb-4">
<h2 class="text-2xl font-bold text-gray-900 flex items-center">
<svg class="h-6 w-6 mr-2 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" />
</svg>
Try the Assistant
</h2>
<button onclick="resetConversation()" class="inline-flex items-center gap-2 text-xs font-medium text-gray-600 bg-gray-100 hover:bg-gray-200 rounded-lg px-3 py-1.5 transition-colors">
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
Reset conversation
</button>
</div>
<!-- Scope selector -->
<div class="flex flex-col sm:flex-row sm:items-center gap-2 mb-4">
<label for="scope-select" class="text-sm font-medium text-gray-700 flex-shrink-0">Document scope:</label>
<select id="scope-select" onchange="setScope(this.value)"
class="border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 sm:w-72">
<option value="all">All sample documents</option>
<option value="microbiome">Microbiome Pilot Study</option>
<option value="imaging">Imaging Protocol Review</option>
</select>
<span class="text-xs text-gray-500">Example tasks update to match the selected scope.</span>
</div>
<!-- Conversation area -->
<div id="conversation" class="bg-gray-50 border border-gray-200 rounded-lg p-4 space-y-4 max-h-[36rem] overflow-y-auto mb-4">
<!-- Rendered by JS -->
</div>
<!-- Example task chips -->
<div class="flex flex-wrap items-center gap-2 mb-3" id="example-chips">
<!-- Rendered by JS -->
</div>
<!-- Input -->
<div class="flex flex-col sm:flex-row gap-2">
<input id="question-input" type="text" placeholder="Ask a question about the sample documents..."
class="flex-1 border border-gray-300 rounded-lg px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
onkeydown="if(event.key==='Enter'){submitQuestion();}">
<button onclick="submitQuestion()" class="inline-flex items-center justify-center gap-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium px-5 py-2.5 rounded-lg transition-colors">
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
</svg>
Ask
</button>
</div>
</section>
<!-- Workflow -->
<section class="bg-white rounded-xl shadow-lg p-6">
<h2 class="text-2xl font-bold text-gray-900 mb-6 flex items-center">
<svg class="h-6 w-6 mr-2 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6" />
</svg>
Workflow
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div class="border-2 border-gray-200 rounded-lg p-4 hover:border-indigo-500 transition-colors">
<div class="flex items-start">
<div class="step-blue rounded-full w-9 h-9 flex items-center justify-center font-bold mr-3 flex-shrink-0">1</div>
<div>
<h3 class="font-semibold text-gray-900 mb-1 text-sm">Select document scope</h3>
<p class="text-xs text-gray-600">All documents, or a single project collection</p>
</div>
</div>
</div>
<div class="border-2 border-gray-200 rounded-lg p-4 hover:border-indigo-500 transition-colors">
<div class="flex items-start">
<div class="step-yellow rounded-full w-9 h-9 flex items-center justify-center font-bold mr-3 flex-shrink-0">2</div>
<div>
<h3 class="font-semibold text-gray-900 mb-1 text-sm">Ask a question</h3>
<p class="text-xs text-gray-600">A question, a summary request, or a comparison</p>
</div>
</div>
</div>
<div class="border-2 border-gray-200 rounded-lg p-4 hover:border-indigo-500 transition-colors">
<div class="flex items-start">
<div class="step-purple rounded-full w-9 h-9 flex items-center justify-center font-bold mr-3 flex-shrink-0">3</div>
<div>
<h3 class="font-semibold text-gray-900 mb-1 text-sm">Review the answer and sources</h3>
<p class="text-xs text-gray-600">Open each citation to check the supporting passage</p>
</div>
</div>
</div>
<div class="border-2 border-gray-200 rounded-lg p-4 hover:border-indigo-500 transition-colors">
<div class="flex items-start">
<div class="step-green rounded-full w-9 h-9 flex items-center justify-center font-bold mr-3 flex-shrink-0">4</div>
<div>
<h3 class="font-semibold text-gray-900 mb-1 text-sm">Ask a follow-up</h3>
<p class="text-xs text-gray-600">Continue the conversation — try the suggested follow-up in the demo above</p>
</div>
</div>
</div>
</div>
</section>
<!-- Bottom disclaimer -->
<div class="text-center text-xs text-gray-500 max-w-3xl mx-auto leading-relaxed">
All projects, documents, excerpts, and answers on this page are fictional sample content created for demonstration.
Responses are predefined and run entirely in your browser — no AI model or API is called, and this page is not
connected to any production system.
</div>
</div>
<!-- Footer -->
<div class="bg-white border-t mt-12">
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<p class="text-center text-sm text-gray-600">
AI Research Assistant
</p>
</div>
</div>
<script>
// ============================================================
// Sample data: fictional documents, questions, and predefined
// answers. Consistent with the AI Knowledge Base sample library.
// ============================================================
const SCOPE_LABELS = {
all: 'All sample documents',
microbiome: 'Microbiome Pilot Study',
imaging: 'Imaging Protocol Review'
};
const EXAMPLES = {
ask: {
chip: 'Ask a question',
icon: 'M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z',
question: 'What are the inclusion and exclusion criteria for the pilot study?',
scopes: ['all', 'microbiome'],
keywords: ['inclusion', 'exclusion', 'criteria', 'eligib'],
followUp: 'askWhy',
answer: `
<p class="mb-2">Based on the study protocol, the pilot study applies the following criteria:</p>
<p class="mb-1"><span class="font-semibold">Inclusion</span> [[1]]</p>
<ul class="list-disc pl-5 mb-2 space-y-0.5">
<li>Adults aged 18–65</li>
<li>Able to provide informed consent</li>
<li>No systemic antibiotic use within the 90 days before enrollment</li>
<li>Willing to complete all three stool-sample collections</li>
</ul>
<p class="mb-1"><span class="font-semibold">Exclusion</span> [[2]]</p>
<ul class="list-disc pl-5 space-y-0.5">
<li>Current pregnancy</li>
<li>Physician-diagnosed chronic gastrointestinal disease</li>
<li>Immunosuppressive medication within the 6 months prior to screening</li>
</ul>`,
sources: [
{
doc: 'Microbiome Pilot - Study Protocol.pdf',
loc: 'Page 6 · Section 4.2 Eligibility Criteria',
excerpt: '“4.2 Eligibility Criteria. Adults aged 18–65 are eligible if they meet all inclusion criteria: ability to provide informed consent, no systemic antibiotic use within the 90 days prior to enrollment, and willingness to complete the three stool-sample collections described in Section 5.”'
},
{
doc: 'Microbiome Pilot - Study Protocol.pdf',
loc: 'Page 7 · Table 2 Exclusion Criteria',
excerpt: '“Table 2 — Exclusion Criteria: current pregnancy; physician-diagnosed chronic gastrointestinal disease; use of immunosuppressive medication within the 6 months prior to screening.”'
}
]
},
askWhy: {
// Follow-up to "ask" — offered as a suggested follow-up, not an example chip
question: 'Why is recent antibiotic use an exclusion?',
scopes: ['all', 'microbiome'],
keywords: ['antibiotic', 'washout'],
answer: `
<p class="mb-2">The protocol explains that systemic antibiotics can substantially alter gut microbiome composition,
and the effect can persist for weeks after treatment ends [[1]].</p>
<p>The 90-day window acts as a washout period, so that the stool samples collected at enrollment reflect each
participant's baseline microbiome rather than a recent antibiotic effect.</p>`,
sources: [
{
doc: 'Microbiome Pilot - Study Protocol.pdf',
loc: 'Page 6 · Section 4.2 Eligibility Criteria (rationale note)',
excerpt: '“Rationale: systemic antibiotic exposure can markedly shift gut microbial composition, with effects persisting for several weeks after treatment. A 90-day antibiotic-free window is required so that enrollment samples represent the participant’s baseline microbiome.”'
}
]
},
summarize: {
chip: 'Summarize',
icon: 'M4 6h16M4 10h16M4 14h10M4 18h6',
question: 'Summarize the data quality checks described in these documents.',
scopes: ['all'],
keywords: ['summar', 'quality check', 'qc'],
answer: `
<p class="mb-2">Two documents describe quality checks, at different stages of the data pipeline:</p>
<ul class="list-disc pl-5 space-y-1.5">
<li><span class="font-semibold">Survey data entry</span> [[1]] — every variable has an allowed value range, unit, and missing-value codes; automated checks run at data entry and flag out-of-range values for review before a record is accepted.</li>
<li><span class="font-semibold">Sequencing QC</span> [[2]] — libraries are checked against read-count, duplication-rate, and insert-size thresholds; failing samples are re-sequenced (in Batch 7, 2 of 96 libraries were re-run and passed on the second attempt).</li>
</ul>`,
sources: [
{
doc: 'Data Dictionary - Survey Wave 1.pdf',
loc: 'Page 12 · Variable QC Rules',
excerpt: '“Each variable entry specifies the allowed value range, unit, and missing-value codes (-97, -98, -99). Automated quality checks run at data entry and flag out-of-range values for review before the record is accepted into the survey dataset.”'
},
{
doc: 'Sequencing QC Notes.txt',
loc: 'Lines 24–31 · Batch 7 summary',
excerpt: '“Batch 7 QC summary: 94/96 libraries passed on first run. Samples S-041 and S-087 showed low read counts and were re-sequenced; both passed on the second run. All remaining metrics (duplication rate, insert size) within expected thresholds.”'
}
]
},
compare: {
chip: 'Compare documents',
icon: 'M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7',
question: 'Compare the imaging acquisition settings across the two protocols.',
scopes: ['all', 'imaging'],
keywords: ['compare', 'imaging', 'acquisition'],
answer: `
<p class="mb-2">The two site protocols differ on all three acquisition parameters:</p>
<div class="overflow-x-auto mb-2">
<table class="min-w-[430px] w-full text-xs border border-gray-200 rounded">
<thead>
<tr class="bg-gray-100 text-left text-gray-600">
<th class="px-3 py-2 font-semibold">Parameter</th>
<th class="px-3 py-2 font-semibold">Site A protocol [[1]]</th>
<th class="px-3 py-2 font-semibold">Site B protocol [[2]]</th>
<th class="px-3 py-2 font-semibold">Difference</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<tr><td class="px-3 py-2 font-medium text-gray-800">Field of view</td><td class="px-3 py-2">220 mm</td><td class="px-3 py-2">240 mm</td><td class="px-3 py-2 text-gray-600">20 mm larger at Site B</td></tr>
<tr><td class="px-3 py-2 font-medium text-gray-800">Slice thickness</td><td class="px-3 py-2">2.5 mm</td><td class="px-3 py-2">3.0 mm</td><td class="px-3 py-2 text-gray-600">0.5 mm thicker at Site B</td></tr>
<tr><td class="px-3 py-2 font-medium text-gray-800">Repetition time (TR)</td><td class="px-3 py-2">2000 ms</td><td class="px-3 py-2">2200 ms</td><td class="px-3 py-2 text-gray-600">200 ms longer at Site B</td></tr>
</tbody>
</table>
</div>
<p>The cross-site review recommends harmonizing these parameters before the next imaging wave [[3]].</p>`,
sources: [
{
doc: 'Site A Imaging Protocol.pdf',
loc: 'Page 4 · Acquisition Parameters',
excerpt: '“Axial T2 acquisition: field of view 220 mm, slice thickness 2.5 mm, repetition time (TR) 2000 ms, matrix 256 × 256.”'
},
{
doc: 'Site B Imaging Protocol.pdf',
loc: 'Page 3 · Scan Parameters',
excerpt: '“Axial T2 series: field of view 240 mm, slice thickness 3.0 mm, repetition time (TR) 2200 ms, matrix 256 × 256.”'
},
{
doc: 'Imaging Protocol Review - Summary.pdf',
loc: 'Page 3 · Recommendations',
excerpt: '“Recommendation 2: Harmonize acquisition settings across the two participating sites — in particular field of view, slice thickness, and repetition time — and document the agreed parameters in the shared protocol before the next imaging wave begins.”'
}
]
},
outcomes: {
chip: 'Ask about missing info',
icon: 'M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z',
question: 'What were the final clinical outcomes of the pilot study?',
scopes: ['all', 'microbiome'],
keywords: ['outcome', 'results of the pilot', 'final'],
answer: `
<p class="mb-2">The documents currently in scope do not report final clinical outcomes.</p>
<p class="mb-2">The only pilot-study document available is the study protocol, which describes the design, eligibility criteria,
and sample collection procedures — it states that results will be reported separately after data collection is complete [[1]].</p>
<p class="text-gray-600">To answer this question, the final study report or outcomes dataset would need to be added to the knowledge base.</p>`,
sources: [
{
doc: 'Microbiome Pilot - Study Protocol.pdf',
loc: 'Page 2 · Study Synopsis',
excerpt: '“This protocol describes the design, eligibility criteria, and sample collection schedule for the pilot. Study results will be analyzed and reported separately after data collection is complete.”'
}
]
}
};
const EXAMPLE_ORDER = ['ask', 'summarize', 'compare', 'outcomes']; // shown as chips
const MATCH_ORDER = [...EXAMPLE_ORDER, 'askWhy']; // matchable from free input
// ============================================================
// State
// ============================================================
let currentScope = 'all';
let msgCounter = 0;
// ============================================================
// Rendering helpers
// ============================================================
function conversationEl() { return document.getElementById('conversation'); }
function scrollConversation() {
const c = conversationEl();
c.scrollTop = c.scrollHeight;
}
function appendNote(text) {
conversationEl().insertAdjacentHTML('beforeend',
`<div class="text-center"><span class="inline-block text-xs text-gray-500 bg-gray-100 border border-gray-200 rounded-full px-3 py-1">${text}</span></div>`);
}
function appendUser(text) {
conversationEl().insertAdjacentHTML('beforeend', `
<div class="flex justify-end">
<div class="max-w-[85%] bg-indigo-600 text-white text-sm rounded-2xl rounded-br-sm px-4 py-2.5 leading-relaxed">${text}</div>
</div>`);
}
function appendAssistant(example) {
msgCounter++;
const m = msgCounter;
// Replace [[n]] tokens with citation buttons
const answerHtml = example.answer.replace(/\[\[(\d)\]\]/g, function (_, n) {
return `<button class="cite-btn" id="cite-${m}-${n}" onclick="toggleSource(${m}, ${n})" title="View source ${n}">${n}</button>`;
});
const sourcesHtml = example.sources.map((s, i) => `
<div id="source-${m}-${i + 1}" class="hidden mt-2 border-l-4 border-indigo-300 bg-indigo-50/60 rounded-r-lg p-3">
<div class="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-gray-500 mb-1.5">
<span class="inline-flex items-center justify-center w-4 h-4 rounded bg-indigo-600 text-white text-[10px] font-bold flex-shrink-0">${i + 1}</span>
<span class="font-medium text-gray-700">${s.doc}</span>
<span class="text-gray-400">·</span>
<span>${s.loc}</span>
</div>
<p class="text-xs text-gray-700 leading-relaxed italic">${s.excerpt}</p>
</div>`).join('');
conversationEl().insertAdjacentHTML('beforeend', `
<div class="flex justify-start">
<div class="max-w-[92%] w-fit bg-white border border-gray-200 rounded-2xl rounded-bl-sm px-4 py-3 shadow-sm">
<div class="text-sm text-gray-800 leading-relaxed">${answerHtml}</div>
${sourcesHtml}
</div>
</div>`);
// Offer a suggested follow-up question, if this example has one
if (example.followUp && EXAMPLES[example.followUp].scopes.includes(currentScope)) {
conversationEl().insertAdjacentHTML('beforeend', `
<div id="followup-${m}" class="flex justify-end">
<button onclick="runFollowUp('${example.followUp}', ${m})"
class="inline-flex items-center gap-1.5 text-xs font-medium text-indigo-700 bg-white hover:bg-indigo-50 border border-dashed border-indigo-300 rounded-full px-3 py-1.5 transition-colors">
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a4 4 0 014 4v1m0 0l-3-3m3 3l3-3" transform="rotate(180 12 12)" />
</svg>
Suggested follow-up: ${EXAMPLES[example.followUp].question}
</button>
</div>`);
}
return m;
}
function runFollowUp(id, fromMsgId) {
const suggestion = document.getElementById(`followup-${fromMsgId}`);
if (suggestion) suggestion.remove();
appendUser(EXAMPLES[id].question);
appendAssistant(EXAMPLES[id]);
scrollConversation();
}
function appendDemoNotice() {
conversationEl().insertAdjacentHTML('beforeend', `
<div class="flex justify-start">
<div class="max-w-[92%] bg-gray-50 border border-dashed border-gray-300 rounded-2xl rounded-bl-sm px-4 py-3">
<p class="text-sm text-gray-600 leading-relaxed">
This demo answers only the predefined example tasks — it doesn't generate responses to arbitrary
questions, and no AI service is called. Please pick one of the example tasks below, or reset the conversation.
</p>
</div>
</div>`);
}
function toggleSource(msgId, n) {
const panel = document.getElementById(`source-${msgId}-${n}`);
const btn = document.getElementById(`cite-${msgId}-${n}`);
if (!panel) return;
const nowHidden = panel.classList.toggle('hidden');
if (btn) btn.classList.toggle('open', !nowHidden);
if (!nowHidden) panel.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
// ============================================================
// Example chips & scope
// ============================================================
function renderChips() {
const container = document.getElementById('example-chips');
const chips = EXAMPLE_ORDER.filter(id => EXAMPLES[id].scopes.includes(currentScope));
container.innerHTML = '<span class="text-xs text-gray-500 font-medium">Example tasks:</span>' + chips.map(id => `
<button onclick="runExample('${id}')" class="inline-flex items-center gap-1.5 text-xs font-medium text-indigo-700 bg-indigo-50 hover:bg-indigo-100 border border-indigo-200 rounded-full px-3 py-1.5 transition-colors">
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="${EXAMPLES[id].icon}" />
</svg>
${EXAMPLES[id].chip}
</button>`).join('');
}
function setScope(scope) {
currentScope = scope;
document.getElementById('scope-select').value = scope;
conversationEl().innerHTML = '';
appendNote(`Scope: ${SCOPE_LABELS[scope]}`);
renderChips();
}
function runExample(id) {
const ex = EXAMPLES[id];
if (!ex || !ex.scopes.includes(currentScope)) return;
appendUser(ex.question);
appendAssistant(ex);
scrollConversation();
}
// ============================================================
// Free input
// ============================================================
function submitQuestion() {
const input = document.getElementById('question-input');
const text = input.value.trim();
if (!text) return;
input.value = '';
const lower = text.toLowerCase();
const match = MATCH_ORDER.find(id =>
EXAMPLES[id].scopes.includes(currentScope) &&
EXAMPLES[id].keywords.some(k => lower.includes(k))
);
if (match) {
appendUser(text);
appendAssistant(EXAMPLES[match]);
} else {
appendUser(text);
appendDemoNotice();
}
scrollConversation();
}
// ============================================================
// Reset & init
// ============================================================
function resetConversation() {
currentScope = 'all';
document.getElementById('scope-select').value = 'all';
document.getElementById('question-input').value = '';
conversationEl().innerHTML = '';
appendNote(`Scope: ${SCOPE_LABELS.all}`);
renderChips();
// Default worked example: first question with its first source expanded
appendUser(EXAMPLES.ask.question);
const m = appendAssistant(EXAMPLES.ask);
toggleSource(m, 1);
conversationEl().scrollTop = 0;
}
document.addEventListener('DOMContentLoaded', resetConversation);
</script>
</body>
</html>