ParisNeo commited on
Commit
f656dda
·
unverified ·
1 Parent(s): 5d2ecbc

Update index.html

Browse files
Files changed (1) hide show
  1. lightrag/api/static/index.html +96 -47
lightrag/api/static/index.html CHANGED
@@ -3,75 +3,87 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>RAG WebUI</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <!-- Include Marked.js -->
 
 
 
 
 
 
9
  </head>
10
- <body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
11
- <div class="w-full max-w-4xl bg-white shadow-md rounded-lg p-6 relative">
12
  <!-- Settings Button -->
13
- <button id="settingsButton" class="absolute top-4 right-4 text-gray-600 hover:text-gray-800">
14
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
15
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 2a10 10 0 0110 10 10 10 0 01-10 10A10 10 0 012 12a10 10 0 0110-10zm0 2a8 8 0 100 16 8 8 0 000-16zm1 4h-2v4h2V8zm0 6h-2v2h2v-2z" />
 
16
  </svg>
17
  </button>
18
 
19
- <!-- Modal for Settings -->
20
- <div id="settingsModal" class="hidden fixed inset-0 bg-gray-800 bg-opacity-50 flex items-center justify-center">
21
- <div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-md">
22
- <h2 class="text-lg font-semibold text-gray-700 mb-4">Settings</h2>
23
- <div class="flex flex-col gap-4">
24
- <input type="text" id="bearerKeyInput" class="w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter Bearer Key">
25
- <button id="saveBearerKey" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">Save Key</button>
26
- <button id="closeSettings" class="text-gray-500 hover:text-gray-700 text-sm">Close</button>
27
- </div>
28
- <div id="bearerKeyStatus" class="mt-2 text-sm text-gray-600"></div>
29
- </div>
30
- </div>
31
-
32
  <!-- Health Check Button -->
33
- <button id="healthCheckButton" class="absolute top-4 left-4 text-gray-600 hover:text-gray-800">
34
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
35
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-3-3v6m-7 4a9 9 0 1118 0H5z" />
36
  </svg>
37
  </button>
38
 
39
- <!-- Modal for Health Check -->
40
- <div id="healthModal" class="hidden fixed inset-0 bg-gray-800 bg-opacity-50 flex items-center justify-center">
41
- <div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-lg">
42
- <h2 class="text-lg font-semibold text-gray-700 mb-4">System Health</h2>
43
- <div id="healthInfo" class="text-sm text-gray-600"></div>
44
- <button id="closeHealth" class="mt-4 bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600">Close</button>
45
- </div>
46
- </div>
47
-
48
  <!-- Main Content -->
49
- <h1 class="text-2xl font-bold text-gray-800 mb-4">RAG WebUI</h1>
 
 
 
50
 
51
  <!-- File Upload Section -->
52
- <div class="mb-6">
53
- <h2 class="text-lg font-semibold text-gray-700 mb-2">Upload Files</h2>
54
- <form id="uploadForm" class="flex flex-col gap-4">
55
- <input type="file" id="fileInput" multiple class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
56
- <button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">Upload</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  </form>
58
- <div id="uploadStatus" class="mt-2 text-sm text-gray-600"></div>
59
  <div id="progressContainer" class="mt-4 hidden">
60
- <div id="progressBar" class="w-full bg-gray-200 rounded h-4">
61
- <div class="bg-blue-500 h-4 rounded" style="width: 0%;"></div>
62
  </div>
63
  <p id="progressText" class="text-sm text-gray-600 mt-2"></p>
64
  </div>
65
  </div>
66
 
67
  <!-- Query Section -->
68
- <div class="mb-6">
69
- <h2 class="text-lg font-semibold text-gray-700 mb-2">Query</h2>
70
- <form id="queryForm" class="flex flex-col gap-4">
71
- <textarea id="queryInput" rows="4" class="w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter your query here..."></textarea>
72
- <button type="submit" class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">Submit Query</button>
 
 
 
 
 
 
 
73
  </form>
74
- <div id="queryResponse" class="mt-4 p-4 bg-gray-50 border rounded text-gray-700"></div>
75
  </div>
76
  </div>
77
 
@@ -140,6 +152,8 @@
140
  // File Upload Handler
141
  const uploadForm = document.getElementById('uploadForm');
142
  const fileInput = document.getElementById('fileInput');
 
 
143
  const uploadStatus = document.getElementById('uploadStatus');
144
  const progressContainer = document.getElementById('progressContainer');
145
  const progressBar = document.getElementById('progressBar').firstElementChild;
@@ -230,6 +244,41 @@
230
  queryResponse.textContent = `Error: ${err.message}`;
231
  }
232
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  </script>
234
  </body>
235
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>LightRag</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
9
+ <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
11
+ body {
12
+ font-family: 'Inter', sans-serif;
13
+ }
14
+ </style>
15
  </head>
16
+ <body class="bg-gray-50 min-h-screen flex flex-col items-center justify-center p-4">
17
+ <div class="w-full max-w-4xl bg-white shadow-lg rounded-xl p-8 relative">
18
  <!-- Settings Button -->
19
+ <button id="settingsButton" class="absolute top-6 right-6 text-gray-600 hover:text-gray-800 transition-colors">
20
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 24 24" fill="none" stroke="currentColor">
21
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
22
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15a3 3 0 100-6 3 3 0 000 6z"/>
23
  </svg>
24
  </button>
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  <!-- Health Check Button -->
27
+ <button id="healthCheckButton" class="absolute top-6 left-6 text-gray-600 hover:text-gray-800 transition-colors">
28
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 24 24" fill="none" stroke="currentColor">
29
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m-6-8h6M5 5h14a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2z"/>
30
  </svg>
31
  </button>
32
 
 
 
 
 
 
 
 
 
 
33
  <!-- Main Content -->
34
+ <div class="text-center mb-8">
35
+ <h1 class="text-3xl font-bold text-gray-900 mb-2">LightRag</h1>
36
+ <p class="text-gray-600">Lightweight RAG System Interface</p>
37
+ </div>
38
 
39
  <!-- File Upload Section -->
40
+ <div class="mb-8 bg-gray-50 p-6 rounded-lg">
41
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Document Upload</h2>
42
+ <form id="uploadForm" class="space-y-4">
43
+ <div class="flex items-center justify-center w-full">
44
+ <label class="flex flex-col items-center justify-center w-full h-32 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer bg-gray-50 hover:bg-gray-100 transition-colors">
45
+ <div class="flex flex-col items-center justify-center pt-5 pb-6">
46
+ <svg class="w-8 h-8 mb-4 text-gray-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
47
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/>
48
+ </svg>
49
+ <p class="mb-2 text-sm text-gray-500"><span class="font-semibold">Click to upload</span> or drag and drop</p>
50
+ <p class="text-xs text-gray-500">PDF, TXT, DOC, DOCX (MAX. 10MB)</p>
51
+ </div>
52
+ <input type="file" id="fileInput" class="hidden" multiple />
53
+ </label>
54
+ </div>
55
+
56
+ <!-- Selected Files Preview -->
57
+ <div id="selectedFiles" class="space-y-2"></div>
58
+
59
+ <button type="submit" class="w-full bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors">
60
+ Upload Documents
61
+ </button>
62
  </form>
63
+ <div id="uploadStatus" class="mt-4 text-sm text-gray-600"></div>
64
  <div id="progressContainer" class="mt-4 hidden">
65
+ <div class="w-full bg-gray-200 rounded-full h-2">
66
+ <div id="progressBar" class="bg-blue-600 h-2 rounded-full transition-all duration-300"></div>
67
  </div>
68
  <p id="progressText" class="text-sm text-gray-600 mt-2"></p>
69
  </div>
70
  </div>
71
 
72
  <!-- Query Section -->
73
+ <div class="bg-gray-50 p-6 rounded-lg">
74
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Query Documents</h2>
75
+ <form id="queryForm" class="space-y-4">
76
+ <textarea
77
+ id="queryInput"
78
+ rows="4"
79
+ class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all"
80
+ placeholder="Enter your query here..."
81
+ ></textarea>
82
+ <button type="submit" class="w-full bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 transition-colors">
83
+ Submit Query
84
+ </button>
85
  </form>
86
+ <div id="queryResponse" class="mt-6 p-4 bg-white border rounded-lg text-gray-700 prose max-w-none"></div>
87
  </div>
88
  </div>
89
 
 
152
  // File Upload Handler
153
  const uploadForm = document.getElementById('uploadForm');
154
  const fileInput = document.getElementById('fileInput');
155
+ const selectedFiles = document.getElementById('selectedFiles');
156
+
157
  const uploadStatus = document.getElementById('uploadStatus');
158
  const progressContainer = document.getElementById('progressContainer');
159
  const progressBar = document.getElementById('progressBar').firstElementChild;
 
244
  queryResponse.textContent = `Error: ${err.message}`;
245
  }
246
  });
247
+
248
+ // File preview functionality
249
+ fileInput.addEventListener('change', () => {
250
+ selectedFiles.innerHTML = '';
251
+ Array.from(fileInput.files).forEach((file, index) => {
252
+ const fileDiv = document.createElement('div');
253
+ fileDiv.className = 'flex items-center justify-between p-2 bg-white rounded border';
254
+ fileDiv.innerHTML = `
255
+ <span class="text-sm text-gray-600">${file.name} (${(file.size / 1024).toFixed(1)} KB)</span>
256
+ <button type="button" class="text-red-500 hover:text-red-700 transition-colors" data-index="${index}">
257
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
258
+ <path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" />
259
+ </svg>
260
+ </button>
261
+ `;
262
+ selectedFiles.appendChild(fileDiv);
263
+ });
264
+ });
265
+
266
+ // Remove file functionality
267
+ selectedFiles.addEventListener('click', (e) => {
268
+ if (e.target.closest('button')) {
269
+ const index = e.target.closest('button').dataset.index;
270
+ const dt = new DataTransfer();
271
+ const files = fileInput.files;
272
+
273
+ for (let i = 0; i < files.length; i++) {
274
+ if (i != index) dt.items.add(files[i]);
275
+ }
276
+
277
+ fileInput.files = dt.files;
278
+ e.target.closest('div').remove();
279
+ }
280
+ });
281
+
282
  </script>
283
  </body>
284
  </html>