Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: improve UI and functionality

LearningCircuitf7c234722254
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.py
index ccd387a557..8de4b34b7c 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -280,6 +280,61 @@ def get_current_settings():
), 500
+@rag_bp.route("/api/rag/test-embedding", methods=["POST"])
+@login_required
+def test_embedding():
+ """Test an embedding configuration by generating a test embedding."""
+ import time
+
+ try:
+ data = request.json
+ provider = data.get("provider")
+ model = data.get("model")
+ test_text = data.get("test_text", "This is a test.")
+
+ if not provider or not model:
+ return jsonify(
+ {"success": False, "error": "Provider and model are required"}
+ ), 400
+
+ # Import embedding functions
+ from ...embeddings.embeddings_config import (
+ get_embedding_function,
+ )
+
+ logger.info(
+ f"Testing embedding with provider={provider}, model={model}"
+ )
+
+ # Get embedding function with the specified configuration
+ start_time = time.time()
+ embedding_func = get_embedding_function(
+ provider=provider,
+ model_name=model,
+ )
+
+ # Generate test embedding
+ embedding = embedding_func([test_text])[0]
+ response_time_ms = int((time.time() - start_time) * 1000)
+
+ # Get embedding dimension
+ dimension = len(embedding) if hasattr(embedding, "__len__") else None
+
+ return jsonify(
+ {
+ "success": True,
+ "dimension": dimension,
+ "response_time_ms": response_time_ms,
+ "provider": provider,
+ "model": model,
+ }
+ )
+
+ except Exception as e:
+ logger.exception("Error testing embedding")
+ return jsonify({"success": False, "error": str(e)}), 500
+
+
@rag_bp.route("/api/rag/models", methods=["GET"])
@login_required
def get_available_models():
diff --git a/src/local_deep_research/web/static/css/document_details.css b/src/local_deep_research/web/static/css/document_details.css
index 291e305d84..ef18e97041 100644
--- a/src/local_deep_research/web/static/css/document_details.css
+++ b/src/local_deep_research/web/static/css/document_details.css
@@ -98,23 +98,7 @@
overflow: hidden;
}
-.ldr-btn::before {
- content: '';
- position: absolute;
- top: 0;
- left: -100%;
- width: 100%;
- height: 100%;
- background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
- transition: left 0.5s ease;
-}
-
-.ldr-btn:hover::before {
- left: 100%;
-}
-
.ldr-btn:hover {
- transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
@@ -178,12 +162,6 @@
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
animation: fadeInUp 0.8s ease-out;
- transition: transform 0.3s ease, box-shadow 0.3s ease;
-}
-
-.ldr-metadata-section:hover {
- transform: translateY(-2px);
- box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.ldr-metadata-section h2 {
@@ -217,13 +195,11 @@
background: linear-gradient(135deg, #f7fafc, #edf2f7);
border-radius: 12px;
border: 1px solid #e2e8f0;
- transition: all 0.3s ease;
+ transition: border-color 0.3s ease;
}
.ldr-metadata-item:hover {
- background: linear-gradient(135deg, #edf2f7, #e2e8f0);
border-color: #cbd5e0;
- transform: translateY(-1px);
}
.ldr-metadata-label {
diff --git a/src/local_deep_research/web/static/js/collections_manager.js b/src/local_deep_research/web/static/js/collections_manager.js
index 036dd7213a..997ea6931b 100644
--- a/src/local_deep_research/web/static/js/collections_manager.js
+++ b/src/local_deep_research/web/static/js/collections_manager.js
@@ -24,10 +24,16 @@ async function safeFetch(url, options = {}) {
document.addEventListener('DOMContentLoaded', function() {
loadCollections();
- // Setup modal handlers
- document.getElementById('create-collection-btn').addEventListener('click', showCreateCollectionModal);
- document.getElementById('create-collection-modal-form').addEventListener('submit', handleCreateCollection);
- document.getElementById('cancel-create-btn').addEventListener('click', hideCreateCollectionModal);
+ // Setup modal handlers (only if modal form exists)
+ const createCollectionModalForm = document.getElementById('create-collection-modal-form');
+ if (createCollectionModalForm) {
+ createCollectionModalForm.addEventListener('submit', handleCreateCollection);
+ }
+
+ const cancelCreateBtn = document.getElementById('cancel-create-btn');
+ if (cancelCreateBtn) {
+ cancelCreateBtn.addEventListener('click', hideCreateCollectionModal);
+ }
// Setup close buttons
document.querySelectorAll('.modal .ldr-close').forEach(btn => {
diff --git a/src/local_deep_research/web/static/js/embedding_settings.js b/src/local_deep_research/web/static/js/embedding_settings.js
index c47c20ce0d..cdc168b8e3 100644
--- a/src/local_deep_research/web/static/js/embedding_settings.js
+++ b/src/local_deep_research/web/static/js/embedding_settings.js
@@ -412,43 +412,77 @@ async function handleConfigSubmit(event) {
}
/**
- * Refresh configuration
- */
-async function refreshConfiguration() {
- showInfo('Refreshing configuration...');
- await loadCurrentSettings();
- await loadCurrentIndexInfo();
- showSuccess('Configuration refreshed');
-}
-
-/**
- * Test configuration
+ * Test configuration by sending a real embedding request
*/
async function testConfiguration() {
const provider = document.getElementById('embedding-provider').value;
const model = document.getElementById('embedding-model').value;
+ const testBtn = document.getElementById('test-config-btn');
+ const testResult = document.getElementById('test-result');
if (!provider || !model) {
- showError('Please configure embedding settings first');
+ showError('Please select a provider and model first');
return;
}
- showInfo('Testing embedding configuration...');
+ // Disable button during test
+ testBtn.disabled = true;
+ testBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Testing...';
+
+ testResult.style.display = 'block';
+ testResult.innerHTML = '<div class="ldr-alert ldr-alert-info"><i class="fas fa-spinner fa-spin"></i> Testing embedding model...</div>';
try {
- // Test by trying to get index info (this will create/validate the index)
- const response = await safeFetch('/library/api/rag/info');
+ const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
+
+ // Send test embedding request with selected configuration
+ const response = await safeFetch('/library/api/rag/test-embedding', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfToken
+ },
+ body: JSON.stringify({
+ provider: provider,
+ model: model,
+ test_text: 'This is a test sentence to verify the embedding model is working correctly.'
+ })
+ });
+
const data = await response.json();
if (data.success) {
- showSuccess('Configuration test passed! Embedding is working correctly.');
+ testResult.innerHTML = `
+ <div class="ldr-alert ldr-alert-success">
+ <i class="fas fa-check-circle"></i> <strong>Test Passed!</strong><br>
+ Model: ${model}<br>
+ Provider: ${provider}<br>
+ Embedding dimension: ${data.dimension}<br>
+ Response time: ${data.response_time_ms}ms
+ </div>
+ `;
+ showSuccess('Embedding test passed!');
} else {
- // If no index exists, that's okay - it means configuration is valid but no index has been created yet
- showInfo('Configuration is valid. Index will be created when documents are indexed.');
+ testResult.innerHTML = `
+ <div class="ldr-alert ldr-alert-danger">
+ <i class="fas fa-times-circle"></i> <strong>Test Failed!</strong><br>
+ Error: ${data.error || 'Unknown error'}
+ </div>
+ `;
+ showError('Embedding test failed: ' + (data.error || 'Unknown error'));
}
} catch (error) {
- console.error('Error testing configuration:', error);
- showError('Configuration test failed');
+ testResult.innerHTML = `
+ <div class="ldr-alert ldr-alert-danger">
+ <i class="fas fa-times-circle"></i> <strong>Test Failed!</strong><br>
+ Error: ${error.message}
+ </div>
+ `;
+ showError('Test failed: ' + error.message);
+ } finally {
+ // Re-enable button
+ testBtn.disabled = false;
+ testBtn.innerHTML = '<i class="fas fa-play"></i> Test Embedding Model';
}
}
diff --git a/src/local_deep_research/web/templates/pages/embedding_settings.html b/src/local_deep_research/web/templates/pages/embedding_settings.html
index 5b3e9d1e44..06f659d9f8 100644
--- a/src/local_deep_research/web/templates/pages/embedding_settings.html
+++ b/src/local_deep_research/web/templates/pages/embedding_settings.html
@@ -108,18 +108,22 @@
</div>
</div>
- <!-- Status Panel -->
+ <!-- Test Panel -->
<div class="ldr-rag-operations-panel">
- <h2><i class="fas fa-check-circle"></i> Status</h2>
+ <h2><i class="fas fa-vial"></i> Test Configuration</h2>
+ <p class="ldr-text-muted" style="margin-bottom: 15px;">
+ Test the currently selected embedding model to ensure it's working correctly.
+ </p>
<div class="ldr-operations-grid">
- <button class="ldr-btn ldr-btn-info ldr-btn-lg" onclick="refreshConfiguration()">
- <i class="fas fa-sync"></i> Refresh Configuration
- </button>
- <button class="ldr-btn ldr-btn-success ldr-btn-lg" onclick="testConfiguration()">
- <i class="fas fa-play"></i> Test Configuration
+ <button class="ldr-btn ldr-btn-success ldr-btn-lg" onclick="testConfiguration()" id="test-config-btn">
+ <i class="fas fa-play"></i> Test Embedding Model
</button>
</div>
+
+ <div id="test-result" style="margin-top: 15px; display: none;">
+ <!-- Test results will appear here -->
+ </div>
</div>
</div>