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: Address djpetti's review feedback

LearningCircuit1894891cb9a7
diff --git a/pdm.lock b/pdm.lock
index ef277da9dc..9633f2471c 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -5,7 +5,7 @@
groups = ["default", "dev"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
-content_hash = "sha256:0db686598bdfe4eab556110abf733b5703ed15cbaf032ce944a80c9a4ace2e36"
+content_hash = "sha256:04774fc01850d6a8cbd868f89a3de0d761f5f6df6d3f3693c7bda790a4241876"
[[metadata.targets]]
requires_python = ">=3.11,<3.15"
@@ -185,7 +185,7 @@ files = [
[[package]]
name = "anthropic"
-version = "0.74.1"
+version = "0.75.0"
requires_python = ">=3.9"
summary = "The official Python library for the anthropic API"
groups = ["default"]
@@ -200,8 +200,8 @@ dependencies = [
"typing-extensions<5,>=4.10",
]
files = [
- {file = "anthropic-0.74.1-py3-none-any.whl", hash = "sha256:b07b998d1cee7f41d9f02530597d7411672b362cc2417760a40c0167b81c6e65"},
- {file = "anthropic-0.74.1.tar.gz", hash = "sha256:04c087b2751385c524f6d332d066a913870e4de8b3e335fb0a0c595f1f88dc6e"},
+ {file = "anthropic-0.75.0-py3-none-any.whl", hash = "sha256:ea8317271b6c15d80225a9f3c670152746e88805a7a61e14d4a374577164965b"},
+ {file = "anthropic-0.75.0.tar.gz", hash = "sha256:e8607422f4ab616db2ea5baacc215dd5f028da99ce2f022e33c7c535b29f3dfb"},
]
[[package]]
@@ -1302,6 +1302,21 @@ files = [
{file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"},
]
+[[package]]
+name = "deprecated"
+version = "1.3.1"
+requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
+summary = "Python @deprecated decorator to deprecate old python classes, functions or methods."
+groups = ["default"]
+dependencies = [
+ "inspect2; python_version < \"3\"",
+ "wrapt<3,>=1.10",
+]
+files = [
+ {file = "deprecated-1.3.1-py2.py3-none-any.whl", hash = "sha256:597bfef186b6f60181535a29fbe44865ce137a5079f295b479886c82729d5f3f"},
+ {file = "deprecated-1.3.1.tar.gz", hash = "sha256:b1b50e0ff0c1fddaa5708a2c6b0a6588bb09b892825ab2b214ac9ea9d92a5223"},
+]
+
[[package]]
name = "dill"
version = "0.4.0"
@@ -1551,6 +1566,24 @@ files = [
{file = "flask_cors-6.0.1.tar.gz", hash = "sha256:d81bcb31f07b0985be7f48406247e9243aced229b7747219160a0559edd678db"},
]
+[[package]]
+name = "flask-limiter"
+version = "4.0.0"
+requires_python = ">=3.10"
+summary = "Rate limiting for flask applications"
+groups = ["default"]
+dependencies = [
+ "flask>=2",
+ "limits>=3.13",
+ "ordered-set<5,>4",
+ "rich<15,>=12",
+ "typing-extensions>=4.3",
+]
+files = [
+ {file = "flask_limiter-4.0.0-py3-none-any.whl", hash = "sha256:be62b462d5a052d21572d4c932e18a8da58cf9ddc18a34b6f1c21fa2ec35a395"},
+ {file = "flask_limiter-4.0.0.tar.gz", hash = "sha256:536a8df0bb2033f415a2212e19a3b7ddfea38585ac5a2444e1cfa986a697847c"},
+]
+
[[package]]
name = "flask-login"
version = "0.6.3"
@@ -2942,7 +2975,7 @@ files = [
[[package]]
name = "langgraph"
-version = "1.0.3"
+version = "1.0.4"
requires_python = ">=3.10"
summary = "Building stateful, multi-actor applications with LLMs"
groups = ["default"]
@@ -2955,8 +2988,8 @@ dependencies = [
"xxhash>=3.5.0",
]
files = [
- {file = "langgraph-1.0.3-py3-none-any.whl", hash = "sha256:4a75146f09bd0d127a724876f4244f460c4c66353a993641bd641ed710cd010f"},
- {file = "langgraph-1.0.3.tar.gz", hash = "sha256:873a6aae6be054ef52a05c463be363a46da9711405b1b14454d595f543b68335"},
+ {file = "langgraph-1.0.4-py3-none-any.whl", hash = "sha256:b1a835ceb0a8d69b9db48075e1939e28b1ad70ee23fa3fa8f90149904778bacf"},
+ {file = "langgraph-1.0.4.tar.gz", hash = "sha256:86d08e25d7244340f59c5200fa69fdd11066aa999b3164b531e2a20036fac156"},
]
[[package]]
@@ -2991,8 +3024,8 @@ files = [
[[package]]
name = "langgraph-sdk"
-version = "0.2.9"
-requires_python = ">=3.9"
+version = "0.2.10"
+requires_python = ">=3.10"
summary = "SDK for interacting with LangGraph API"
groups = ["default"]
dependencies = [
@@ -3000,13 +3033,13 @@ dependencies = [
"orjson>=3.10.1",
]
files = [
- {file = "langgraph_sdk-0.2.9-py3-none-any.whl", hash = "sha256:fbf302edadbf0fb343596f91c597794e936ef68eebc0d3e1d358b6f9f72a1429"},
- {file = "langgraph_sdk-0.2.9.tar.gz", hash = "sha256:b3bd04c6be4fa382996cd2be8fbc1e7cc94857d2bc6b6f4599a7f2a245975303"},
+ {file = "langgraph_sdk-0.2.10-py3-none-any.whl", hash = "sha256:9aef403663726085de6851e4e50459df9562069bd316dd0261eb359f776fd0ef"},
+ {file = "langgraph_sdk-0.2.10.tar.gz", hash = "sha256:ab58331504fbea28e6322037aa362929799b4e9106663ac1dbd7c5ac44558933"},
]
[[package]]
name = "langsmith"
-version = "0.4.46"
+version = "0.4.49"
requires_python = ">=3.10"
summary = "Client library to connect to the LangSmith Observability and Evaluation Platform."
groups = ["default"]
@@ -3020,8 +3053,8 @@ dependencies = [
"zstandard>=0.23.0",
]
files = [
- {file = "langsmith-0.4.46-py3-none-any.whl", hash = "sha256:783c16ef108c42a16ec2d8bc68067b969f3652e2fe82ca1289007baf947e4500"},
- {file = "langsmith-0.4.46.tar.gz", hash = "sha256:0b73d47ebd0a27ea10edec1717f36f6a865cb9ffc7f4e6a419e2cea1ab3c5b1e"},
+ {file = "langsmith-0.4.49-py3-none-any.whl", hash = "sha256:95f84edcd8e74ed658e4a3eb7355b530f35cb08a9a8865dbfde6740e4b18323c"},
+ {file = "langsmith-0.4.49.tar.gz", hash = "sha256:4a16ef6f3a9b20c5471884991a12ff37d81f2c13a50660cfe27fa79a7ca2c1b0"},
]
[[package]]
@@ -3035,6 +3068,22 @@ files = [
{file = "lark-1.3.1.tar.gz", hash = "sha256:b426a7a6d6d53189d318f2b6236ab5d6429eaf09259f1ca33eb716eed10d2905"},
]
+[[package]]
+name = "limits"
+version = "5.6.0"
+requires_python = ">=3.10"
+summary = "Rate limiting utilities"
+groups = ["default"]
+dependencies = [
+ "deprecated>=1.2",
+ "packaging>=21",
+ "typing-extensions",
+]
+files = [
+ {file = "limits-5.6.0-py3-none-any.whl", hash = "sha256:b585c2104274528536a5b68864ec3835602b3c4a802cd6aa0b07419798394021"},
+ {file = "limits-5.6.0.tar.gz", hash = "sha256:807fac75755e73912e894fdd61e2838de574c5721876a19f7ab454ae1fffb4b5"},
+]
+
[[package]]
name = "logistro"
version = "2.0.1"
@@ -3879,13 +3928,13 @@ files = [
[[package]]
name = "networkx"
-version = "3.5"
+version = "3.6"
requires_python = ">=3.11"
summary = "Python package for creating and manipulating graphs and networks"
groups = ["default"]
files = [
- {file = "networkx-3.5-py3-none-any.whl", hash = "sha256:0030d386a9a06dee3565298b4a734b68589749a544acbb6c412dc9e2489ec6ec"},
- {file = "networkx-3.5.tar.gz", hash = "sha256:d4c6f9cf81f52d69230866796b82afbccdec3db7ae4fbd1b65ea750feed50037"},
+ {file = "networkx-3.6-py3-none-any.whl", hash = "sha256:cdb395b105806062473d3be36458d8f1459a4e4b98e236a66c3a48996e07684f"},
+ {file = "networkx-3.6.tar.gz", hash = "sha256:285276002ad1f7f7da0f7b42f004bcba70d381e936559166363707fdad3d72ad"},
]
[[package]]
@@ -4109,6 +4158,17 @@ files = [
{file = "optuna-4.6.0.tar.gz", hash = "sha256:89e38c2447c7f793a726617b8043f01e31f0bad54855040db17eb3b49404a369"},
]
+[[package]]
+name = "ordered-set"
+version = "4.1.0"
+requires_python = ">=3.7"
+summary = "An OrderedSet is a custom MutableSet that remembers its order, so that every"
+groups = ["default"]
+files = [
+ {file = "ordered-set-4.1.0.tar.gz", hash = "sha256:694a8e44c87657c59292ede72891eb91d34131f6531463aab3009191c77364a8"},
+ {file = "ordered_set-4.1.0-py3-none-any.whl", hash = "sha256:046e1132c71fcf3330438a539928932caf51ddbc582496833e23de611de14562"},
+]
+
[[package]]
name = "orjson"
version = "3.11.4"
@@ -4814,7 +4874,7 @@ files = [
[[package]]
name = "pydantic"
-version = "2.12.4"
+version = "2.12.5"
requires_python = ">=3.9"
summary = "Data validation using Python type hints"
groups = ["default"]
@@ -4825,8 +4885,8 @@ dependencies = [
"typing-inspection>=0.4.2",
]
files = [
- {file = "pydantic-2.12.4-py3-none-any.whl", hash = "sha256:92d3d202a745d46f9be6df459ac5a064fdaa3c1c4cd8adcfa332ccf3c05f871e"},
- {file = "pydantic-2.12.4.tar.gz", hash = "sha256:0f8cb9555000a4b5b617f66bfd2566264c4984b27589d3b845685983e8ea85ac"},
+ {file = "pydantic-2.12.5-py3-none-any.whl", hash = "sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d"},
+ {file = "pydantic-2.12.5.tar.gz", hash = "sha256:4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49"},
]
[[package]]
@@ -6483,7 +6543,7 @@ files = [
[[package]]
name = "transformers"
-version = "4.57.1"
+version = "4.57.3"
requires_python = ">=3.9.0"
summary = "State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow"
groups = ["default"]
@@ -6500,8 +6560,8 @@ dependencies = [
"tqdm>=4.27",
]
files = [
- {file = "transformers-4.57.1-py3-none-any.whl", hash = "sha256:b10d05da8fa67dc41644dbbf9bc45a44cb86ae33da6f9295f5fbf5b7890bd267"},
- {file = "transformers-4.57.1.tar.gz", hash = "sha256:f06c837959196c75039809636cd964b959f6604b75b8eeec6fdfc0440b89cc55"},
+ {file = "transformers-4.57.3-py3-none-any.whl", hash = "sha256:c77d353a4851b1880191603d36acb313411d3577f6e2897814f333841f7003f4"},
+ {file = "transformers-4.57.3.tar.gz", hash = "sha256:df4945029aaddd7c09eec5cad851f30662f8bd1746721b34cc031d70c65afebc"},
]
[[package]]
diff --git a/src/local_deep_research/security/file_upload_validator.py b/src/local_deep_research/security/file_upload_validator.py
index 56c3eec14f..a9a33bfdb6 100644
--- a/src/local_deep_research/security/file_upload_validator.py
+++ b/src/local_deep_research/security/file_upload_validator.py
@@ -19,7 +19,7 @@ class FileUploadValidator:
"""Centralized file upload validation for security."""
# Security constants
- MAX_FILE_SIZE = 10 * 1024 * 1024 # 10MB per file
+ MAX_FILE_SIZE = 50 * 1024 * 1024 # 50MB per file
MAX_FILES_PER_REQUEST = 100 # Maximum number of files in single request
PDF_MAGIC_BYTES = b"%PDF" # PDF file signature
ALLOWED_MIME_TYPES = {"application/pdf"}
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.py
index f19c0483ec..6380196fdb 100644
--- a/src/local_deep_research/web/app_factory.py
+++ b/src/local_deep_research/web/app_factory.py
@@ -15,6 +15,7 @@ from local_deep_research.settings.logger import log_settings
from ..utilities.log_utils import InterceptHandler
from ..security import SecurityHeaders
+from ..security.file_upload_validator import FileUploadValidator
# Removed DB_PATH import - using per-user databases now
from .services.socket_service import SocketIOService
@@ -94,9 +95,11 @@ def create_app():
app.config["PERMANENT_SESSION_LIFETIME"] = 7200 # 2 hours in seconds
app.config["PREFERRED_URL_SCHEME"] = "https"
- # File upload security limits
- # 100 files * 10MB = 1GB max total request size
- app.config["MAX_CONTENT_LENGTH"] = 100 * 10 * 1024 * 1024 # 1GB max request
+ # File upload security limits - calculated from FileUploadValidator constants
+ app.config["MAX_CONTENT_LENGTH"] = (
+ FileUploadValidator.MAX_FILES_PER_REQUEST
+ * FileUploadValidator.MAX_FILE_SIZE
+ )
# Initialize CSRF protection
CSRFProtect(app)
diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.py
index cd1a18815b..2ab35ca986 100644
--- a/src/local_deep_research/web/routes/research_routes.py
+++ b/src/local_deep_research/web/routes/research_routes.py
@@ -1501,7 +1501,7 @@ def upload_pdf():
Security features:
- Rate limiting (10 uploads/min, 100/hour per user)
- - File size validation (10MB max per file)
+ - File size validation (50MB max per file)
- File count validation (100 files max)
- PDF structure validation
- MIME type validation
@@ -1517,7 +1517,10 @@ def upload_pdf():
try:
# Early request size validation (before reading any files)
# This prevents memory exhaustion from chunked encoding attacks
- max_request_size = 100 * 10 * 1024 * 1024 # 1GB (100 files * 10MB)
+ max_request_size = (
+ FileUploadValidator.MAX_FILES_PER_REQUEST
+ * FileUploadValidator.MAX_FILE_SIZE
+ )
if request.content_length and request.content_length > max_request_size:
return jsonify(
{
diff --git a/src/local_deep_research/web/static/js/pdf_upload_handler.js b/src/local_deep_research/web/static/js/pdf_upload_handler.js
index 11731db370..fa16426eea 100644
--- a/src/local_deep_research/web/static/js/pdf_upload_handler.js
+++ b/src/local_deep_research/web/static/js/pdf_upload_handler.js
@@ -9,7 +9,7 @@ class PDFUploadHandler {
this.queryTextarea = null;
this.isDragOver = false;
this.uploadedPDFs = [];
- this.maxFileSize = 10 * 1024 * 1024; // 10MB limit
+ this.maxFileSize = 50 * 1024 * 1024; // 50MB limit
this.maxFiles = 100; // Maximum 100 PDFs at once
this.statusTimers = []; // Track setTimeout IDs to prevent timer leaks
this.init();
diff --git a/tests/pdf_tests/test_file_validator.py b/tests/pdf_tests/test_file_validator.py
index c8ca23d53e..30517a2b1b 100644
--- a/tests/pdf_tests/test_file_validator.py
+++ b/tests/pdf_tests/test_file_validator.py
@@ -37,7 +37,7 @@ class TestValidateFileSize:
def test_oversized_via_content_length(self):
"""Test that oversized file is rejected via Content-Length."""
is_valid, error = FileUploadValidator.validate_file_size(
- content_length=11 * 1024 * 1024 # 11MB
+ content_length=51 * 1024 * 1024 # 51MB (over 50MB limit)
)
assert is_valid is False
assert error is not None
@@ -45,7 +45,7 @@ class TestValidateFileSize:
def test_oversized_via_file_content(self):
"""Test that oversized file is rejected via actual content."""
- content = b"x" * (11 * 1024 * 1024) # 11MB
+ content = b"x" * (51 * 1024 * 1024) # 51MB (over 50MB limit)
is_valid, error = FileUploadValidator.validate_file_size(
content_length=None, file_content=content
)
@@ -233,7 +233,9 @@ class TestValidateUpload:
def test_all_validations_run(self):
"""Test that all validations are executed."""
# Invalid size should fail first
- large_content = b"%PDF-1.4\n" + (b"x" * (11 * 1024 * 1024))
+ large_content = b"%PDF-1.4\n" + (
+ b"x" * (51 * 1024 * 1024)
+ ) # 51MB (over 50MB limit)
is_valid, error = FileUploadValidator.validate_upload(
filename="test.pdf",
file_content=large_content,
@@ -254,7 +256,7 @@ class TestValidateUpload:
def test_returns_first_error(self):
"""Test that first validation error stops processing."""
# Large file with wrong extension - should fail on size first
- large_content = b"x" * (11 * 1024 * 1024)
+ large_content = b"x" * (51 * 1024 * 1024) # 51MB (over 50MB limit)
is_valid, error = FileUploadValidator.validate_upload(
filename="test.txt",
file_content=large_content,
@@ -267,9 +269,9 @@ class TestValidateUpload:
class TestConstants:
"""Tests for class constants."""
- def test_max_file_size_is_10mb(self):
- """Verify MAX_FILE_SIZE is 10MB."""
- expected = 10 * 1024 * 1024
+ def test_max_file_size_is_50mb(self):
+ """Verify MAX_FILE_SIZE is 50MB."""
+ expected = 50 * 1024 * 1024
assert FileUploadValidator.MAX_FILE_SIZE == expected
def test_max_files_is_100(self):