~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
integrate to agentico board
hashedviking9340b9d8b755
diff --git a/app.py b/app.pyindex ec489e533e..e41ef1edbd 100644--- a/app.py+++ b/app.py@@ -4,7 +4,7 @@ import timeimport sqlite3import threadingfrom datetime import datetime-from flask import Flask, render_template, request, jsonify, send_from_directory, Response, make_response+from flask import Flask, render_template, request, jsonify, send_from_directory, Response, make_response, current_app, Blueprint, redirect, url_forfrom flask_socketio import SocketIO, emitfrom search_system import AdvancedSearchSystemfrom report_generator import IntegratedReportGenerator@@ -12,20 +12,20 @@ from dateutil import parserimport traceback# Initialize Flask app-app = Flask(__name__, static_folder='static')+app = Flask(__name__, static_folder=os.path.abspath('static'))app.config['SECRET_KEY'] = 'deep-research-secret-key'+# Create a Blueprint for the research application+research_bp = Blueprint('research', __name__, url_prefix='/research')+# Add improved Socket.IO configuration with better error handlingsocketio = SocketIO(app,- cors_allowed_origins="*",- ping_timeout=60,- ping_interval=25,- async_mode='threading',- reconnection=True,- reconnection_attempts=5,- logger=True, # Enable logging- engineio_logger=True # Enable engine.io logging+ cors_allowed_origins="*",+ async_mode='threading',+ path='/research/socket.io',+ logger=True,+ engineio_logger=True)# Active research processes and socket subscriptions@@ -144,15 +144,27 @@ def initialize():# Call initialize immediately when app is createdinitialize()+# Route for index page - keep this at root level for easy access@app.route('/')+def root_index():+ return redirect(url_for('research.index'))++# Update all routes with the research prefix+@research_bp.route('/')def index():return render_template('index.html')[email protected]('/static/<path:path>')+@research_bp.route('/static/<path:path>')def serve_static(path):- return send_from_directory('static', path)+ try:+ print(f"Serving static file: {path}")+ print(f"Static folder path: {app.static_folder}")+ return send_from_directory(app.static_folder, path)+ except Exception as e:+ print(f"Error serving static file {path}: {str(e)}")+ return f"Error serving file: {str(e)}", 404[email protected]('/api/history', methods=['GET'])+@research_bp.route('/api/history', methods=['GET'])def get_history():"""Get the research history"""try:@@ -236,7 +248,7 @@ def get_history():response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')return response[email protected]('/api/start_research', methods=['POST'])+@research_bp.route('/api/start_research', methods=['POST'])def start_research():data = request.jsonquery = data.get('query')@@ -284,7 +296,7 @@ def start_research():'research_id': research_id})[email protected]('/api/research/<int:research_id>')+@research_bp.route('/api/research/<int:research_id>')def get_research_status(research_id):conn = sqlite3.connect(DB_PATH)conn.row_factory = sqlite3.Row@@ -315,7 +327,7 @@ def get_research_status(research_id):return jsonify(result)[email protected]('/api/research/<int:research_id>/details')+@research_bp.route('/api/research/<int:research_id>/details')def get_research_details(research_id):"""Get detailed progress log for a specific research"""conn = sqlite3.connect(DB_PATH)@@ -350,7 +362,7 @@ def get_research_details(research_id):'log': progress_log})[email protected]('/api/report/<int:research_id>')+@research_bp.route('/api/report/<int:research_id>')def get_report(research_id):conn = sqlite3.connect(DB_PATH)conn.row_factory = sqlite3.Row@@ -373,7 +385,7 @@ def get_report(research_id):except Exception as e:return jsonify({'status': 'error', 'message': str(e)}), 500[email protected]('/research/details/<int:research_id>')+@research_bp.route('/research/details/<int:research_id>')def research_details_page(research_id):"""Render the research details page"""return render_template('index.html')@@ -665,7 +677,7 @@ def run_research_process(research_id, query, mode):if research_id in termination_flags:del termination_flags[research_id][email protected]('/api/research/<int:research_id>/terminate', methods=['POST'])+@research_bp.route('/api/research/<int:research_id>/terminate', methods=['POST'])def terminate_research(research_id):"""Terminate an in-progress research process"""@@ -750,7 +762,7 @@ def terminate_research(research_id):return jsonify({'status': 'success', 'message': 'Research termination requested'})[email protected]('/api/research/<int:research_id>/delete', methods=['DELETE'])+@research_bp.route('/api/research/<int:research_id>/delete', methods=['DELETE'])def delete_research(research_id):"""Delete a research record"""conn = sqlite3.connect(DB_PATH)@@ -788,6 +800,19 @@ def delete_research(research_id):return jsonify({'status': 'success'})+# Register the blueprint+app.register_blueprint(research_bp)++# Also add the static route at the app level for compatibility[email protected]('/static/<path:path>')+def app_serve_static(path):+ return send_from_directory(app.static_folder, path)++# Add favicon route to prevent 404 errors[email protected]('/favicon.ico')+def favicon():+ return send_from_directory(app.static_folder, 'favicon.ico', mimetype='image/x-icon')+if __name__ == '__main__':# Set server name explicitly to avoid DNS resolution issues- socketio.run(app, debug=False, host='127.0.0.1', port=5000, allow_unsafe_werkzeug=True)\ No newline at end of file+ socketio.run(app, debug=False, host='0.0.0.0', port=5000, allow_unsafe_werkzeug=True)\ No newline at end of filediff --git a/static/css/styles.css b/static/css/styles.cssindex 2fddd9dca7..218f7898d3 100644--- a/static/css/styles.css+++ b/static/css/styles.css@@ -808,6 +808,34 @@ textarea:focus, input[type="text"]:focus {color: var(--text-primary);}+/* External link styling for sidebar and mobile navigation - more subtle */+.sidebar-nav ul li.external-link {+ color: var(--text-primary);+ border-left: 3px solid #607d8b;+ margin-bottom: 10px;+ padding-left: 17px;+ opacity: 0.75;+}++.sidebar-nav ul li.external-link:hover {+ background-color: rgba(96, 125, 139, 0.1);+ opacity: 1;+ cursor: pointer;+}++.mobile-tab-bar ul li.external-link {+ color: var(--text-primary);+ opacity: 0.75;+}++.mobile-tab-bar ul li.external-link i {+ color: var(--text-primary);+}++.mobile-tab-bar ul li.external-link:hover {+ opacity: 1;+}+/* Responsive */@media (max-width: 991px) {.sidebar {diff --git a/static/js/app.js b/static/js/app.jsindex afd4121254..d3da39082a 100644--- a/static/js/app.js+++ b/static/js/app.js@@ -2,12 +2,8 @@document.addEventListener('DOMContentLoaded', () => {// Initialize socket.io connection with proper error handling and reconnection optionsconst socket = io({- reconnection: true,- reconnectionAttempts: 5,- reconnectionDelay: 1000,- reconnectionDelayMax: 5000,- timeout: 20000,- autoConnect: true+ path: '/research/socket.io',+ transports: ['websocket', 'polling']});// Socket connection event handlers@@ -71,6 +67,12 @@ document.addEventListener('DOMContentLoaded', () => {setTimeout(() => loadResearchHistory(), 100);}+ // Add a prefix helper function at the top of the file+ function getApiUrl(path) {+ // This function adds the /research prefix to all API URLs+ return `/research${path}`;+ }+// Function to terminate research - exposed to window objectasync function terminateResearch(researchId) {if (!researchId) {@@ -110,7 +112,7 @@ document.addEventListener('DOMContentLoaded', () => {});// Call the terminate API- const response = await fetch(`/api/research/${researchId}/terminate`, {+ const response = await fetch(getApiUrl(`/api/research/${researchId}/terminate`), {method: 'POST'});@@ -275,7 +277,7 @@ document.addEventListener('DOMContentLoaded', () => {startResearchBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Starting...';try {- const response = await fetch('/api/start_research', {+ const response = await fetch(getApiUrl('/api/start_research'), {method: 'POST',headers: {'Content-Type': 'application/json'@@ -397,7 +399,7 @@ document.addEventListener('DOMContentLoaded', () => {function pollResearchStatus(researchId) {const interval = setInterval(async () => {try {- const response = await fetch(`/api/research/${researchId}`);+ const response = await fetch(getApiUrl(`/api/research/${researchId}`));const data = await response.json();if (data.status === 'completed' || data.status === 'failed' || data.status === 'suspended') {@@ -488,7 +490,7 @@ document.addEventListener('DOMContentLoaded', () => {try {// Basic fetch without any extras- const response = await fetch('/api/history');+ const response = await fetch(getApiUrl('/api/history'));if (!response.ok) {throw new Error(`API returned status ${response.status}: ${response.statusText}`);@@ -708,7 +710,7 @@ document.addEventListener('DOMContentLoaded', () => {// Function to delete a research recordasync function deleteResearch(researchId) {try {- const response = await fetch(`/api/research/${researchId}/delete`, {+ const response = await fetch(getApiUrl(`/api/research/${researchId}/delete`), {method: 'DELETE'});@@ -734,7 +736,7 @@ document.addEventListener('DOMContentLoaded', () => {try {// Load research details- const detailsResponse = await fetch(`/api/research/${researchId}`);+ const detailsResponse = await fetch(getApiUrl(`/api/research/${researchId}`));const details = await detailsResponse.json();// Display metadata@@ -762,7 +764,7 @@ document.addEventListener('DOMContentLoaded', () => {document.getElementById('result-mode').textContent = details.mode === 'quick' ? 'Quick Summary' : 'Detailed Report';// Load the report content- const reportResponse = await fetch(`/api/report/${researchId}`);+ const reportResponse = await fetch(getApiUrl(`/api/report/${researchId}`));const reportData = await reportResponse.json();if (reportData.status === 'success') {@@ -794,7 +796,7 @@ document.addEventListener('DOMContentLoaded', () => {try {// Load research details- const response = await fetch(`/api/research/${researchId}/details`);+ const response = await fetch(getApiUrl(`/api/research/${researchId}/details`));console.log('Research details API response status:', response.status);if (!response.ok) {@@ -1032,7 +1034,7 @@ document.addEventListener('DOMContentLoaded', () => {// Check for active research on page load(async function checkActiveResearch() {try {- const response = await fetch('/api/history');+ const response = await fetch(getApiUrl('/api/history'));const history = await response.json();// Find in-progress research@@ -1067,7 +1069,7 @@ document.addEventListener('DOMContentLoaded', () => {if (!isResearchInProgress || !currentResearchId) return;// Fetch current status- fetch(`/api/research/${currentResearchId}`)+ fetch(getApiUrl(`/api/research/${currentResearchId}`)).then(response => response.json()).then(data => {document.getElementById('current-query').textContent = data.query || '';@@ -1150,7 +1152,7 @@ document.addEventListener('DOMContentLoaded', () => {}// Update the progress page- fetch(`/api/research/${currentResearchId}`)+ fetch(getApiUrl(`/api/research/${currentResearchId}`)).then(response => response.json()).then(data => {// Update the query display@@ -1460,11 +1462,11 @@ document.addEventListener('DOMContentLoaded', () => {async function generatePdfFromResearch(researchId) {try {// Load research details- const detailsResponse = await fetch(`/api/research/${researchId}`);+ const detailsResponse = await fetch(getApiUrl(`/api/research/${researchId}`));const details = await detailsResponse.json();// Load the report content- const reportResponse = await fetch(`/api/report/${researchId}`);+ const reportResponse = await fetch(getApiUrl(`/api/report/${researchId}`));const reportData = await reportResponse.json();if (reportData.status === 'success') {@@ -1547,4 +1549,13 @@ document.addEventListener('DOMContentLoaded', () => {if (downloadPdfBtn) {downloadPdfBtn.addEventListener('click', generatePdf);}++ // Home navigation - redirect to warplink.dev+ document.getElementById('home-link').addEventListener('click', function() {+ window.location.href = 'https://warplink.dev';+ });++ document.getElementById('mobile-home-link').addEventListener('click', function() {+ window.location.href = 'https://warplink.dev';+ });});\ No newline at end of filediff --git a/templates/index.html b/templates/index.htmlindex 5448220170..1d3118846a 100644--- a/templates/index.html+++ b/templates/index.html@@ -3,8 +3,8 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <title>Deep Research Lab</title>- <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">+ <title>Deep Research System</title>+ <link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"><!-- Change to CDN version that works in browsers --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css">@@ -19,6 +19,7 @@</div><nav class="sidebar-nav"><ul>+ <li id="home-link" class="external-link"><i class="fas fa-arrow-left"></i> Home</li><li class="active" data-page="new-research"><i class="fas fa-search"></i> New Research</li><li data-page="history"><i class="fas fa-history"></i> History</li></ul>@@ -229,6 +230,10 @@<!-- Mobile Tab Bar --><nav class="mobile-tab-bar"><ul>+ <li id="mobile-home-link" class="external-link">+ <i class="fas fa-arrow-left"></i>+ <span>Home</span>+ </li><li class="active" data-page="new-research"><i class="fas fa-search"></i><span>Research</span>@@ -258,7 +263,7 @@<!-- PDF generation libraries --><script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>- <script src="{{ url_for('static', filename='js/app.js') }}"></script>+ <script src="{{ url_for('research.serve_static', path='js/app.js') }}"></script><script>document.addEventListener('DOMContentLoaded', function() {// Initialize the terminate button event listener