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.

llama.cpp server support

LearningCircuita9824681202b
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index 8bab9363e0..0db2eb86a4 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -215,31 +215,62 @@ def get_llm(model_name=None, temperature=None, provider=None, openai_endpoint_ur
)
return wrap_llm_without_think_tags(llm)
+ # Update the llamacpp section in get_llm function
elif provider == "llamacpp":
# Import LlamaCpp
from langchain_community.llms import LlamaCpp
- # Get LlamaCpp model path from settings
- model_path = get_db_setting("llm.llamacpp_model_path")
- if not model_path:
- logger.error("llamacpp_model_path not set in settings")
- raise ValueError("llamacpp_model_path not set in settings")
-
- # Get additional LlamaCpp parameters
- n_gpu_layers = get_db_setting("llm.llamacpp_n_gpu_layers", 1)
- n_batch = get_db_setting("llm.llamacpp_n_batch", 512)
- f16_kv = get_db_setting("llm.llamacpp_f16_kv", True)
-
- # Create LlamaCpp instance
- llm = LlamaCpp(
- model_path=model_path,
- temperature=temperature,
- max_tokens=get_db_setting("llm.max_tokens", 30000),
- n_gpu_layers=n_gpu_layers,
- n_batch=n_batch,
- f16_kv=f16_kv,
- verbose=True,
- )
+ # Get LlamaCpp connection mode from settings
+ connection_mode = get_db_setting("llm.llamacpp_connection_mode", "local")
+
+ if connection_mode == "http":
+ # Use HTTP client mode
+ from langchain_community.llms.llamacpp_client import LlamaCppClient
+
+ server_url = get_db_setting(
+ "llm.llamacpp_server_url", "http://localhost:8000"
+ )
+
+ llm = LlamaCppClient(
+ server_url=server_url,
+ temperature=temperature,
+ max_tokens=get_db_setting("llm.max_tokens", 30000),
+ )
+ else:
+ # Use direct model loading (existing code)
+ # Get LlamaCpp model path from settings
+ model_path = get_db_setting("llm.llamacpp_model_path")
+ if not model_path:
+ logger.error("llamacpp_model_path not set in settings")
+ raise ValueError("llamacpp_model_path not set in settings")
+
+ # Get additional LlamaCpp parameters
+ n_gpu_layers = get_db_setting("llm.llamacpp_n_gpu_layers", 1)
+ n_batch = get_db_setting("llm.llamacpp_n_batch", 512)
+ f16_kv = get_db_setting("llm.llamacpp_f16_kv", True)
+
+ # Set up callbacks for streaming if enabled
+ callbacks = None
+ if get_db_setting("llm.llamacpp_streaming", False):
+ from langchain_core.callbacks.manager import CallbackManager
+ from langchain_core.callbacks.streaming_stdout import (
+ StreamingStdOutCallbackHandler,
+ )
+
+ callbacks = CallbackManager([StreamingStdOutCallbackHandler()])
+
+ # Create LlamaCpp instance
+ llm = LlamaCpp(
+ model_path=model_path,
+ temperature=temperature,
+ max_tokens=get_db_setting("llm.max_tokens", 30000),
+ n_gpu_layers=n_gpu_layers,
+ n_batch=n_batch,
+ f16_kv=f16_kv,
+ verbose=True,
+ callback_manager=callbacks,
+ )
+
return wrap_llm_without_think_tags(llm)
else:
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index 96d71bef20..e462fb5c26 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -3992,5 +3992,56 @@
"ui_element": "checkbox",
"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
+ },
+ "llm.llamacpp_streaming": {
+ "category": "llm_parameters",
+ "description": "Enable streaming output for LlamaCpp (local mode only)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "LlamaCpp Streaming",
+ "options": null,
+ "step": null,
+ "type": "LLM",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
}
}