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.

fix(llm): remove broken llamacpp HTTP mode, guide users to openai_endpoint

LearningCircuit7d8d16fc7145
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index c6ec8d200f..8df498fa95 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -178,12 +178,17 @@ def is_lmstudio_available(settings_snapshot=None):
def is_llamacpp_available(settings_snapshot=None):
- """Check if LlamaCpp is available and configured"""
+ """Check if LlamaCpp is available and properly configured.
+
+ This checks both HTTP mode (server URL configured) and local mode
+ (model path configured and looks like a file).
+ """
try:
# Import check
from langchain_community.llms import LlamaCpp # noqa: F401
- # Get the configured model path
+ # Check if model path is configured and looks valid
+ # Note: For llama.cpp server connections, use 'openai_endpoint' provider instead
model_path_str = get_setting_from_snapshot(
"llm.llamacpp_model_path",
default=None,
@@ -194,14 +199,16 @@ def is_llamacpp_available(settings_snapshot=None):
if not model_path_str:
return False
- # Security Note: Path validation is critical here
- # CodeQL may flag filesystem operations with user input
- # We validate paths are within allowed directories before any filesystem access
+ # Check if it looks like a file path (has an extension)
+ # This helps avoid accepting directories as valid
+ from pathlib import Path
- # For security, we simply check if a path is configured
- # The actual path validation will happen when the model is loaded
- # This avoids CodeQL alerts about filesystem access with user input
- # The LlamaCpp library itself will validate the path when loading
+ path = Path(model_path_str)
+ # Has extension = likely a file path
+ if path.suffix:
+ return True
+ # No extension but not a known directory pattern
+ # Could still be valid, let the actual validation handle it
return True
except ImportError:
@@ -862,74 +869,85 @@ def get_llm(
# Import LlamaCpp
from langchain_community.llms import LlamaCpp
- # Get LlamaCpp connection mode from settings
- connection_mode = get_setting_from_snapshot(
- "llm.llamacpp_connection_mode",
- "local",
- settings_snapshot=settings_snapshot,
+ # Note: For llama.cpp server connections, use 'openai_endpoint' provider
+ # with the server's /v1 URL (e.g., 'http://localhost:8000/v1')
+
+ # Get LlamaCpp model path from settings
+ model_path = get_setting_from_snapshot(
+ "llm.llamacpp_model_path", settings_snapshot=settings_snapshot
)
+ if not model_path:
+ logger.error("llamacpp_model_path not set in settings")
+ raise ValueError(
+ "LlamaCpp model path not configured. Either:\n"
+ "1. Set 'llm.llamacpp_model_path' to your .gguf file path, or\n"
+ "2. For llama.cpp server connections, use 'openai_endpoint' provider "
+ "with the server's /v1 endpoint (e.g., 'http://localhost:8000/v1')"
+ )
- if connection_mode == "http":
- # Use HTTP client mode
- from langchain_community.llms.llamacpp_client import LlamaCppClient
+ # Pre-validate path with helpful messages before security validation
+ from pathlib import Path as PathLib
- server_url = get_setting_from_snapshot(
- "llm.llamacpp_server_url",
- "http://localhost:8000",
- settings_snapshot=settings_snapshot,
- )
+ raw_path = PathLib(model_path)
- llm = LlamaCppClient(
- server_url=server_url,
- temperature=temperature,
- max_tokens=get_setting_from_snapshot(
- "llm.max_tokens", 8192, settings_snapshot=settings_snapshot
- ),
+ # Check if path is a directory instead of a file
+ if raw_path.is_dir():
+ # List .gguf files in directory if any
+ gguf_files = list(raw_path.glob("*.gguf"))
+ if gguf_files:
+ files_list = ", ".join(f.name for f in gguf_files[:5])
+ if len(gguf_files) > 5:
+ files_list += f" (and {len(gguf_files) - 5} more)"
+ suggestion = f"Found .gguf files: {files_list}"
+ else:
+ suggestion = "No .gguf files found in this directory"
+ raise ValueError(
+ f"Model path is a directory, not a file: {model_path}\n"
+ f"Please specify the full path to a .gguf model file.\n"
+ f"{suggestion}"
)
- else:
- # Use direct model loading (existing code)
- # Get LlamaCpp model path from settings
- model_path = get_setting_from_snapshot(
- "llm.llamacpp_model_path", settings_snapshot=settings_snapshot
+
+ # Check for .gguf extension (warning only, don't block)
+ if raw_path.suffix.lower() not in (".gguf", ".bin"):
+ logger.warning(
+ f"Model file does not have .gguf extension: {raw_path.suffix}. "
+ "LlamaCpp typically expects .gguf files."
)
- if not model_path:
- logger.error("llamacpp_model_path not set in settings")
- raise ValueError("llamacpp_model_path not set in settings")
- # Validate model path for security using centralized validator
- from ..security.path_validator import PathValidator
+ # Validate model path for security using centralized validator
+ from ..security.path_validator import PathValidator
- try:
- validated_path = PathValidator.validate_model_path(model_path)
- model_path = str(validated_path)
- except ValueError:
- logger.exception("Model path validation failed")
- raise
-
- # Get additional LlamaCpp parameters
- n_gpu_layers = get_setting_from_snapshot(
- "llm.llamacpp_n_gpu_layers",
- 1,
- settings_snapshot=settings_snapshot,
- )
- n_batch = get_setting_from_snapshot(
- "llm.llamacpp_n_batch", 512, settings_snapshot=settings_snapshot
- )
- f16_kv = get_setting_from_snapshot(
- "llm.llamacpp_f16_kv", True, settings_snapshot=settings_snapshot
- )
+ try:
+ validated_path = PathValidator.validate_model_path(model_path)
+ model_path = str(validated_path)
+ except ValueError:
+ logger.exception("Model path validation failed")
+ raise
+
+ # Get additional LlamaCpp parameters
+ n_gpu_layers = get_setting_from_snapshot(
+ "llm.llamacpp_n_gpu_layers",
+ 1,
+ settings_snapshot=settings_snapshot,
+ )
+ n_batch = get_setting_from_snapshot(
+ "llm.llamacpp_n_batch", 512, settings_snapshot=settings_snapshot
+ )
+ f16_kv = get_setting_from_snapshot(
+ "llm.llamacpp_f16_kv", True, settings_snapshot=settings_snapshot
+ )
- # Create LlamaCpp instance
- llm = LlamaCpp(
- model_path=model_path,
- temperature=temperature,
- max_tokens=max_tokens, # Use calculated max_tokens
- n_gpu_layers=n_gpu_layers,
- n_batch=n_batch,
- f16_kv=f16_kv,
- n_ctx=context_window_size, # Set context window size directly (None = use default)
- verbose=True,
- )
+ # Create LlamaCpp instance
+ llm = LlamaCpp(
+ model_path=model_path,
+ temperature=temperature,
+ max_tokens=max_tokens, # Use calculated max_tokens
+ n_gpu_layers=n_gpu_layers,
+ n_batch=n_batch,
+ f16_kv=f16_kv,
+ n_ctx=context_window_size, # Set context window size directly (None = use default)
+ verbose=True,
+ )
return wrap_llm_without_think_tags(
llm,
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index cd4991f3d0..f11cbcafa1 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -276,7 +276,7 @@
},
"llm.llamacpp_model_path": {
"category": null,
- "description": "Absolute file path to the GGUF model file for LlamaCpp. Required when using local model loading mode (llm.llamacpp_connection_mode='local').",
+ "description": "Absolute file path to the GGUF model file for LlamaCpp. For llama.cpp server connections, use 'openai_endpoint' provider instead with the server's /v1 URL.",
"editable": true,
"max_value": null,
"min_value": null,
@@ -4908,43 +4908,6 @@
"value": false,
"visible": true
},
- "llm.llamacpp_connection_mode": {
- "category": "llm_parameters",
- "description": "Connection mode for LlamaCpp: 'local' for direct model loading or 'http' for using a remote server",
- "editable": true,
- "max_value": null,
- "min_value": null,
- "name": "LlamaCpp Connection Mode",
- "options": [
- {
- "label": "Local Model",
- "value": "local"
- },
- {
- "label": "HTTP Server",
- "value": "http"
- }
- ],
- "step": null,
- "type": "LLM",
- "ui_element": "select",
- "value": "local",
- "visible": true
- },
- "llm.llamacpp_server_url": {
- "category": "llm_parameters",
- "description": "URL of the LlamaCpp HTTP server (only used when connection mode is 'http')",
- "editable": true,
- "max_value": null,
- "min_value": null,
- "name": "LlamaCpp Server URL",
- "options": null,
- "step": null,
- "type": "LLM",
- "ui_element": "text",
- "value": "http://localhost:8000",
- "visible": true
- },
"app.warnings.dismiss_high_context": {
"category": "warnings",
"description": "Dismiss warnings about high context window sizes that may cause memory issues",
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index 3a925e6967..6eb44cb988 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -596,10 +596,32 @@ def run_research_process(
logger.info(
f"Successfully set LLM to: provider={model_provider}, model={model}"
)
- except Exception:
+ except Exception as e:
logger.exception(
f"Error setting LLM provider={model_provider}, model={model}"
)
+ error_msg = str(e)
+ # Surface configuration errors to user instead of silently continuing
+ config_error_keywords = [
+ "model path",
+ "llamacpp",
+ "cannot connect",
+ "server",
+ "not configured",
+ "not responding",
+ "directory",
+ ".gguf",
+ ]
+ if any(
+ keyword in error_msg.lower()
+ for keyword in config_error_keywords
+ ):
+ # This is a configuration error the user can fix
+ raise ValueError(
+ f"LLM Configuration Error: {error_msg}"
+ ) from e
+ # For other errors, re-raise to avoid silent failures
+ raise
# Create search engine first if specified, to avoid default creation without username
use_search = None
@@ -615,10 +637,31 @@ def run_research_process(
logger.info(
f"Successfully created search engine: {search_engine}"
)
- except Exception:
+ except Exception as e:
logger.exception(
f"Error creating search engine {search_engine}"
)
+ error_msg = str(e)
+ # Surface configuration errors to user instead of silently continuing
+ config_error_keywords = [
+ "searxng",
+ "instance_url",
+ "api_key",
+ "cannot connect",
+ "connection",
+ "timeout",
+ "not configured",
+ ]
+ if any(
+ keyword in error_msg.lower()
+ for keyword in config_error_keywords
+ ):
+ # This is a configuration error the user can fix
+ raise ValueError(
+ f"Search Engine Configuration Error ({search_engine}): {error_msg}"
+ ) from e
+ # For other errors, re-raise to avoid silent failures
+ raise
# Set the progress callback in the system
system = AdvancedSearchSystem(