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.

feat: add embedding settings page and improve document indexing

LearningCircuitb5c811044fa9
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 7fb9fd85ce..574749d0a4 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -63,6 +63,15 @@ def rag_manager_page():
return render_template("pages/rag_manager.html")
+@rag_bp.route("/embedding-settings")
+@login_required
+def embedding_settings_page():
+ """Render the Embedding Settings page."""
+ return render_template(
+ "pages/embedding_settings.html", active_page="embedding-settings"
+ )
+
+
@rag_bp.route("/collections")
@login_required
def collections_page():
@@ -1432,6 +1441,8 @@ def index_collection(collection_id):
)
db_session.commit()
+ # Ensure all changes are written to disk
+ db_session.flush()
yield f"data: {json.dumps({'type': 'complete', 'results': results})}\n\n"
diff --git a/src/local_deep_research/research_library/services/library_rag_service.py b/src/local_deep_research/research_library/services/library_rag_service.py
index 73b189d30b..79c3e2f271 100644
--- a/src/local_deep_research/research_library/services/library_rag_service.py
+++ b/src/local_deep_research/research_library/services/library_rag_service.py
@@ -875,7 +875,7 @@ class LibraryRAGService:
# Load or create FAISS index
if self.faiss_index is None:
- self.faiss_index = self._load_or_create_faiss_index()
+ self.faiss_index = self.load_or_create_faiss_index()
# Add embeddings to FAISS index
self.faiss_index.add_documents(chunks, ids=embedding_ids)
@@ -972,7 +972,7 @@ class LibraryRAGService:
# Load or create FAISS index for this collection
if self.faiss_index is None:
- self.faiss_index = self._load_or_create_faiss_index()
+ self.faiss_index = self.load_or_create_faiss_index()
# If force_reindex, remove old chunks from FAISS before adding new ones
if force_reindex:
@@ -1093,7 +1093,7 @@ class LibraryRAGService:
# Load FAISS index if not already loaded
if self.faiss_index is None:
- self.faiss_index = self._load_or_create_faiss_index()
+ self.faiss_index = self.load_or_create_faiss_index()
# Remove from FAISS index
if hasattr(self.faiss_index, "delete"):
diff --git a/src/local_deep_research/web/static/css/collection_details.css b/src/local_deep_research/web/static/css/collection_details.css
index 646fd5475b..5b00b1a7a9 100644
--- a/src/local_deep_research/web/static/css/collection_details.css
+++ b/src/local_deep_research/web/static/css/collection_details.css
@@ -997,3 +997,47 @@
background: #667eea !important;
color: white !important;
}
+
+/* Embedding Settings Card */
+.ldr-embedding-settings-card {
+ background: rgba(255, 255, 255, 0.1);
+ border-radius: 12px;
+ padding: 20px;
+ border: 1px solid rgba(255, 255, 255, 0.2);
+ backdrop-filter: blur(10px);
+}
+
+.ldr-embedding-info h4 {
+ color: #2d3748;
+ margin-bottom: 15px;
+ font-size: 1.2rem;
+ font-weight: 600;
+}
+
+.ldr-embedding-info .ldr-info-box {
+ background: rgba(255, 255, 255, 0.8);
+ padding: 15px;
+ border-radius: 8px;
+ border-left: 4px solid #667eea;
+ margin-bottom: 15px;
+}
+
+.ldr-embedding-info .ldr-info-item {
+ display: flex;
+ justify-content: space-between;
+ padding: 8px 0;
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
+}
+
+.ldr-embedding-info .ldr-info-item:last-child {
+ border-bottom: none;
+}
+
+.ldr-embedding-info .ldr-info-label {
+ font-weight: 600;
+ color: #4a5568;
+}
+
+.ldr-embedding-info .ldr-info-value {
+ color: #2d3748;
+}
diff --git a/src/local_deep_research/web/static/js/collection_details.js b/src/local_deep_research/web/static/js/collection_details.js
index b6be3c72e1..cd884ec22d 100644
--- a/src/local_deep_research/web/static/js/collection_details.js
+++ b/src/local_deep_research/web/static/js/collection_details.js
@@ -25,6 +25,7 @@ async function safeFetch(url, options = {}) {
*/
document.addEventListener('DOMContentLoaded', function() {
loadCollectionDetails();
+ loadDefaultEmbeddingSettings();
// Setup button handlers
document.getElementById('index-collection-btn').addEventListener('click', () => indexCollection(false));
@@ -77,6 +78,78 @@ function updateStatistics() {
document.getElementById('stat-total-chunks').textContent = totalChunks;
}
+/**
+ * Load default embedding settings
+ */
+async function loadDefaultEmbeddingSettings() {
+ try {
+ const response = await safeFetch('/library/api/rag/settings');
+ const data = await response.json();
+
+ if (data.success && data.settings) {
+ const settings = data.settings;
+ const infoContainer = document.getElementById('default-embedding-info');
+
+ infoContainer.innerHTML = `
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Provider:</span>
+ <span class="ldr-info-value">${getProviderLabel(settings.embedding_provider)}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Model:</span>
+ <span class="ldr-info-value">${getModelLabel(settings.embedding_model, settings.embedding_provider)}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Chunk Size:</span>
+ <span class="ldr-info-value">${settings.chunk_size} characters</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Chunk Overlap:</span>
+ <span class="ldr-info-value">${settings.chunk_overlap} characters</span>
+ </div>
+ `;
+ } else {
+ document.getElementById('default-embedding-info').innerHTML = `
+ <div class="ldr-alert ldr-alert-warning">
+ <i class="fas fa-exclamation-triangle"></i> No default embedding settings configured
+ </div>
+ `;
+ }
+ } catch (error) {
+ console.error('Error loading default embedding settings:', error);
+ document.getElementById('default-embedding-info').innerHTML = `
+ <div class="ldr-alert ldr-alert-danger">
+ <i class="fas fa-exclamation-triangle"></i> Failed to load default settings
+ </div>
+ `;
+ }
+}
+
+/**
+ * Get provider label (simplified version)
+ */
+function getProviderLabel(providerValue) {
+ const providerMap = {
+ 'sentence_transformers': 'Sentence Transformers',
+ 'ollama': 'Ollama',
+ 'openai': 'OpenAI',
+ 'anthropic': 'Anthropic',
+ 'cohere': 'Cohere'
+ };
+ return providerMap[providerValue] || providerValue || 'Not configured';
+}
+
+/**
+ * Get model label (simplified version)
+ */
+function getModelLabel(modelValue, provider) {
+ if (!modelValue) return 'Not configured';
+ if (provider === 'ollama' && modelValue.includes(':')) {
+ return modelValue.split(':')[0];
+ }
+ return modelValue;
+}
+
/**
* Render documents list
*/
@@ -205,7 +278,7 @@ async function indexCollection(forceReindex) {
setTimeout(() => {
loadCollectionDetails();
progressSection.style.display = 'none';
- }, 3000);
+ }, 5000);
} else if (data.type === 'error') {
console.log('❌ Indexing error:', data.error);
addLogEntry(`Error: ${data.error}`, 'error');
diff --git a/src/local_deep_research/web/static/js/embedding_settings.js b/src/local_deep_research/web/static/js/embedding_settings.js
new file mode 100644
index 0000000000..b6947f4b9a
--- /dev/null
+++ b/src/local_deep_research/web/static/js/embedding_settings.js
@@ -0,0 +1,499 @@
+/**
+ * Embedding Settings JavaScript
+ * Handles the embedding configuration UI and API calls
+ */
+
+// Available providers and models loaded from API
+let providerOptions = [];
+let availableModels = {};
+let currentSettings = null;
+
+/**
+ * Safe fetch wrapper with URL validation
+ */
+async function safeFetch(url, options = {}) {
+ // Internal URLs starting with '/' are safe
+ if (!url.startsWith('/')) {
+ if (!URLValidator.isSafeUrl(url)) {
+ throw new Error(`Blocked unsafe URL: ${url}`);
+ }
+ }
+ return fetch(url, options);
+}
+
+
+/**
+ * Initialize the page
+ */
+document.addEventListener('DOMContentLoaded', function() {
+ // Load available models first, then settings
+ loadAvailableModels().then(() => {
+ // After models are loaded, load current settings
+ loadCurrentSettings();
+ });
+
+ loadCurrentIndexInfo();
+
+ // Setup provider change handler
+ document.getElementById('embedding-provider').addEventListener('change', function() {
+ updateModelOptions();
+ });
+
+ // Setup model change handler
+ document.getElementById('embedding-model').addEventListener('change', updateModelDescription);
+
+ // Setup config form submission
+ document.getElementById('rag-config-form').addEventListener('submit', handleConfigSubmit);
+});
+
+/**
+ * Load available embedding providers and models
+ */
+async function loadAvailableModels() {
+ try {
+ const response = await safeFetch('/library/api/rag/models');
+ const data = await response.json();
+
+ if (data.success) {
+ providerOptions = data.provider_options || [];
+ availableModels = data.providers || {};
+
+ // Populate provider dropdown
+ populateProviders();
+
+ // Update models for current provider (don't select yet, wait for settings)
+ updateModelOptions();
+
+ // Update provider information
+ updateProviderInfo();
+ } else {
+ showError('Failed to load available models: ' + data.error);
+ }
+ } catch (error) {
+ console.error('Error loading models:', error);
+ showError('Failed to load available models');
+ }
+}
+
+/**
+ * Load current RAG settings from database
+ */
+async function loadCurrentSettings() {
+ try {
+ const response = await safeFetch('/library/api/rag/settings');
+ const data = await response.json();
+
+ if (data.success && data.settings) {
+ currentSettings = data.settings;
+ const settings = data.settings;
+
+ // Set provider
+ const providerSelect = document.getElementById('embedding-provider');
+ if (settings.embedding_provider) {
+ providerSelect.value = settings.embedding_provider;
+ }
+
+ // Update models for this provider
+ updateModelOptions();
+
+ // Set model
+ const modelSelect = document.getElementById('embedding-model');
+ if (settings.embedding_model) {
+ modelSelect.value = settings.embedding_model;
+ updateModelDescription();
+ }
+
+ // Set chunk size and overlap
+ if (settings.chunk_size) {
+ document.getElementById('chunk-size').value = settings.chunk_size;
+ }
+ if (settings.chunk_overlap) {
+ document.getElementById('chunk-overlap').value = settings.chunk_overlap;
+ }
+ }
+ } catch (error) {
+ console.error('Error loading current settings:', error);
+ // Don't show error to user - just use defaults
+ }
+}
+
+/**
+ * Populate provider dropdown
+ */
+function populateProviders() {
+ const providerSelect = document.getElementById('embedding-provider');
+ const currentValue = providerSelect.value;
+
+ // Clear existing options
+ providerSelect.innerHTML = '';
+
+ // Add provider options
+ providerOptions.forEach(provider => {
+ const option = document.createElement('option');
+ option.value = provider.value;
+ option.textContent = provider.label;
+ providerSelect.appendChild(option);
+ });
+
+ // Restore previous value if it exists
+ if (currentValue && Array.from(providerSelect.options).some(opt => opt.value === currentValue)) {
+ providerSelect.value = currentValue;
+ } else if (providerSelect.options.length > 0) {
+ providerSelect.value = providerSelect.options[0].value;
+ }
+}
+
+/**
+ * Update model dropdown based on selected provider
+ */
+function updateModelOptions() {
+ const provider = document.getElementById('embedding-provider').value;
+ const modelSelect = document.getElementById('embedding-model');
+ const descriptionSpan = document.getElementById('model-description');
+
+ // Clear existing options
+ modelSelect.innerHTML = '';
+
+ // Add models for selected provider
+ const models = availableModels[provider] || [];
+ models.forEach(modelData => {
+ const option = document.createElement('option');
+ option.value = modelData.value;
+ option.textContent = modelData.label;
+ modelSelect.appendChild(option);
+ });
+
+ // Update description for first model
+ updateModelDescription();
+
+ // Add change handler for model selection (remove old handler first)
+ modelSelect.removeEventListener('change', updateModelDescription);
+ modelSelect.addEventListener('change', updateModelDescription);
+}
+
+/**
+ * Update model description text
+ */
+function updateModelDescription() {
+ const provider = document.getElementById('embedding-provider').value;
+ const modelSelect = document.getElementById('embedding-model');
+ const descriptionSpan = document.getElementById('model-description');
+
+ // Get selected model's label which contains the description
+ const selectedOption = modelSelect.options[modelSelect.selectedIndex];
+ if (selectedOption) {
+ // Extract description from label (after the dash)
+ const label = selectedOption.textContent;
+ const parts = label.split(' - ');
+ if (parts.length > 1) {
+ descriptionSpan.textContent = parts.slice(1).join(' - ');
+ } else {
+ descriptionSpan.textContent = '';
+ }
+ } else {
+ descriptionSpan.textContent = '';
+ }
+}
+
+/**
+ * Update provider information display
+ */
+function updateProviderInfo() {
+ const providerInfo = document.getElementById('provider-info');
+
+ let infoHTML = '';
+
+ providerOptions.forEach(provider => {
+ const providerKey = provider.value;
+ const models = availableModels[providerKey] || [];
+
+ infoHTML += `
+ <div class="ldr-stat-card">
+ <h4>${provider.label}</h4>
+ <p><strong>Models Available:</strong> ${models.length}</p>
+ <p><strong>Status:</strong> <span class="provider-status">Available</span></p>
+ <div class="provider-status">
+ <i class="fas fa-check-circle"></i> Ready
+ </div>
+ </div>
+ `;
+ });
+
+ providerInfo.innerHTML = infoHTML;
+}
+
+/**
+ * Load current index information
+ */
+async function loadCurrentIndexInfo() {
+ const infoContainer = document.getElementById('current-index-info');
+
+ try {
+ const response = await safeFetch('/library/api/rag/info');
+ const data = await response.json();
+
+ if (data.success) {
+ if (data.info) {
+ renderIndexInfo(data.info);
+ } else {
+ infoContainer.innerHTML = `
+ <div class="ldr-alert ldr-alert-info">
+ <i class="fas fa-info-circle"></i> No RAG index exists yet. Configure settings and index documents to get started.
+ </div>
+ `;
+ }
+ } else {
+ infoContainer.innerHTML = `
+ <div class="ldr-alert ldr-alert-danger">
+ Error loading index info: ${data.error}
+ </div>
+ `;
+ }
+ } catch (error) {
+ console.error('Error loading index info:', error);
+ infoContainer.innerHTML = `
+ <div class="ldr-alert ldr-alert-danger">
+ Failed to load index information
+ </div>
+ `;
+ }
+}
+
+/**
+ * Render index information
+ */
+function renderIndexInfo(info) {
+ const infoContainer = document.getElementById('current-index-info');
+
+ infoContainer.innerHTML = `
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Embedding Model:</span>
+ <span class="ldr-info-value">${info.embedding_model}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Provider:</span>
+ <span class="ldr-info-value">${info.embedding_model_type}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Vector Dimension:</span>
+ <span class="ldr-info-value">${info.embedding_dimension}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Chunk Size:</span>
+ <span class="ldr-info-value">${info.chunk_size} characters</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Chunk Overlap:</span>
+ <span class="ldr-info-value">${info.chunk_overlap} characters</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Total Chunks:</span>
+ <span class="ldr-info-value">${info.chunk_count}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Documents:</span>
+ <span class="ldr-info-value">${info.total_documents}</span>
+ </div>
+ <div class="ldr-info-item">
+ <span class="ldr-info-label">Last Updated:</span>
+ <span class="ldr-info-value">${new Date(info.last_updated_at).toLocaleString()}</span>
+ </div>
+ `;
+}
+
+
+
+/**
+ * Handle configuration form submission
+ */
+async function handleConfigSubmit(event) {
+ event.preventDefault();
+ console.log('🚀 Configuration form submitted!');
+
+ const formData = {
+ embedding_provider: document.getElementById('embedding-provider').value,
+ embedding_model: document.getElementById('embedding-model').value,
+ chunk_size: parseInt(document.getElementById('chunk-size').value),
+ chunk_overlap: parseInt(document.getElementById('chunk-overlap').value)
+ };
+
+ console.log('📋 Form data:', formData);
+
+ // Validation
+ if (!formData.embedding_provider) {
+ console.error('❌ No provider selected');
+ showError('Please select an embedding provider');
+ return;
+ }
+
+ if (!formData.embedding_model) {
+ console.error('❌ No model selected');
+ showError('Please select an embedding model');
+ return;
+ }
+
+ if (formData.chunk_size < 100 || formData.chunk_size > 5000) {
+ console.error('❌ Invalid chunk size:', formData.chunk_size);
+ showError('Chunk size must be between 100 and 5000 characters');
+ return;
+ }
+
+ if (formData.chunk_overlap < 0 || formData.chunk_overlap > 1000) {
+ console.error('❌ Invalid chunk overlap:', formData.chunk_overlap);
+ showError('Chunk overlap must be between 0 and 1000 characters');
+ return;
+ }
+
+ console.log('✅ Form validation passed');
+
+ try {
+ const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
+ console.log('🔐 CSRF Token:', csrfToken ? 'Found' : 'Not found');
+
+ const response = await safeFetch('/library/api/rag/configure', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfToken
+ },
+ body: JSON.stringify(formData)
+ });
+
+ console.log('📡 Response status:', response.status);
+ const responseText = await response.text();
+ console.log('📄 Response text:', responseText);
+
+ let data;
+ try {
+ data = JSON.parse(responseText);
+ } catch (parseError) {
+ console.error('❌ Failed to parse JSON:', parseError);
+ console.error('❌ Response was:', responseText);
+ showError('Server returned invalid response. Check console for details.');
+ return;
+ }
+
+ if (data.success) {
+ console.log('✅ Default settings saved successfully!');
+ showSuccess('Default embedding settings saved successfully! New collections will use these settings.');
+ currentSettings = formData;
+ loadCurrentIndexInfo();
+ } else {
+ console.error('❌ Server returned error:', data.error);
+ showError('Failed to save default settings: ' + data.error);
+ }
+ } catch (error) {
+ console.error('❌ Error updating configuration:', error);
+ showError('Failed to save configuration: ' + error.message);
+ }
+}
+
+/**
+ * Refresh configuration
+ */
+async function refreshConfiguration() {
+ showInfo('Refreshing configuration...');
+ await loadCurrentSettings();
+ await loadCurrentIndexInfo();
+ showSuccess('Configuration refreshed');
+}
+
+/**
+ * Test configuration
+ */
+async function testConfiguration() {
+ const provider = document.getElementById('embedding-provider').value;
+ const model = document.getElementById('embedding-model').value;
+
+ if (!provider || !model) {
+ showError('Please configure embedding settings first');
+ return;
+ }
+
+ showInfo('Testing embedding configuration...');
+
+ try {
+ // Test by trying to get index info (this will create/validate the index)
+ const response = await safeFetch('/library/api/rag/info');
+ const data = await response.json();
+
+ if (data.success) {
+ showSuccess('Configuration test passed! Embedding is working correctly.');
+ } 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.');
+ }
+ } catch (error) {
+ console.error('Error testing configuration:', error);
+ showError('Configuration test failed');
+ }
+}
+
+/**
+ * Show success message
+ */
+function showSuccess(message) {
+ const alertDiv = document.createElement('div');
+ alertDiv.className = 'ldr-alert ldr-alert-success';
+ alertDiv.innerHTML = `<i class="fas fa-check-circle"></i>${message}`;
+
+ // Insert at the top of the container
+ const container = document.querySelector('.ldr-library-container');
+ container.insertBefore(alertDiv, container.firstChild);
+
+ // Auto-remove after 5 seconds
+ setTimeout(() => {
+ if (alertDiv.parentNode) {
+ alertDiv.parentNode.removeChild(alertDiv);
+ }
+ }, 5000);
+}
+
+/**
+ * Show info message
+ */
+function showInfo(message) {
+ const alertDiv = document.createElement('div');
+ alertDiv.className = 'ldr-alert ldr-alert-info';
+ alertDiv.innerHTML = `<i class="fas fa-info-circle"></i>${message}`;
+
+ // Insert at the top of the container
+ const container = document.querySelector('.ldr-library-container');
+ container.insertBefore(alertDiv, container.firstChild);
+
+ // Auto-remove after 3 seconds
+ setTimeout(() => {
+ if (alertDiv.parentNode) {
+ alertDiv.parentNode.removeChild(alertDiv);
+ }
+ }, 3000);
+}
+
+/**
+ * Show error message
+ */
+function showError(message) {
+ const alertDiv = document.createElement('div');
+ alertDiv.className = 'ldr-alert ldr-alert-danger';
+ alertDiv.innerHTML = `<i class="fas fa-exclamation-triangle"></i>${message}`;
+
+ // Insert at the top of the container
+ const container = document.querySelector('.ldr-library-container');
+ container.insertBefore(alertDiv, container.firstChild);
+
+ // Auto-remove after 5 seconds
+ setTimeout(() => {
+ if (alertDiv.parentNode) {
+ alertDiv.parentNode.removeChild(alertDiv);
+ }
+ }, 5000);
+}
+
+/**
+ * Escape HTML to prevent XSS
+ */
+function escapeHtml(text) {
+ const div = document.createElement('div');
+ div.textContent = text;
+ return div.innerHTML;
+}
diff --git a/src/local_deep_research/web/templates/components/sidebar.html b/src/local_deep_research/web/templates/components/sidebar.html
index 2ddbbfd537..397b3d5a52 100644
--- a/src/local_deep_research/web/templates/components/sidebar.html
+++ b/src/local_deep_research/web/templates/components/sidebar.html
@@ -31,6 +31,9 @@
<li {% if active_page == 'metrics' %}class="active"{% endif %} data-page="metrics">
<a href="{{ url_for('metrics.metrics_dashboard') }}"><i class="fas fa-chart-bar"></i> Metrics</a>
</li>
+ <li {% if active_page == 'embedding-settings' %}class="active"{% endif %} data-page="embedding-settings">
+ <a href="{{ url_for('rag.embedding_settings_page') }}"><i class="fas fa-brain"></i> Embedding Settings</a>
+ </li>
<li {% if active_page == 'settings' %}class="active"{% endif %} data-page="settings">
<a href="{{ url_for('settings.settings_page') }}"><i class="fas fa-cog"></i> Settings</a>
</li>
diff --git a/src/local_deep_research/web/templates/pages/collection_details.html b/src/local_deep_research/web/templates/pages/collection_details.html
index 65451a474c..55550229a2 100644
--- a/src/local_deep_research/web/templates/pages/collection_details.html
+++ b/src/local_deep_research/web/templates/pages/collection_details.html
@@ -67,6 +67,33 @@
</div>
</div>
+ <!-- Embedding Settings -->
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
+ <h2><i class="fas fa-brain"></i> Embedding Settings</h2>
+ </div>
+
+ <div class="ldr-embedding-settings-card">
+ <div class="ldr-embedding-info">
+ <h4>Current Default Settings</h4>
+ <div id="default-embedding-info" class="ldr-info-box">
+ <div class="ldr-loading-spinner">
+ <i class="fas fa-spinner fa-spin"></i> Loading default settings...
+ </div>
+ </div>
+ <p class="ldr-form-text ldr-text-muted">
+ <i class="fas fa-info-circle"></i> These are the default embedding settings that will be used for new collections.
+ Individual collections can have different embedding settings based on their specific needs (e.g., different languages or content types).
+ </p>
+ <div style="margin-top: 15px;">
+ <a href="/library/embedding-settings" class="ldr-btn-collections ldr-btn-collections-info">
+ <i class="fas fa-cog"></i> Configure Default Settings
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+
<!-- Indexing Progress -->
<div id="indexing-progress" class="ldr-rag-section" style="display: none;">
<div class="ldr-section-header">
diff --git a/src/local_deep_research/web/templates/pages/embedding_settings.html b/src/local_deep_research/web/templates/pages/embedding_settings.html
new file mode 100644
index 0000000000..e56b183d0b
--- /dev/null
+++ b/src/local_deep_research/web/templates/pages/embedding_settings.html
@@ -0,0 +1,473 @@
+{% extends "base.html" %}
+
+{% block title %}Embedding Settings{% endblock %}
+
+{% block content %}
+<div class="ldr-library-container">
+ <div class="ldr-library-header">
+ <h1>Default Embedding Settings</h1>
+ <p class="ldr-subtitle">Configure default embedding models for new collections and semantic search</p>
+ </div>
+
+ <!-- Configuration Panel -->
+ <div class="ldr-rag-config-panel">
+ <h2><i class="fas fa-cog"></i> Configuration</h2>
+
+ <div class="ldr-config-grid">
+ <!-- Current Default Settings -->
+ <div class="ldr-config-section">
+ <h3>Current Default Settings</h3>
+ <div id="current-index-info" class="ldr-info-box">
+ <div class="ldr-loading-spinner">
+ <i class="fas fa-spinner fa-spin"></i> Loading...
+ </div>
+ </div>
+ <p class="ldr-form-text ldr-text-muted">
+ <i class="fas fa-info-circle"></i> These settings will be used as defaults for new collections. Individual collections can override these settings when needed.
+ </p>
+ </div>
+
+ <!-- Default Embedding Configuration -->
+ <div class="ldr-config-section">
+ <h3>Default Embedding Configuration</h3>
+ <form id="rag-config-form">
+ <div class="ldr-form-group">
+ <label for="embedding-provider">Provider</label>
+ <select id="embedding-provider" class="ldr-form-control">
+ <option value="">Loading providers...</option>
+ </select>
+ </div>
+
+ <div class="ldr-form-group">
+ <label for="embedding-model">Model</label>
+ <select id="embedding-model" class="ldr-form-control">
+ <!-- Options loaded dynamically -->
+ </select>
+ <small class="ldr-form-text ldr-text-muted">
+ <span id="model-description"></span>
+ </small>
+ </div>
+
+ <div class="ldr-form-row">
+ <div class="ldr-form-group ldr-col-md-6">
+ <label for="chunk-size">Chunk Size</label>
+ <input type="number" id="chunk-size" class="ldr-form-control" value="1000" min="100" max="5000" step="100">
+ <small class="ldr-form-text ldr-text-muted">Characters per chunk</small>
+ </div>
+ <div class="ldr-form-group ldr-col-md-6">
+ <label for="chunk-overlap">Chunk Overlap</label>
+ <input type="number" id="chunk-overlap" class="ldr-form-control" value="200" min="0" max="1000" step="50">
+ <small class="ldr-form-text ldr-text-muted">Overlap between chunks</small>
+ </div>
+ </div>
+
+ <button type="submit" class="ldr-btn ldr-btn-primary">
+ <i class="fas fa-save"></i> Save Default Settings
+ </button>
+ <small class="ldr-form-text ldr-text-muted ldr-mt-2">
+ <i class="fas fa-info-circle"></i> These settings will be used as defaults for new collections. Existing collections will continue using their current settings unless re-indexed with new defaults.
+ </small>
+ </form>
+ </div>
+ </div>
+ </div>
+
+ <!-- Provider Information Panel -->
+ <div class="ldr-rag-stats-panel">
+ <h2><i class="fas fa-info-circle"></i> Provider Information</h2>
+ <div id="provider-info" class="ldr-stats-grid">
+ <div class="ldr-loading-spinner">
+ <i class="fas fa-spinner fa-spin"></i> Loading provider information...
+ </div>
+ </div>
+ </div>
+
+ <!-- Status Panel -->
+ <div class="ldr-rag-operations-panel">
+ <h2><i class="fas fa-check-circle"></i> Status</h2>
+
+ <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>
+ </div>
+ </div>
+</div>
+
+
+<style>
+.ldr-library-container {
+ padding: 20px;
+ max-width: 1400px;
+ margin: 0 auto;
+ background: var(--bg-primary, #1a1a1a);
+ min-height: 100vh;
+}
+
+.ldr-library-header {
+ margin-bottom: 30px;
+}
+
+.ldr-library-header h1 {
+ color: var(--text-primary, #e4e4e4);
+ font-size: 2em;
+ margin: 0 0 10px 0;
+}
+
+.ldr-library-header .ldr-subtitle {
+ color: var(--text-secondary, #999);
+ font-size: 1.1em;
+ margin-top: 10px;
+}
+
+.ldr-rag-config-panel,
+.ldr-rag-stats-panel,
+.ldr-rag-operations-panel,
+.ldr-rag-documents-panel {
+ background: var(--card-bg, #2a2a2a);
+ border-radius: 8px;
+ padding: 25px;
+ margin-bottom: 25px;
+ box-shadow: 0 2px 4px var(--shadow-color, rgba(0,0,0,0.3));
+ border: 1px solid var(--border-color, #333);
+}
+
+.ldr-rag-config-panel h2,
+.ldr-rag-stats-panel h2,
+.ldr-rag-operations-panel h2,
+.ldr-rag-documents-panel h2 {
+ margin-bottom: 20px;
+ color: var(--text-primary, #e4e4e4);
+ font-size: 1.5em;
+}
+
+.ldr-config-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 30px;
+}
+
+@media (max-width: 992px) {
+ .ldr-config-grid {
+ grid-template-columns: 1fr;
+ }
+}
+
+.ldr-config-section {
+ background: var(--input-bg, #1a1a1a);
+ padding: 20px;
+ border-radius: 6px;
+ border: 1px solid var(--border-color, #444);
+}
+
+.ldr-config-section h3 {
+ margin-bottom: 15px;
+ font-size: 1.2em;
+ color: var(--text-primary, #e4e4e4);
+}
+
+.ldr-info-box {
+ background: var(--card-bg, #2a2a2a);
+ padding: 15px;
+ border-radius: 4px;
+ border-left: 4px solid var(--primary-color, #007bff);
+}
+
+.ldr-info-box .ldr-alert {
+ margin: 0;
+ padding: 12px;
+}
+
+.ldr-info-box:has(.ldr-alert) {
+ background: transparent;
+ padding: 0;
+ border: none;
+}
+
+.ldr-info-box .ldr-info-item {
+ display: flex;
+ justify-content: space-between;
+ padding: 8px 0;
+ border-bottom: 1px solid var(--border-color, #444);
+}
+
+.ldr-info-box .ldr-info-item:last-child {
+ border-bottom: none;
+}
+
+.ldr-info-box .ldr-info-label {
+ font-weight: 600;
+ color: var(--text-secondary, #999);
+}
+
+.ldr-info-box .ldr-info-value {
+ color: var(--text-primary, #e4e4e4);
+}
+
+.ldr-stats-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ gap: 20px;
+}
+
+.ldr-stat-card {
+ background: var(--input-bg, #1a1a1a);
+ padding: 20px;
+ border-radius: 6px;
+ text-align: center;
+ border-left: 4px solid var(--success-color, #28a745);
+ border: 1px solid var(--border-color, #444);
+}
+
+.ldr-stat-card.ldr-warning {
+ border-left-color: var(--warning-color, #ffc107);
+}
+
+.ldr-stat-card .ldr-stat-value {
+ font-size: 2.5em;
+ font-weight: bold;
+ color: var(--text-primary, #e4e4e4);
+ display: block;
+}
+
+.ldr-stat-card .ldr-stat-label {
+ color: var(--text-secondary, #999);
+ margin-top: 10px;
+ font-size: 0.9em;
+}
+
+.ldr-operations-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
+ gap: 20px;
+}
+
+
+/* Modal Styles */
+.ldr-modal {
+ position: fixed;
+ z-index: 1000;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.7);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.ldr-modal-content {
+ background: var(--card-bg, #2a2a2a);
+ border-radius: 8px;
+ width: 90%;
+ max-width: 500px;
+ max-height: 90vh;
+ overflow-y: auto;
+}
+
+.ldr-modal-large {
+ max-width: 800px;
+}
+
+.ldr-modal-header {
+ padding: 20px;
+ border-bottom: 1px solid var(--border-color, #444);
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.ldr-modal-close {
+ font-size: 28px;
+ font-weight: bold;
+ color: var(--text-secondary, #999);
+ cursor: pointer;
+}
+
+.ldr-modal-close:hover {
+ color: var(--text-primary, #e4e4e4);
+}
+
+.ldr-modal-body {
+ padding: 20px;
+}
+
+.ldr-modal-footer {
+ padding: 15px 20px;
+ border-top: 1px solid var(--border-color, #444);
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+}
+
+
+.ldr-mb-2 {
+ margin-bottom: 10px;
+}
+
+.ldr-mt-2 {
+ margin-top: 10px;
+}
+
+.ldr-mt-3 {
+ margin-top: 15px;
+}
+
+.ldr-form-row {
+ display: flex;
+ gap: 20px;
+ margin-bottom: 15px;
+}
+
+.ldr-col-md-6 {
+ flex: 1;
+}
+
+.ldr-mt-4 {
+ margin-top: 20px;
+}
+
+.ldr-loading-spinner {
+ text-align: center;
+ padding: 40px;
+ color: var(--text-secondary, #999);
+ font-size: 1.2em;
+}
+
+.ldr-log-container {
+ max-height: 300px;
+ overflow-y: auto;
+ background: var(--input-bg, #1a1a1a);
+ padding: 15px;
+ border-radius: 4px;
+ font-family: monospace;
+ font-size: 0.9em;
+ border: 1px solid var(--border-color, #444);
+}
+
+.ldr-log-entry {
+ padding: 5px 0;
+ border-bottom: 1px solid var(--border-color, #444);
+}
+
+.ldr-log-entry:last-child {
+ border-bottom: none;
+}
+
+.ldr-log-entry.ldr-success {
+ color: var(--success-color, #28a745);
+}
+
+.ldr-log-entry.ldr-error {
+ color: var(--danger-color, #dc3545);
+}
+
+.ldr-log-entry.ldr-info {
+ color: var(--info-color, #17a2b8);
+}
+
+.ldr-documents-list {
+ margin-top: 20px;
+}
+
+.ldr-filter-controls {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.ldr-document-item {
+ background: var(--input-bg, #1a1a1a);
+ padding: 15px;
+ margin-bottom: 10px;
+ border-radius: 6px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border: 1px solid var(--border-color, #444);
+}
+
+.ldr-document-info {
+ flex: 1;
+}
+
+.ldr-document-title {
+ font-weight: 600;
+ color: var(--text-primary, #e4e4e4);
+ margin-bottom: 5px;
+}
+
+.ldr-document-meta {
+ font-size: 0.9em;
+ color: var(--text-secondary, #999);
+}
+
+.ldr-document-actions {
+ display: flex;
+ gap: 10px;
+}
+
+.ldr-badge-indexed {
+ background: var(--success-color, #28a745);
+ color: white;
+ padding: 4px 8px;
+ border-radius: 4px;
+ font-size: 0.85em;
+}
+
+.ldr-badge-unindexed {
+ background: var(--secondary-color, #6c757d);
+ color: white;
+ padding: 4px 8px;
+ border-radius: 4px;
+ font-size: 0.85em;
+}
+
+.ldr-alert {
+ padding: 12px 16px;
+ margin-bottom: 10px;
+ border-radius: 4px;
+ border: 1px solid transparent;
+}
+
+.ldr-alert-info {
+ color: #0c5460;
+ background-color: #d1ecf1;
+ border-color: #bee5eb;
+}
+
+.ldr-alert-danger {
+ color: #721c24;
+ background-color: #f8d7da;
+ border-color: #f5c6cb;
+}
+
+.ldr-alert-success {
+ color: #155724;
+ background-color: #d4edda;
+ border-color: #c3e6cb;
+}
+
+.ldr-alert-warning {
+ color: #856404;
+ background-color: #fff3cd;
+ border-color: #ffeaa7;
+}
+
+.ldr-alert i {
+ margin-right: 8px;
+}
+
+.ldr-btn-sm {
+ padding: 4px 10px;
+ font-size: 0.85em;
+}
+</style>
+
+<script src="/static/js/security/url-validator.js"></script>
+<script src="/static/js/embedding_settings.js"></script>
+{% endblock %}