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.

improvments to settings

LearningCircuit9f9e2642b583
diff --git a/src/local_deep_research/config.py.bak b/src/local_deep_research/config.py.bak
new file mode 100644
index 0000000000..682e1a7e3f
--- /dev/null
+++ b/src/local_deep_research/config.py.bak
@@ -0,0 +1,295 @@
+"""
+Local Deep Research Configuration Guide
+
+This configuration file controls the behavior of the research system.
+
+MAIN SETTINGS:
+- search_tool (str): Choose which search engine to use
+ - "auto": Intelligent selection based on query content (recommended)
+ - "local_all": Search only local document collections
+ - "wikipedia": General knowledge and facts
+ - "arxiv": Scientific papers and research
+ - "duckduckgo": General web search (no API key needed)
+ - "serp": Google search via SerpAPI (requires API key)
+ - "google_pse": Google Programmable Search Engine for custom search experiences (requires API key)
+ - "guardian": News articles (requires API key)
+ - Any collection name from your local_collections.py
+
+- DEFAULT_MODEL (str): LLM to use for analysis
+ - "mistral": Default local model via Ollama
+ - "deepseek-r1:14b": Alternative larger model
+ - "claude-3-5-sonnet-latest": Claude model (requires API key)
+ - "gpt-4o": OpenAI model (requires API key)
+ - "mpt-7b": MPT model via VLLM
+
+API KEYS:
+For search engines requiring API keys, set these in your .env file:
+- SERP_API_KEY: For Google search via SerpAPI
+- GUARDIAN_API_KEY: For The Guardian news search
+- GOOGLE_PSE_API_KEY: For Google Programmable Search Engine
+- GOOGLE_PSE_ENGINE_ID: Search Engine ID from Google PSE Control Panel
+
+RESEARCH SETTINGS:
+- SEARCH_ITERATIONS (int): Number of research cycles
+- QUESTIONS_PER_ITERATION (int): Questions per cycle
+- SEARCHES_PER_SECTION (int): Searches per report section
+- MAX_SEARCH_RESULTS (int): Results per search query
+- MAX_FILTERED_RESULTS (int): Results after relevance filtering
+
+For full documentation, see the README.md
+"""
+
+from langchain_anthropic import ChatAnthropic
+from langchain_openai import ChatOpenAI
+from langchain_ollama import ChatOllama
+from langchain_community.llms import VLLM # Added VLLM import
+from dotenv import load_dotenv
+from .utilties.enums import KnowledgeAccumulationApproach
+
+import json
+import os
+import re
+from typing import Dict, List, Any, Optional, Callable
+
+# Load environment variables
+load_dotenv()
+# Choose search tool: "serp" or "duckduckgo" (serp requires API key)
+search_tool = "auto" # Change this variable to switch between search tools; for only local search "local-all"
+
+KNOWLEDGE_ACCUMULATION = KnowledgeAccumulationApproach.ITERATION # None doesnt work with detailed report. It basically means the questions are seperate on the topic.
+KNOWLEDGE_ACCUMULATION_CONTEXT_LIMIT = 2000000
+
+# LLM Configuration
+OPENAIENDPOINT=False # True + URL + Model Name
+OPENROUTER_BASE_URL= "https://openrouter.ai/api/v1"
+
+DEFAULT_MODEL = "mistral" # try to use the largest model that fits into your GPU memory
+DEFAULT_TEMPERATURE = 0.7
+MAX_TOKENS = 30000
+
+# VLLM Configuration
+VLLM_MAX_NEW_TOKENS = 128
+VLLM_TOP_K = 10
+VLLM_TOP_P = 0.95
+VLLM_TEMPERATURE = 0.8
+
+# Search System Settings
+SEARCH_ITERATIONS = 2
+QUESTIONS_PER_ITERATION = 2
+
+# Report settings
+SEARCHES_PER_SECTION = 2
+#CONTEXT_CUT_OFF = 10000
+
+# citation handler
+ENABLE_FACT_CHECKING = False # comes with pros and cons. Maybe works better with larger LLMs?
+
+# URL Quality Check (applies to both DDG and SerpAPI)
+QUALITY_CHECK_DDG_URLS = True # Keep True for better quality results.
+
+SEARCH_SNIPPETS_ONLY = False
+SKIP_RELEVANCE_FILTER = False
+
+# Search Configuration (applies to both DDG and SerpAPI)
+MAX_SEARCH_RESULTS = 50
+MAX_FILTERED_RESULTS = 5
+SEARCH_REGION = "us"
+TIME_PERIOD = "y"
+SAFE_SEARCH = True
+SEARCH_LANGUAGE = "English"
+
+# Output Configuration
+OUTPUT_DIR = "research_outputs"
+
+# Make OpenAI integration optional with lazy loading
+def is_openai_available():
+ """Check if OpenAI is available without importing it at module level"""
+ try:
+ # Only import when checking
+ import os
+ api_key = os.environ.get("OPENAI_API_KEY")
+ if not api_key:
+ return False
+
+ # Only try to import if we have an API key
+ try:
+ from langchain_openai import ChatOpenAI
+ return True
+ except ImportError:
+ return False
+ except:
+ return False
+
+# Models map
+MODELS = {
+ # Local models
+ "ollama-llama3": "Local Llama3 model (requires Ollama)",
+ "ollama-mixtral": "Local Mixtral model (requires Ollama)",
+ "ollama-mistral": "Local Mistral model (requires Ollama)",
+
+ # API-based models
+ "gpt-4o": "OpenAI model (requires API key)",
+ "gpt-3.5-turbo": "OpenAI model (requires API key)",
+}
+
+# Available model providers
+MODEL_PROVIDERS = ["local", "openai"]
+
+def get_model(model_name: str, **kwargs):
+ """Get model instance based on the model name"""
+ # Common parameters for all models
+ common_params = {
+ "temperature": kwargs.get("temperature", 0.0),
+ "verbose": kwargs.get("verbose", False),
+ }
+
+ # Ollama models (local)
+ if model_name.startswith("ollama-"):
+ try:
+ from langchain_community.llms import Ollama
+ base_url = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")
+ return Ollama(model=model_name.replace("ollama-", ""), base_url=base_url, **common_params)
+ except ImportError:
+ raise ValueError("Langchain Ollama integration not available. Please install it with: pip install langchain-community")
+
+ # OpenAI models
+ elif model_name in ["gpt-4o", "gpt-3.5-turbo"]:
+ if not is_openai_available():
+ raise ValueError("OpenAI integration not available. Please install langchain-openai and set OPENAI_API_KEY environment variable.")
+
+ api_key = os.getenv("OPENAI_API_KEY")
+ if not api_key:
+ raise ValueError("OPENAI_API_KEY not found in environment variables")
+ return ChatOpenAI(model=model_name, api_key=api_key, **common_params)
+
+ else:
+ raise ValueError(f"Unsupported model: {model_name}")
+
+def get_available_models() -> Dict[str, str]:
+ """Return available models based on installed packages and environment variables"""
+ available_models = {}
+
+ # Check Ollama models
+ try:
+ import langchain_community
+ # Check if Ollama is running
+ ollama_running = False
+ try:
+ import requests
+ base_url = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")
+ requests.get(f"{base_url}/api/tags", timeout=2)
+ ollama_running = True
+ except:
+ pass
+
+ if ollama_running:
+ for model in [k for k in MODELS.keys() if k.startswith("ollama-")]:
+ available_models[model] = MODELS[model]
+ except ImportError:
+ pass
+
+ # Check OpenAI models
+ if is_openai_available():
+ for model in ["gpt-4o", "gpt-3.5-turbo"]:
+ available_models[model] = MODELS[model]
+
+ return available_models
+
+def get_llm(model_name=DEFAULT_MODEL, temperature=DEFAULT_TEMPERATURE):
+ """Get LLM instance - easy to switch between models"""
+ common_params = {
+ "temperature": temperature,
+ "max_tokens": MAX_TOKENS,
+ }
+
+ if "claude" in model_name:
+ api_key = os.getenv("ANTHROPIC_API_KEY")
+ if not api_key:
+ raise ValueError("ANTHROPIC_API_KEY not found in environment variables")
+ return ChatAnthropic(
+ model=model_name, anthropic_api_key=api_key, **common_params
+ )
+ elif OPENAIENDPOINT:
+ api_key = os.getenv("OPENAI_ENDPOINT_API_KEY")
+ if not api_key:
+ raise ValueError("OPENAI_API_KEY not found in environment variables")
+ return ChatOpenAI(model=model_name, api_key=api_key,openai_api_base=OPENROUTER_BASE_URL, **common_params)
+
+ elif "gpt" in model_name:
+ if not is_openai_available():
+ raise ValueError("OpenAI integration not available or API key not set. Please install langchain-openai and set OPENAI_API_KEY.")
+
+ api_key = os.getenv("OPENAI_API_KEY")
+ if not api_key:
+ raise ValueError("OPENAI_API_KEY not found in environment variables")
+ return ChatOpenAI(model=model_name, api_key=api_key, **common_params)
+
+ elif model_name == "mpt-7b":
+ # VLLM configuration for the MPT model
+ return VLLM(
+ model="mosaicml/mpt-7b",
+ trust_remote_code=True, # mandatory for hf models
+ max_new_tokens=VLLM_MAX_NEW_TOKENS,
+ top_k=VLLM_TOP_K,
+ top_p=VLLM_TOP_P,
+ temperature=VLLM_TEMPERATURE,
+ )
+
+ else:
+ return ChatOllama(model=model_name, base_url="http://localhost:11434", **common_params)
+
+
+def get_search():
+ """Get search tool instance based on config settings"""
+ # Import here to avoid circular import
+ from local_deep_research.web_search_engines.search_engine_factory import get_search as factory_get_search
+
+ print(f"Creating search engine with tool: {search_tool}")
+ engine = factory_get_search(
+ search_tool=search_tool,
+ llm_instance=get_llm(),
+ max_results=MAX_SEARCH_RESULTS,
+ region=SEARCH_REGION,
+ time_period=TIME_PERIOD,
+ safe_search=SAFE_SEARCH,
+ search_snippets_only=SEARCH_SNIPPETS_ONLY,
+ search_language=SEARCH_LANGUAGE,
+ max_filtered_results=MAX_FILTERED_RESULTS
+ )
+
+ if engine is None:
+ print(f"Failed to create search engine with tool: {search_tool}")
+
+ return engine
+
+
+# Path for user config
+USER_CONFIG_PATH = os.path.expanduser("~/.local_deep_research/config.json")
+
+def get_config():
+ """Get current configuration as dictionary"""
+ config_dict = {}
+ # Get all uppercase variables (conventional config variables)
+ for key, value in globals().items():
+ if key.isupper() and not key.startswith('_'):
+ config_dict[key] = value
+ return config_dict
+
+def save_config(config_dict):
+ """Save user configuration"""
+ os.makedirs(os.path.dirname(USER_CONFIG_PATH), exist_ok=True)
+ with open(USER_CONFIG_PATH, 'w') as f:
+ json.dump(config_dict, f, indent=2)
+
+# Load user config at module import time
+if os.path.exists(USER_CONFIG_PATH):
+ try:
+ with open(USER_CONFIG_PATH, 'r') as f:
+ user_config = json.load(f)
+ # Update globals with user settings
+ for key, value in user_config.items():
+ if key in globals() and key.isupper():
+ globals()[key] = value
+ print(f"Loaded user configuration from {USER_CONFIG_PATH}")
+ except Exception as e:
+ print(f"Error loading user config: {e}")
\ No newline at end of file
diff --git a/src/local_deep_research/web/app.py b/src/local_deep_research/web/app.py
index af6ed31430..d140a2c2fa 100644
--- a/src/local_deep_research/web/app.py
+++ b/src/local_deep_research/web/app.py
@@ -845,7 +845,120 @@ def delete_research(research_id):
conn.close()
return jsonify({'status': 'success'})
-
+from flask import render_template, redirect, url_for
+from ..config import get_config, save_config
+
+@research_bp.route('/settings', methods=['GET', 'POST'])
+def settings_page():
+ if request.method == 'POST':
+ # Get current config
+ current_config = get_config()
+
+ # Process checkbox fields
+ checkbox_fields = [
+ 'ENABLE_FACT_CHECKING', 'SEARCH_SNIPPETS_ONLY', 'SKIP_RELEVANCE_FILTER',
+ 'QUALITY_CHECK_DDG_URLS', 'SAFE_SEARCH', 'OPENAIENDPOINT'
+ ]
+
+ # First set all checkboxes to False
+ for key in checkbox_fields:
+ if key in current_config and isinstance(current_config[key], bool):
+ current_config[key] = False
+
+ # Update with form data
+ for key, value in request.form.items():
+ if key in current_config:
+ # Convert value to the appropriate type
+ if isinstance(current_config[key], bool) or key in checkbox_fields:
+ current_config[key] = value.lower() in ('true', 'yes', '1', 'on', 'checked')
+ elif isinstance(current_config[key], int):
+ try:
+ current_config[key] = int(value)
+ except ValueError:
+ pass
+ elif isinstance(current_config[key], float):
+ try:
+ current_config[key] = float(value)
+ except ValueError:
+ pass
+ else:
+ current_config[key] = value
+
+ # Handle special cases
+ if 'search_tool' in request.form:
+ current_config['search_tool'] = request.form['search_tool']
+
+ if 'KNOWLEDGE_ACCUMULATION' in request.form:
+ from .utilties.enums import KnowledgeAccumulationApproach
+ value = request.form['KNOWLEDGE_ACCUMULATION']
+ try:
+ current_config['KNOWLEDGE_ACCUMULATION'] = getattr(KnowledgeAccumulationApproach, value)
+ except AttributeError:
+ pass
+
+ # Save updated config
+ save_config(current_config)
+
+ flash('Settings saved successfully', 'success')
+ return redirect(url_for('research.settings_page'))
+
+ # Get the raw config file content
+ try:
+ import os
+ module_path = os.path.join(os.path.dirname(__file__), "config.py")
+ if os.path.exists(module_path):
+ with open(module_path, "r") as f:
+ raw_config = f.read()
+ else:
+ # Look for the config in the parent directory
+ parent_module_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.py")
+ if os.path.exists(parent_module_path):
+ with open(parent_module_path, "r") as f:
+ raw_config = f.read()
+ else:
+ raw_config = "Config file not found. Please check your installation."
+ except Exception as e:
+ raw_config = f"Error loading raw configuration: {str(e)}"
+
+ # For GET request, display settings form
+ return render_template('settings.html', config=get_config(), raw_config=raw_config)
+@research_bp.route('/save_raw_config', methods=['POST'])
+def save_raw_config():
+ try:
+ data = request.get_json()
+ raw_config = data.get('raw_config', '')
+
+ # Validate Python syntax
+ try:
+ compile(raw_config, '<string>', 'exec')
+ except SyntaxError as e:
+ return jsonify({'success': False, 'error': f'Syntax error: {str(e)}'})
+
+ # Save to file
+ import os
+ module_path = os.path.join(os.path.dirname(__file__), "config.py")
+ if os.path.exists(module_path):
+ config_path = module_path
+ else:
+ # Look for the config in the parent directory
+ parent_module_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.py")
+ if os.path.exists(parent_module_path):
+ config_path = parent_module_path
+ else:
+ return jsonify({'success': False, 'error': 'Config file not found'})
+
+ # Create a backup first
+ import shutil
+ backup_path = config_path + '.bak'
+ shutil.copy2(config_path, backup_path)
+
+ # Write new config
+ with open(config_path, 'w') as f:
+ f.write(raw_config)
+
+ return jsonify({'success': True})
+ except Exception as e:
+ return jsonify({'success': False, 'error': str(e)})
# Register the blueprint
app.register_blueprint(research_bp)
diff --git a/src/local_deep_research/web/templates/index.html b/src/local_deep_research/web/templates/index.html
index 9e320353e9..b98176995d 100644
--- a/src/local_deep_research/web/templates/index.html
+++ b/src/local_deep_research/web/templates/index.html
@@ -21,6 +21,7 @@
<ul>
<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>
+ <li data-page="settings"><i class="fas fa-cog"></i> <a href="{{ url_for('research.settings_page') }}">Settings</a></li>
</ul>
</nav>
<div class="sidebar-footer">
@@ -237,6 +238,12 @@
<i class="fas fa-history"></i>
<span>History</span>
</li>
+ <li data-page="settings">
+ <a href="{{ url_for('research.settings_page') }}">
+ <i class="fas fa-cog"></i>
+ <span>Settings</span>
+ </a>
+ </li>
</ul>
</nav>
diff --git a/src/local_deep_research/web/templates/settings.html b/src/local_deep_research/web/templates/settings.html
new file mode 100644
index 0000000000..34a32bc75f
--- /dev/null
+++ b/src/local_deep_research/web/templates/settings.html
@@ -0,0 +1,440 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Deep Research System - Settings</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">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css">
+ <link rel="icon" type="image/png" href="{{ url_for('static', filename='favicon.ico') }}">
+ <style>
+ .settings-section {
+ margin-bottom: 2rem;
+ padding-bottom: 1.5rem;
+ border-bottom: 1px solid #333;
+ }
+ .settings-section h2 {
+ margin-bottom: 1rem;
+ color: #4a6cf7;
+ font-size: 1.3rem;
+ }
+ .form-group {
+ margin-bottom: 1rem;
+ }
+ .form-group label {
+ display: block;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ }
+ .form-control {
+ width: 100%;
+ padding: 0.5rem;
+ border: 1px solid #333;
+ border-radius: 4px;
+ background-color: #1a1a1a;
+ color: #f8f9fa;
+ }
+ .form-row {
+ display: flex;
+ gap: 1rem;
+ }
+ .form-group.half {
+ flex: 1;
+ }
+ .input-help {
+ display: block;
+ font-size: 0.8rem;
+ color: #8a8a8a;
+ margin-top: 0.25rem;
+ }
+ .checkbox-group {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ }
+ .checkbox-group input {
+ margin: 0;
+ }
+ .checkbox-group label {
+ margin: 0;
+ }
+ .form-actions {
+ margin-top: 2rem;
+ display: flex;
+ gap: 1rem;
+ }
+ .range-value {
+ display: inline-block;
+ margin-left: 0.5rem;
+ }
+ .config-raw {
+ margin-top: 2rem;
+ background-color: #0a0a0a;
+ padding: 1rem;
+ border-radius: 4px;
+ overflow: auto;
+ font-family: monospace;
+ font-size: 0.9rem;
+ color: #e6e6e6;
+ white-space: pre;
+ }
+ .toggle-raw-config {
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ margin-top: 2rem;
+ color: #4a6cf7;
+ font-weight: 500;
+ }
+ .config-raw-editor {
+ background-color: #0a0a0a;
+ color: #e6e6e6;
+ font-family: monospace;
+ font-size: 0.9rem;
+ padding: 1rem;
+ border: 1px solid #333;
+ border-radius: 4px;
+ width: 100%;
+ resize: vertical;
+ }
+ </style>
+</head>
+<body>
+ <div class="app-container">
+ <!-- Sidebar -->
+ <aside class="sidebar">
+ <div class="sidebar-header">
+ <h2 id="logo-link" style="cursor: pointer;"><i class="fas fa-atom"></i> Deep Research</h2>
+ </div>
+ <nav class="sidebar-nav">
+ <ul>
+ <li data-page="new-research"><i class="fas fa-search"></i> <a href="{{ url_for('research.index') }}">New Research</a></li>
+ <li data-page="history"><i class="fas fa-history"></i> <a href="{{ url_for('research.index') }}#history">History</a></li>
+ <li class="active" data-page="settings"><i class="fas fa-cog"></i> Settings</li>
+ </ul>
+ </nav>
+ <div class="sidebar-footer">
+ <p>v0.0.1 | <i class="fas fa-brain"></i></p>
+ </div>
+ </aside>
+
+ <!-- Main Content -->
+ <main class="main-content">
+ <div class="page active" id="settings">
+ <div class="page-header">
+ <h1>Settings</h1>
+ </div>
+ <div class="card">
+ <div class="card-content">
+ <form method="POST" action="{{ url_for('research.settings_page') }}">
+ <!-- LLM Settings Section -->
+ <div class="settings-section">
+ <h2><i class="fas fa-brain"></i> LLM Settings</h2>
+ <div class="form-group">
+ <label for="DEFAULT_MODEL">Default Model</label>
+ <select id="DEFAULT_MODEL" name="DEFAULT_MODEL" class="form-control">
+ <option value="mistral" {% if config.DEFAULT_MODEL == "mistral" %}selected{% endif %}>Mistral (Default)</option>
+ <option value="llama3" {% if config.DEFAULT_MODEL == "llama3" %}selected{% endif %}>Llama3</option>
+ <option value="mixtral" {% if config.DEFAULT_MODEL == "mixtral" %}selected{% endif %}>Mixtral</option>
+ <option value="mpt-7b" {% if config.DEFAULT_MODEL == "mpt-7b" %}selected{% endif %}>MPT-7B</option>
+ <option value="gpt-4o" {% if config.DEFAULT_MODEL == "gpt-4o" %}selected{% endif %}>GPT-4o (requires API key)</option>
+ <option value="gpt-3.5-turbo" {% if config.DEFAULT_MODEL == "gpt-3.5-turbo" %}selected{% endif %}>GPT-3.5 Turbo (requires API key)</option>
+ <option value="claude-3-5-sonnet-latest" {% if config.DEFAULT_MODEL == "claude-3-5-sonnet-latest" %}selected{% endif %}>Claude (requires API key)</option>
+ </select>
+ <span class="input-help">Select the default language model to use for analysis</span>
+ </div>
+ <div class="form-group">
+ <label for="DEFAULT_TEMPERATURE">Temperature</label>
+ <input type="range" min="0" max="1" step="0.1" class="form-control" id="DEFAULT_TEMPERATURE" name="DEFAULT_TEMPERATURE" value="{{ config.DEFAULT_TEMPERATURE }}">
+ <span class="range-value" id="temp-value">{{ config.DEFAULT_TEMPERATURE }}</span>
+ <span class="input-help">Higher values = more creative, lower values = more deterministic</span>
+ </div>
+ <div class="form-group">
+ <label for="MAX_TOKENS">Max Tokens</label>
+ <input type="number" min="1000" max="100000" step="1000" class="form-control" id="MAX_TOKENS" name="MAX_TOKENS" value="{{ config.MAX_TOKENS }}">
+ <span class="input-help">Maximum tokens for model output</span>
+ </div>
+
+ <div class="form-group checkbox-group">
+ <input type="checkbox" id="OPENAIENDPOINT" name="OPENAIENDPOINT" {% if config.OPENAIENDPOINT %}checked{% endif %}>
+ <label for="OPENAIENDPOINT">Use OpenAI endpoint</label>
+ </div>
+
+ <div class="form-group">
+ <label for="OPENROUTER_BASE_URL">OpenRouter Base URL</label>
+ <input type="text" class="form-control" id="OPENROUTER_BASE_URL" name="OPENROUTER_BASE_URL" value="{{ config.OPENROUTER_BASE_URL }}">
+ <span class="input-help">Base URL for OpenRouter API</span>
+ </div>
+ </div>
+
+ <!-- VLLM Settings Section -->
+ <div class="settings-section">
+ <h2><i class="fas fa-server"></i> VLLM Configuration</h2>
+ <div class="form-row">
+ <div class="form-group half">
+ <label for="VLLM_MAX_NEW_TOKENS">Max New Tokens</label>
+ <input type="number" min="1" max="1000" class="form-control" id="VLLM_MAX_NEW_TOKENS" name="VLLM_MAX_NEW_TOKENS" value="{{ config.VLLM_MAX_NEW_TOKENS }}">
+ <span class="input-help">Maximum new tokens for VLLM models</span>
+ </div>
+ <div class="form-group half">
+ <label for="VLLM_TOP_K">Top K</label>
+ <input type="number" min="1" max="100" class="form-control" id="VLLM_TOP_K" name="VLLM_TOP_K" value="{{ config.VLLM_TOP_K }}">
+ <span class="input-help">Top K sampling parameter</span>
+ </div>
+ </div>
+ <div class="form-row">
+ <div class="form-group half">
+ <label for="VLLM_TOP_P">Top P</label>
+ <input type="range" min="0" max="1" step="0.01" class="form-control" id="VLLM_TOP_P" name="VLLM_TOP_P" value="{{ config.VLLM_TOP_P }}">
+ <span class="range-value" id="top-p-value">{{ config.VLLM_TOP_P }}</span>
+ <span class="input-help">Top P sampling parameter</span>
+ </div>
+ <div class="form-group half">
+ <label for="VLLM_TEMPERATURE">VLLM Temperature</label>
+ <input type="range" min="0" max="1" step="0.1" class="form-control" id="VLLM_TEMPERATURE" name="VLLM_TEMPERATURE" value="{{ config.VLLM_TEMPERATURE }}">
+ <span class="range-value" id="vllm-temp-value">{{ config.VLLM_TEMPERATURE }}</span>
+ <span class="input-help">Temperature for VLLM models</span>
+ </div>
+ </div>
+ </div>
+
+ <!-- Search Settings Section -->
+ <div class="settings-section">
+ <h2><i class="fas fa-search"></i> Search Settings</h2>
+ <div class="form-group">
+ <label for="search_tool">Default Search Engine</label>
+ <select id="search_tool" name="search_tool" class="form-control">
+ <option value="auto" {% if config.search_tool == "auto" %}selected{% endif %}>Auto (Intelligent selection)</option>
+ <option value="wikipedia" {% if config.search_tool == "wikipedia" %}selected{% endif %}>Wikipedia</option>
+ <option value="arxiv" {% if config.search_tool == "arxiv" %}selected{% endif %}>arXiv (scientific papers)</option>
+ <option value="pubmed" {% if config.search_tool == "pubmed" %}selected{% endif %}>PubMed (medical research)</option>
+ <option value="duckduckgo" {% if config.search_tool == "duckduckgo" %}selected{% endif %}>DuckDuckGo (web search)</option>
+ <option value="serp" {% if config.search_tool == "serp" %}selected{% endif %}>SerpAPI (Google, requires API key)</option>
+ <option value="google_pse" {% if config.search_tool == "google_pse" %}selected{% endif %}>Google PSE (requires API key)</option>
+ <option value="guardian" {% if config.search_tool == "guardian" %}selected{% endif %}>Guardian (news, requires API key)</option>
+ <option value="local_all" {% if config.search_tool == "local_all" %}selected{% endif %}>Local Documents</option>
+ </select>
+ <span class="input-help">Choose your primary search and research source</span>
+ </div>
+
+ <div class="form-row">
+ <div class="form-group half">
+ <label for="SEARCH_ITERATIONS">Search Iterations</label>
+ <input type="number" min="1" max="5" class="form-control" id="SEARCH_ITERATIONS" name="SEARCH_ITERATIONS" value="{{ config.SEARCH_ITERATIONS }}">
+ <span class="input-help">Number of research cycles to perform</span>
+ </div>
+ <div class="form-group half">
+ <label for="QUESTIONS_PER_ITERATION">Questions Per Iteration</label>
+ <input type="number" min="1" max="10" class="form-control" id="QUESTIONS_PER_ITERATION" name="QUESTIONS_PER_ITERATION" value="{{ config.QUESTIONS_PER_ITERATION }}">
+ <span class="input-help">Follow-up questions in each cycle</span>
+ </div>
+ </div>
+
+ <div class="form-row">
+ <div class="form-group half">
+ <label for="MAX_SEARCH_RESULTS">Maximum Search Results</label>
+ <input type="number" min="5" max="100" class="form-control" id="MAX_SEARCH_RESULTS" name="MAX_SEARCH_RESULTS" value="{{ config.MAX_SEARCH_RESULTS }}">
+ <span class="input-help">Higher values give more comprehensive research but take longer</span>
+ </div>
+
+ <div class="form-group half">
+ <label for="MAX_FILTERED_RESULTS">Maximum Filtered Results</label>
+ <input type="number" min="1" max="20" class="form-control" id="MAX_FILTERED_RESULTS" name="MAX_FILTERED_RESULTS" value="{{ config.MAX_FILTERED_RESULTS }}">
+ <span class="input-help">Results kept after relevance filtering</span>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label for="KNOWLEDGE_ACCUMULATION">Knowledge Accumulation</label>
+ <select id="KNOWLEDGE_ACCUMULATION" name="KNOWLEDGE_ACCUMULATION" class="form-control">
+ <option value="ITERATION" {% if config.KNOWLEDGE_ACCUMULATION == "ITERATION" %}selected{% endif %}>Iteration-based</option>
+ <option value="NONE" {% if config.KNOWLEDGE_ACCUMULATION == "NONE" %}selected{% endif %}>None</option>
+ </select>
+ <span class="input-help">How to accumulate knowledge during research</span>
+ </div>
+
+ <div class="form-group">
+ <label for="KNOWLEDGE_ACCUMULATION_CONTEXT_LIMIT">Knowledge Accumulation Context Limit</label>
+ <input type="number" min="1000" max="10000000" step="10000" class="form-control" id="KNOWLEDGE_ACCUMULATION_CONTEXT_LIMIT" name="KNOWLEDGE_ACCUMULATION_CONTEXT_LIMIT" value="{{ config.KNOWLEDGE_ACCUMULATION_CONTEXT_LIMIT }}">
+ <span class="input-help">Maximum context size for knowledge accumulation</span>
+ </div>
+
+ <div class="form-row">
+ <div class="form-group half">
+ <label for="SEARCH_REGION">Search Region</label>
+ <input type="text" class="form-control" id="SEARCH_REGION" name="SEARCH_REGION" value="{{ config.SEARCH_REGION }}">
+ <span class="input-help">Region code for search (e.g., us, uk, de)</span>
+ </div>
+ <div class="form-group half">
+ <label for="TIME_PERIOD">Time Period</label>
+ <select id="TIME_PERIOD" name="TIME_PERIOD" class="form-control">
+ <option value="d" {% if config.TIME_PERIOD == "d" %}selected{% endif %}>Past day</option>
+ <option value="w" {% if config.TIME_PERIOD == "w" %}selected{% endif %}>Past week</option>
+ <option value "m" {% if config.TIME_PERIOD == "m" %}selected{% endif %}>Past month</option>
+ <option value="y" {% if config.TIME_PERIOD == "y" %}selected{% endif %}>Past year</option>
+ <option value="a" {% if config.TIME_PERIOD == "a" %}selected{% endif %}>All time</option>
+ </select>
+ <span class="input-help">Time period for search results</span>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label for="SEARCH_LANGUAGE">Search Language</label>
+ <input type="text" class="form-control" id="SEARCH_LANGUAGE" name="SEARCH_LANGUAGE" value="{{ config.SEARCH_LANGUAGE }}">
+ <span class="input-help">Language for search results</span>
+ </div>
+
+ <div class="form-group checkbox-group">
+ <input type="checkbox" id="SAFE_SEARCH" name="SAFE_SEARCH" {% if config.SAFE_SEARCH %}checked{% endif %}>
+ <label for="SAFE_SEARCH">Safe Search</label>
+ </div>
+
+ <div class="form-group checkbox-group">
+ <input type="checkbox" id="QUALITY_CHECK_DDG_URLS" name="QUALITY_CHECK_DDG_URLS" {% if config.QUALITY_CHECK_DDG_URLS %}checked{% endif %}>
+ <label for="QUALITY_CHECK_DDG_URLS">Quality check URLs</label>
+ <span class="input-help">Enable quality filtering for search results</span>
+ </div>
+
+ <div class="form-group checkbox-group">
+ <input type="checkbox" id="SEARCH_SNIPPETS_ONLY" name="SEARCH_SNIPPETS_ONLY" {% if config.SEARCH_SNIPPETS_ONLY %}checked{% endif %}>
+ <label for="SEARCH_SNIPPETS_ONLY">Use search snippets only (faster but less detailed)</label>
+ </div>
+
+ <div class="form-group checkbox-group">
+ <input type="checkbox" id="SKIP_RELEVANCE_FILTER" name="SKIP_RELEVANCE_FILTER" {% if config.SKIP_RELEVANCE_FILTER %}checked{% endif %}>
+ <label for="SKIP_RELEVANCE_FILTER">Skip relevance filtering (return all results)</label>
+ </div>
+ </div>
+
+ <!-- Report Settings Section -->
+ <div class="settings-section">
+ <h2><i class="fas fa-file-alt"></i> Report Settings</h2>
+ <div class="form-group">
+ <label for="SEARCHES_PER_SECTION">Searches Per Report Section</label>
+ <input type="number" min="1" max="5" class="form-control" id="SEARCHES_PER_SECTION" name="SEARCHES_PER_SECTION" value="{{ config.SEARCHES_PER_SECTION }}">
+ <span class="input-help">Number of searches to run per report section</span>
+ </div>
+
+ <div class="form-group checkbox-group">
+ <input type="checkbox" id="ENABLE_FACT_CHECKING" name="ENABLE_FACT_CHECKING" {% if config.ENABLE_FACT_CHECKING %}checked{% endif %}>
+ <label for="ENABLE_FACT_CHECKING">Enable fact checking (may work better with large LLMs)</label>
+ </div>
+
+ <div class="form-group">
+ <label for="OUTPUT_DIR">Output Directory</label>
+ <input type="text" class="form-control" id="OUTPUT_DIR" name="OUTPUT_DIR" value="{{ config.OUTPUT_DIR }}">
+ <span class="input-help">Directory to save research outputs</span>
+ </div>
+ </div>
+
+ <div class="form-actions">
+ <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Save Settings</button>
+ <a href="{{ url_for('research.index') }}" class="btn btn-outline"><i class="fas fa-times"></i> Cancel</a>
+ </div>
+ </form>
+
+ <div class="toggle-raw-config" onclick="toggleRawConfig()">
+ <i class="fas fa-code"></i> <span id="toggle-text">Show Raw Configuration</span>
+ </div>
+
+ <div id="raw-config" class="config-raw" style="display: none;">
+ {{ raw_config|safe }}
+ </div>
+ <!-- Raw Configuration Editing -->
+ <div class="settings-section">
+ <h2><i class="fas fa-code"></i> Raw Configuration</h2>
+ <div class="form-group">
+ <textarea id="raw_config_editor" name="raw_config_editor" class="form-control config-raw-editor" rows="20">{{ raw_config|safe }}</textarea>
+ </div>
+ <div class="form-actions">
+ <button type="button" class="btn btn-primary" onclick="saveRawConfig()"><i class="fas fa-save"></i> Save Raw Configuration</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </main>
+ </div>
+
+ <!-- Mobile Tab Bar -->
+ <nav class="mobile-tab-bar">
+ <ul>
+ <li data-page="new-research">
+ <a href="{{ url_for('research.index') }}">
+ <i class="fas fa-search"></i>
+ <span>Research</span>
+ </a>
+ </li>
+ <li data-page="history">
+ <a href="{{ url_for('research.index') }}#history">
+ <i class="fas fa-history"></i>
+ <span>History</span>
+ </a>
+ </li>
+ <li class="active" data-page="settings">
+ <i class="fas fa-cog"></i>
+ <span>Settings</span>
+ </li>
+ </ul>
+ </nav>
+
+ <script>
+ // Update temperature display value
+ document.getElementById('DEFAULT_TEMPERATURE').addEventListener('input', function() {
+ document.getElementById('temp-value').textContent = this.value;
+ });
+
+ // Update VLLM temperature display value
+ document.getElementById('VLLM_TEMPERATURE').addEventListener('input', function() {
+ document.getElementById('vllm-temp-value').textContent = this.value;
+ });
+
+ // Update Top P display value
+ document.getElementById('VLLM_TOP_P').addEventListener('input', function() {
+ document.getElementById('top-p-value').textContent = this.value;
+ });
+
+ // Make the logo clickable to go back to home
+ document.getElementById('logo-link').addEventListener('click', function() {
+ window.location.href = "{{ url_for('research.index') }}";
+ });
+
+ // Toggle raw configuration display
+ function toggleRawConfig() {
+ const rawConfig = document.getElementById('raw-config');
+ const toggleText = document.getElementById('toggle-text');
+ if (rawConfig.style.display === 'none') {
+ rawConfig.style.display = 'block';
+ toggleText.textContent = 'Hide Raw Configuration';
+ } else {
+ rawConfig.style.display = 'none';
+ toggleText.textContent = 'Show Raw Configuration';
+ }
+ }
+ function saveRawConfig() {
+ const rawConfig = document.getElementById('raw_config_editor').value;
+
+ fetch('{{ url_for("research.save_raw_config") }}', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ raw_config: rawConfig }),
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ alert('Configuration saved successfully. You may need to restart the application for changes to take effect.');
+ } else {
+ alert('Error saving configuration: ' + data.error);
+ }
+ })
+ .catch(error => {
+ alert('Error saving configuration: ' + error);
+ });
+}
+ </script>
+</body>
+</html>
\ No newline at end of file