Update index.html

This commit is contained in:
Saifeddine ALOUI
2025-01-24 16:05:20 +01:00
committed by GitHub
parent 1f97745b93
commit 6e4668cec8

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LightRAG WebUI</title> <title>RAG WebUI</title>
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <!-- Include Marked.js --> <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <!-- Include Marked.js -->
</head> </head>
@@ -12,11 +12,11 @@
<!-- Settings Button --> <!-- Settings Button -->
<button id="settingsButton" class="absolute top-4 right-4 text-gray-600 hover:text-gray-800"> <button id="settingsButton" class="absolute top-4 right-4 text-gray-600 hover:text-gray-800">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c1.104 0 2-.896 2-2s-.896-2-2-2-2 .896-2 2 .896 2 2 2zm0 4c-1.104 0-2 .896-2 2s.896 2 2 2 2-.896 2-2-.896-2-2-2zm0 8c-1.104 0-2 .896-2 2s.896 2 2 2 2-.896 2-2-.896-2-2-2z" /> <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" />
</svg> </svg>
</button> </button>
<!-- Modal for Bearer Key --> <!-- Modal for Settings -->
<div id="settingsModal" class="hidden fixed inset-0 bg-gray-800 bg-opacity-50 flex items-center justify-center"> <div id="settingsModal" class="hidden fixed inset-0 bg-gray-800 bg-opacity-50 flex items-center justify-center">
<div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-md"> <div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-md">
<h2 class="text-lg font-semibold text-gray-700 mb-4">Settings</h2> <h2 class="text-lg font-semibold text-gray-700 mb-4">Settings</h2>
@@ -29,6 +29,22 @@
</div> </div>
</div> </div>
<!-- Health Check Button -->
<button id="healthCheckButton" class="absolute top-4 left-4 text-gray-600 hover:text-gray-800">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-3-3v6m-7 4a9 9 0 1118 0H5z" />
</svg>
</button>
<!-- Modal for Health Check -->
<div id="healthModal" class="hidden fixed inset-0 bg-gray-800 bg-opacity-50 flex items-center justify-center">
<div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-lg">
<h2 class="text-lg font-semibold text-gray-700 mb-4">System Health</h2>
<div id="healthInfo" class="text-sm text-gray-600"></div>
<button id="closeHealth" class="mt-4 bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600">Close</button>
</div>
</div>
<!-- Main Content --> <!-- Main Content -->
<h1 class="text-2xl font-bold text-gray-800 mb-4">RAG WebUI</h1> <h1 class="text-2xl font-bold text-gray-800 mb-4">RAG WebUI</h1>
@@ -73,27 +89,52 @@
settingsModal.classList.add('hidden'); settingsModal.classList.add('hidden');
}); });
// Bearer Key Handling // Health Check Modal Handling
const bearerKeyInput = document.getElementById('bearerKeyInput'); const healthCheckButton = document.getElementById('healthCheckButton');
const saveBearerKey = document.getElementById('saveBearerKey'); const healthModal = document.getElementById('healthModal');
const bearerKeyStatus = document.getElementById('bearerKeyStatus'); const closeHealth = document.getElementById('closeHealth');
const healthInfo = document.getElementById('healthInfo');
// Load Bearer Key from localStorage on page load healthCheckButton.addEventListener('click', async () => {
const storedBearerKey = localStorage.getItem('bearerKey'); healthModal.classList.remove('hidden');
if (storedBearerKey) { healthInfo.textContent = "Fetching system health...";
bearerKeyInput.value = storedBearerKey; try {
bearerKeyStatus.textContent = "Bearer Key loaded from local storage."; const response = await fetch('/health', {
method: 'GET',
headers: {
'Authorization': `Bearer ${localStorage.getItem('bearerKey') || ''}`
} }
});
// Save Bearer Key to localStorage if (response.ok) {
saveBearerKey.addEventListener('click', () => { const data = await response.json();
const key = bearerKeyInput.value.trim(); healthInfo.innerHTML = `
if (key) { <p><strong>Status:</strong> ${data.status}</p>
localStorage.setItem('bearerKey', key); <p><strong>Working Directory:</strong> ${data.working_directory}</p>
bearerKeyStatus.textContent = "Bearer Key saved successfully."; <p><strong>Input Directory:</strong> ${data.input_directory}</p>
<p><strong>Indexed Files:</strong> ${data.indexed_files}</p>
<p><strong>Configuration:</strong></p>
<ul class="list-disc ml-6">
<li><strong>LLM Binding:</strong> ${data.configuration.llm_binding}</li>
<li><strong>LLM Host:</strong> ${data.configuration.llm_binding_host}</li>
<li><strong>LLM Model:</strong> ${data.configuration.llm_model}</li>
<li><strong>Embedding Binding:</strong> ${data.configuration.embedding_binding}</li>
<li><strong>Embedding Host:</strong> ${data.configuration.embedding_binding_host}</li>
<li><strong>Embedding Model:</strong> ${data.configuration.embedding_model}</li>
<li><strong>Max Tokens:</strong> ${data.configuration.max_tokens}</li>
</ul>
`;
} else { } else {
bearerKeyStatus.textContent = "Please enter a valid Bearer Key."; const error = await response.json();
healthInfo.textContent = `Error: ${error.detail}`;
} }
} catch (err) {
healthInfo.textContent = `Error: ${err.message}`;
}
});
closeHealth.addEventListener('click', () => {
healthModal.classList.add('hidden');
}); });
// File Upload Handler // File Upload Handler