avakanski commited on
Commit
40f6083
·
verified ·
1 Parent(s): 532d263

Upload 6 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ rag_index/default__vector_store.json filter=lfs diff=lfs merge=lfs -text
37
+ rag_index/docstore.json filter=lfs diff=lfs merge=lfs -text
rag_index/default__vector_store.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:603331cb264670dfde965c30760230a5daa27bab8187330d8fd68c9c30bde59c
3
+ size 325804547
rag_index/docstore.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b4c9b06c032fb260cc8050ad10e7d1dbe3aa87155e9a5da5a7487e0d05c0273
3
+ size 59050518
rag_index/graph_store.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"graph_dict": {}}
rag_index/image__vector_store.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"embedding_dict": {}, "text_id_to_ref_doc_id": {}, "metadata_dict": {}}
rag_index/index_store.json ADDED
The diff for this file is too large to render. See raw diff
 
static/index.html ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>US Army RAG System</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap" rel="stylesheet">
8
+ <style>
9
+ :root {
10
+ --primary: #4F46E5;
11
+ --primary-hover: #4338CA;
12
+ --bg-dark: #0F172A;
13
+ --bg-card: #1E293B;
14
+ --text-main: #F8FAFC;
15
+ --text-muted: #94A3B8;
16
+ --accent: #10B981;
17
+ }
18
+
19
+ * {
20
+ margin: 0;
21
+ padding: 0;
22
+ box-sizing: border-box;
23
+ font-family: 'Outfit', sans-serif;
24
+ }
25
+
26
+ body {
27
+ background-color: var(--bg-dark);
28
+ color: var(--text-main);
29
+ min-height: 100vh;
30
+ display: flex;
31
+ flex-direction: column;
32
+ align-items: center;
33
+ padding: 2rem;
34
+ background-image: radial-gradient(circle at top right, #1e1b4b 0%, transparent 40%),
35
+ radial-gradient(circle at bottom left, #064e3b 0%, transparent 40%);
36
+ }
37
+
38
+ .container {
39
+ width: 100%;
40
+ max-width: 800px;
41
+ margin-top: 4rem;
42
+ }
43
+
44
+ header {
45
+ text-align: center;
46
+ margin-bottom: 3rem;
47
+ animation: fadeIn 0.8s ease-out;
48
+ }
49
+
50
+ h1 {
51
+ font-size: 3rem;
52
+ font-weight: 600;
53
+ background: linear-gradient(to right, #818cf8, #34d399);
54
+ -webkit-background-clip: text;
55
+ -webkit-text-fill-color: transparent;
56
+ margin-bottom: 0.5rem;
57
+ }
58
+
59
+ .subtitle {
60
+ color: var(--text-muted);
61
+ font-size: 1.1rem;
62
+ }
63
+
64
+ .search-box {
65
+ background: rgba(30, 41, 59, 0.7);
66
+ backdrop-filter: blur(10px);
67
+ border: 1px solid rgba(255, 255, 255, 0.1);
68
+ padding: 1.5rem;
69
+ border-radius: 1.5rem;
70
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
71
+ margin-bottom: 2rem;
72
+ position: relative;
73
+ animation: slideUp 0.8s ease-out;
74
+ }
75
+
76
+ .input-group {
77
+ display: flex;
78
+ gap: 1rem;
79
+ position: relative;
80
+ }
81
+
82
+ input[type="text"] {
83
+ width: 100%;
84
+ padding: 1rem 1.5rem;
85
+ background: rgba(15, 23, 42, 0.6);
86
+ border: 1px solid rgba(255, 255, 255, 0.1);
87
+ border-radius: 1rem;
88
+ color: white;
89
+ font-size: 1.1rem;
90
+ transition: all 0.3s ease;
91
+ }
92
+
93
+ input[type="text"]:focus {
94
+ outline: none;
95
+ border-color: var(--primary);
96
+ box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
97
+ }
98
+
99
+ button {
100
+ padding: 1rem 2rem;
101
+ background: var(--primary);
102
+ color: white;
103
+ border: none;
104
+ border-radius: 1rem;
105
+ font-weight: 600;
106
+ font-size: 1rem;
107
+ cursor: pointer;
108
+ transition: all 0.2s ease;
109
+ white-space: nowrap;
110
+ }
111
+
112
+ button:hover {
113
+ background: var(--primary-hover);
114
+ transform: translateY(-2px);
115
+ box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
116
+ }
117
+
118
+ button:active {
119
+ transform: translateY(0);
120
+ }
121
+
122
+ button:disabled {
123
+ background: var(--text-muted);
124
+ cursor: not-allowed;
125
+ transform: none;
126
+ }
127
+
128
+ #loading {
129
+ display: none;
130
+ text-align: center;
131
+ margin: 2rem 0;
132
+ color: var(--primary);
133
+ }
134
+
135
+ .spinner {
136
+ width: 30px;
137
+ height: 30px;
138
+ border: 3px solid rgba(255, 255, 255, 0.1);
139
+ border-top-color: var(--primary);
140
+ border-radius: 50%;
141
+ animation: spin 1s linear infinite;
142
+ margin: 0 auto 1rem;
143
+ }
144
+
145
+ #results {
146
+ display: none;
147
+ animation: fadeIn 0.5s ease-out;
148
+ }
149
+
150
+ .answer-card {
151
+ background: rgba(30, 41, 59, 0.7);
152
+ backdrop-filter: blur(10px);
153
+ border: 1px solid rgba(255, 255, 255, 0.1);
154
+ border-radius: 1.5rem;
155
+ padding: 2rem;
156
+ margin-bottom: 1.5rem;
157
+ }
158
+
159
+ .section-title {
160
+ color: var(--accent);
161
+ text-transform: uppercase;
162
+ letter-spacing: 0.1em;
163
+ font-size: 0.85rem;
164
+ font-weight: 600;
165
+ margin-bottom: 1rem;
166
+ display: flex;
167
+ align-items: center;
168
+ gap: 0.5rem;
169
+ }
170
+
171
+ .answer-text {
172
+ line-height: 1.7;
173
+ font-size: 1.1rem;
174
+ color: #E2E8F0;
175
+ white-space: pre-wrap;
176
+ }
177
+
178
+ .sources-grid {
179
+ display: grid;
180
+ gap: 1rem;
181
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
182
+ margin-top: 2rem;
183
+ }
184
+
185
+ .source-card {
186
+ background: rgba(15, 23, 42, 0.5);
187
+ padding: 1.5rem;
188
+ border-radius: 1rem;
189
+ border: 1px solid rgba(255, 255, 255, 0.05);
190
+ transition: transform 0.2s ease;
191
+ }
192
+
193
+ .source-card:hover {
194
+ transform: translateY(-2px);
195
+ background: rgba(15, 23, 42, 0.8);
196
+ }
197
+
198
+ .source-title {
199
+ font-weight: 600;
200
+ margin-bottom: 0.5rem;
201
+ color: #93C5FD;
202
+ font-size: 0.95rem;
203
+ }
204
+
205
+ .source-meta {
206
+ font-size: 0.85rem;
207
+ color: var(--text-muted);
208
+ margin-bottom: 0.8rem;
209
+ }
210
+
211
+ .source-excerpt {
212
+ font-size: 0.9rem;
213
+ color: #CBD5E1;
214
+ line-height: 1.5;
215
+ font-style: italic;
216
+ }
217
+
218
+ @keyframes spin {
219
+ to { transform: rotate(360deg); }
220
+ }
221
+
222
+ @keyframes fadeIn {
223
+ from { opacity: 0; transform: translateY(10px); }
224
+ to { opacity: 1; transform: translateY(0); }
225
+ }
226
+
227
+ @keyframes slideUp {
228
+ from { opacity: 0; transform: translateY(20px); }
229
+ to { opacity: 1; transform: translateY(0); }
230
+ }
231
+
232
+ /* Scrollbar */
233
+ ::-webkit-scrollbar {
234
+ width: 8px;
235
+ }
236
+ ::-webkit-scrollbar-track {
237
+ background: var(--bg-dark);
238
+ }
239
+ ::-webkit-scrollbar-thumb {
240
+ background: var(--bg-card);
241
+ border-radius: 4px;
242
+ }
243
+ ::-webkit-scrollbar-thumb:hover {
244
+ background: var(--text-muted);
245
+ }
246
+ </style>
247
+ </head>
248
+ <body>
249
+ <div class="container">
250
+ <header>
251
+ <h1>Medical Research RAG</h1>
252
+ <p class="subtitle">AI-Powered Question Answering System</p>
253
+ </header>
254
+
255
+ <div class="search-box">
256
+ <div class="input-group">
257
+ <input type="text" id="questionInput" placeholder="Ask a question about medical research..." autocomplete="off">
258
+ <button id="searchBtn" onclick="askQuestion()">
259
+ Ask AI
260
+ </button>
261
+ </div>
262
+ </div>
263
+
264
+ <div id="loading">
265
+ <div class="spinner"></div>
266
+ <p>Analyzing medical papers...</p>
267
+ </div>
268
+
269
+ <div id="results">
270
+ <div class="answer-card">
271
+ <div class="section-title">
272
+ <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg>
273
+ AI Consolidated Answer
274
+ </div>
275
+ <div id="answerText" class="answer-text"></div>
276
+ </div>
277
+
278
+ <div class="sources-list">
279
+ <div class="section-title">
280
+ <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"><path d="M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z"/></svg>
281
+ Reference Sources
282
+ </div>
283
+ <div id="sourcesGrid" class="sources-grid"></div>
284
+ </div>
285
+ </div>
286
+ </div>
287
+
288
+ <script>
289
+ const input = document.getElementById('questionInput');
290
+ const searchBtn = document.getElementById('searchBtn');
291
+ const loading = document.getElementById('loading');
292
+ const results = document.getElementById('results');
293
+ const answerText = document.getElementById('answerText');
294
+ const sourcesGrid = document.getElementById('sourcesGrid');
295
+
296
+ // Allow Enter key to submit
297
+ input.addEventListener('keypress', function(e) {
298
+ if (e.key === 'Enter') {
299
+ askQuestion();
300
+ }
301
+ });
302
+
303
+ async function askQuestion() {
304
+ const question = input.value.trim();
305
+ if (!question) return;
306
+
307
+ // UI State updates
308
+ searchBtn.disabled = true;
309
+ input.disabled = true;
310
+ results.style.display = 'none';
311
+ loading.style.display = 'block';
312
+
313
+ try {
314
+ const response = await fetch('/query', {
315
+ method: 'POST',
316
+ headers: {
317
+ 'Content-Type': 'application/json',
318
+ },
319
+ body: JSON.stringify({
320
+ question: question,
321
+ top_k: 5
322
+ })
323
+ });
324
+
325
+ if (!response.ok) {
326
+ throw new Error('Failed to get response');
327
+ }
328
+
329
+ const data = await response.json();
330
+
331
+ // Display results
332
+ answerText.textContent = data.answer;
333
+
334
+ // Clear and populate sources
335
+ sourcesGrid.innerHTML = '';
336
+ data.sources.forEach(source => {
337
+ const card = document.createElement('div');
338
+ card.className = 'source-card';
339
+ card.innerHTML = `
340
+ <div class="source-title">${source.metadata.title || 'Untitled Document'}</div>
341
+ <div class="source-meta">
342
+ ${source.metadata.journal || 'Unknown Journal'} • ${source.metadata.year || 'N/A'}
343
+ </div>
344
+ <div class="source-excerpt">"...${source.text}..."</div>
345
+ `;
346
+ sourcesGrid.appendChild(card);
347
+ });
348
+
349
+ results.style.display = 'block';
350
+
351
+ } catch (error) {
352
+ alert('Error querying the system. Please try again.');
353
+ console.error(error);
354
+ } finally {
355
+ loading.style.display = 'none';
356
+ searchBtn.disabled = false;
357
+ input.disabled = false;
358
+ input.focus();
359
+ }
360
+ }
361
+ </script>
362
+ </body>
363
+ </html>