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.

fixing question and iteration display

LearningCircuitbe18b4a5229a
diff --git a/src/local_deep_research/web/static/js/research_form.js b/src/local_deep_research/web/static/js/research_form.js
new file mode 100644
index 0000000000..c0a20a64f7
--- /dev/null
+++ b/src/local_deep_research/web/static/js/research_form.js
@@ -0,0 +1,105 @@
+/**
+ * Research form handling with settings management
+ */
+
+document.addEventListener('DOMContentLoaded', function() {
+ // Initialize the research form
+ console.log('DOM loaded, initializing research form');
+ initResearchForm();
+});
+
+/**
+ * Initialize the research form with values from settings
+ */
+function initResearchForm() {
+ console.log('Initializing research form...');
+ // Get form elements
+ const iterationsInput = document.getElementById('iterations');
+ const questionsInput = document.getElementById('questions_per_iteration');
+
+ // Fetch all settings at once (more efficient)
+ fetch('/research/settings/all_settings')
+ .then(response => {
+ if (!response.ok) {
+ throw new Error('Failed to fetch settings');
+ }
+ return response.json();
+ })
+ .then(data => {
+ console.log('Loaded settings:', data);
+ if (data && data.status === 'success' && data.settings) {
+ // Find our specific settings
+ const settings = data.settings;
+
+ // Look for the research iterations setting
+ for (const setting of settings) {
+ if (setting.key === 'search.research_iterations' || setting.key === 'search.iterations') {
+ console.log('Found iterations setting:', setting.value);
+ iterationsInput.value = setting.value;
+ }
+
+ if (setting.key === 'search.questions_per_iteration') {
+ console.log('Found questions setting:', setting.value);
+ questionsInput.value = setting.value;
+ }
+ }
+ }
+ })
+ .catch(error => {
+ console.warn('Error loading research settings:', error);
+ // Form will use default values if settings can't be loaded
+ });
+
+ // Add our settings saving to the form submission process
+ patchFormSubmitHandler();
+}
+
+/**
+ * Patch the existing form submit handler to include our settings saving functionality
+ */
+function patchFormSubmitHandler() {
+ // Get the form element
+ const form = document.getElementById('research-form');
+ if (!form) return;
+
+ // Monitor for form submissions using the capture phase to run before other handlers
+ form.addEventListener('submit', function(event) {
+ // Save research settings first, before the main form handler processes the submission
+ saveResearchSettings();
+
+ // Let the event continue normally to the other handlers
+ }, true); // true enables capture phase
+}
+
+/**
+ * Save research settings to the database
+ */
+function saveResearchSettings() {
+ const iterations = document.getElementById('iterations').value;
+ const questions = document.getElementById('questions_per_iteration').value;
+
+ console.log('Saving research settings:', { iterations, questions });
+
+ // Get CSRF token
+ const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
+
+ // Save settings
+ fetch('/research/settings/save_all_settings', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfToken
+ },
+ body: JSON.stringify({
+ 'search.iterations': parseInt(iterations),
+ 'search.questions_per_iteration': parseInt(questions)
+ })
+ })
+ .then(response => response.json())
+ .then(data => {
+ console.log('Settings saved:', data);
+ })
+ .catch(error => {
+ console.warn('Error saving research settings:', error);
+ });
+}
diff --git a/src/local_deep_research/web/templates/pages/research.html b/src/local_deep_research/web/templates/pages/research.html
index 87fa7e6a19..d6c2453a45 100644
--- a/src/local_deep_research/web/templates/pages/research.html
+++ b/src/local_deep_research/web/templates/pages/research.html
@@ -136,4 +136,5 @@
{% block component_scripts %}
<script src="{{ url_for('research.serve_static', path='js/components/custom_dropdown.js') }}"></script>
<script src="{{ url_for('research.serve_static', path='js/components/research.js') }}"></script>
+<script src="{{ url_for('research.serve_static', path='js/research_form.js') }}"></script>
{% endblock %}