~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Enhance results page with research logs and fix API endpoints
hashedvikinged9181834563
diff --git a/src/local_deep_research/web/routes/history_routes.py b/src/local_deep_research/web/routes/history_routes.pyindex f09e289eae..3f0dcd4dd5 100644--- a/src/local_deep_research/web/routes/history_routes.py+++ b/src/local_deep_research/web/routes/history_routes.py@@ -234,6 +234,33 @@ def get_report(research_id):except Exception as e:return jsonify({"status": "error", "message": str(e)}), 500+@history_bp.route("/research/<int:research_id>/markdown")+def get_markdown(research_id):+ """Get markdown export for a specific research"""+ conn = get_db_connection()+ conn.row_factory = lambda cursor, row: {+ column[0]: row[idx] for idx, column in enumerate(cursor.description)+ }+ cursor = conn.cursor()+ cursor.execute("SELECT * FROM research_history WHERE id = ?", (research_id,))+ result = cursor.fetchone()+ conn.close()++ if not result or not result.get("report_path"):+ return jsonify({"status": "error", "message": "Report not found"}), 404++ try:+ with open(result["report_path"], "r", encoding="utf-8") as f:+ content = f.read()+ return jsonify(+ {+ "status": "success",+ "content": content+ }+ )+ except Exception as e:+ return jsonify({"status": "error", "message": str(e)}), 500+@history_bp.route("/research/<int:research_id>/logs")def get_research_logs(research_id):"""Get logs for a specific research ID"""diff --git a/src/local_deep_research/web/static/js/components/results.js b/src/local_deep_research/web/static/js/components/results.jsindex 8c593ec35c..d58c79b4b7 100644--- a/src/local_deep_research/web/static/js/components/results.js+++ b/src/local_deep_research/web/static/js/components/results.js@@ -6,6 +6,7 @@// Component statelet currentResearchId = null;let researchData = null;+ let researchLogs = [];// DOM Elementslet resultsContainer = null;@@ -13,6 +14,8 @@let exportPdfBtn = null;let exportMarkdownBtn = null;let backToHistoryBtn = null;+ let logsContainer = null;+ let logsTabs = null;/*** Initialize the results component@@ -36,6 +39,8 @@exportPdfBtn = document.getElementById('download-pdf-btn');exportMarkdownBtn = document.getElementById('export-markdown-btn');backToHistoryBtn = document.getElementById('back-to-history');+ logsContainer = document.getElementById('logs-container');+ logsTabs = document.querySelectorAll('.log-tab');if (!resultsContainer) {console.error('Required DOM elements not found for results component');@@ -48,6 +53,9 @@// Load research resultsloadResearchResults();+ // Load research logs+ loadResearchLogs();+console.log('Results component initialized for research ID:', currentResearchId);}@@ -84,6 +92,20 @@});}+ // Set up log tabs if they exist+ if (logsTabs) {+ logsTabs.forEach(tab => {+ tab.addEventListener('click', () => {+ const filterType = tab.dataset.type || 'all';+ filterLogs(filterType);++ // Update active tab+ logsTabs.forEach(t => t.classList.remove('active'));+ tab.classList.add('active');+ });+ });+ }+// Set up table of contents click eventsdocument.addEventListener('click', function(e) {if (e.target && e.target.matches('.toc-link')) {@@ -340,6 +362,94 @@}}+ /**+ * Load research logs from API+ */+ async function loadResearchLogs() {+ if (!currentResearchId || !logsContainer) return;++ try {+ // Get research logs+ const response = await window.api.getResearchLogs(currentResearchId);++ if (response && response.logs) {+ researchLogs = response.logs;+ renderLogs(researchLogs);+ }+ } catch (error) {+ console.error('Error loading research logs:', error);+ if (logsContainer) {+ logsContainer.innerHTML = '<div class="error-message">Failed to load research logs.</div>';+ }+ }+ }++ /**+ * Render research logs+ * @param {Array} logs - The logs to render+ */+ function renderLogs(logs) {+ if (!logsContainer) return;++ if (!logs || logs.length === 0) {+ logsContainer.innerHTML = '<div class="empty-logs">No logs yet. Research logs will appear here as they occur.</div>';+ return;+ }++ const logItems = logs.map(log => {+ const type = log.type || 'info';+ const time = formatLogTime(log.time);+ const message = log.message || '';++ return `+ <div class="log-item log-${type}" data-type="${type}">+ <span class="log-time">${time}</span>+ <span class="log-message">${message}</span>+ </div>+ `;+ });++ logsContainer.innerHTML = logItems.join('');+ }++ /**+ * Format log timestamp+ * @param {string} timeStr - ISO timestamp+ * @returns {string} Formatted time+ */+ function formatLogTime(timeStr) {+ if (!timeStr) return '';++ try {+ const date = new Date(timeStr);+ return date.toLocaleTimeString(undefined, {+ hour: '2-digit',+ minute: '2-digit',+ second: '2-digit'+ });+ } catch (e) {+ return timeStr;+ }+ }++ /**+ * Filter logs by type+ * @param {string} filterType - The type to filter by+ */+ function filterLogs(filterType = 'all') {+ if (!logsContainer) return;++ const logItems = logsContainer.querySelectorAll('.log-item');++ logItems.forEach(item => {+ if (filterType === 'all' || item.dataset.type === filterType) {+ item.style.display = '';+ } else {+ item.style.display = 'none';+ }+ });+ }+// Initialize on DOM content loadedif (document.readyState === 'loading') {document.addEventListener('DOMContentLoaded', initializeResults);diff --git a/src/local_deep_research/web/templates/pages/results.html b/src/local_deep_research/web/templates/pages/results.htmlindex fe99e95082..d560f37ab7 100644--- a/src/local_deep_research/web/templates/pages/results.html+++ b/src/local_deep_research/web/templates/pages/results.html@@ -6,16 +6,17 @@<div class="page active" id="research-results"><div class="page-header"><div class="results-header">- <h1>Research Results</h1>+ <h1 class="page-title">Research Results</h1><div class="results-actions"><button class="btn btn-outline" id="download-pdf-btn"><i class="fas fa-file-pdf"></i> Download PDF</button>+ <button class="btn btn-outline" id="export-markdown-btn"><i class="fas fa-file-alt"></i> Export Markdown</button><button class="btn btn-outline" id="back-to-history"><i class="fas fa-arrow-left"></i> Back to History</button></div></div></div><div class="card results-card"><div class="card-content">- <div class="results-metadata">+ <div class="results-metadata" id="research-metadata"><div class="metadata-item"><span class="metadata-label">Query:</span><span id="result-query" class="metadata-value"></span>@@ -37,10 +38,30 @@</div></div></div>++ <div class="card mt-4">+ <div class="card-header">+ <h3><i class="fas fa-history"></i> Research Logs</h3>+ <div class="tabs log-tabs">+ <button class="tab log-tab active" data-type="all">All</button>+ <button class="tab log-tab" data-type="info">Info</button>+ <button class="tab log-tab" data-type="milestone">Milestones</button>+ <button class="tab log-tab" data-type="error">Errors</button>+ </div>+ </div>+ <div class="card-content">+ <div id="logs-container" class="logs-container">+ <div class="empty-logs">No logs yet. Research logs will appear here as they occur.</div>+ </div>+ </div>+ </div></div>{% endblock %}{% block page_scripts %}+<script src="{{ url_for('research.serve_static', path='js/services/ui.js') }}"></script>+<script src="{{ url_for('research.serve_static', path='js/services/formatting.js') }}"></script>+<script src="{{ url_for('research.serve_static', path='js/services/api.js') }}"></script><script src="{{ url_for('research.serve_static', path='js/services/pdf.js') }}"></script><script src="{{ url_for('research.serve_static', path='js/components/results.js') }}"></script>{% endblock %}\ No newline at end of file