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 pre-commit hook errors and CSS class naming issues

LearningCircuitc1334db4c370
diff --git a/pdm.lock b/pdm.lock
index ee8375585c..447756d404 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:b9aa1d52fc1c168dcfae477a1609552a263bfecdb127ef88a87ced2f6d38d90f"
+content_hash = "sha256:4a620355a265be4d0bd568f8eeb740079de4140d53302c04726153c15d7bbdde"
[[metadata.targets]]
requires_python = ">=3.11"
@@ -1138,6 +1138,33 @@ files = [
{file = "dataclasses_json-0.6.7.tar.gz", hash = "sha256:b6b3e528266ea45b9535223bc53ca645f5208833c29229e847b3f26a1cc55fc0"},
]
+[[package]]
+name = "datasets"
+version = "4.2.0"
+requires_python = ">=3.9.0"
+summary = "HuggingFace community-driven open-source library of datasets"
+groups = ["default"]
+dependencies = [
+ "dill<0.4.1,>=0.3.0",
+ "filelock",
+ "fsspec[http]<=2025.9.0,>=2023.1.0",
+ "httpx<1.0.0",
+ "huggingface-hub<2.0,>=0.25.0",
+ "multiprocess<0.70.17",
+ "numpy>=1.17",
+ "packaging",
+ "pandas",
+ "pyarrow>=21.0.0",
+ "pyyaml>=5.1",
+ "requests>=2.32.2",
+ "tqdm>=4.66.3",
+ "xxhash",
+]
+files = [
+ {file = "datasets-4.2.0-py3-none-any.whl", hash = "sha256:fdc43aaf4a73b31f64f80f72f195ab413a1141ed15555d675b2fd17926f8b026"},
+ {file = "datasets-4.2.0.tar.gz", hash = "sha256:8333a7db9f3bb8044c1b819a35d4e3e2809596c837793b0921382efffdc36e78"},
+]
+
[[package]]
name = "debugpy"
version = "1.8.17"
@@ -1187,6 +1214,17 @@ files = [
{file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"},
]
+[[package]]
+name = "dill"
+version = "0.4.0"
+requires_python = ">=3.8"
+summary = "serialize all of Python"
+groups = ["default"]
+files = [
+ {file = "dill-0.4.0-py3-none-any.whl", hash = "sha256:44f54bf6412c2c8464c14e8243eb163690a9800dbe2c367330883b19c7561049"},
+ {file = "dill-0.4.0.tar.gz", hash = "sha256:0633f1d2df477324f53a895b02c901fb961bdbf65a17122586ea7019292cbcf0"},
+]
+
[[package]]
name = "distlib"
version = "0.4.0"
@@ -1703,6 +1741,22 @@ files = [
{file = "fsspec-2025.9.0.tar.gz", hash = "sha256:19fd429483d25d28b65ec68f9f4adc16c17ea2c7c7bf54ec61360d478fb19c19"},
]
+[[package]]
+name = "fsspec"
+version = "2025.9.0"
+extras = ["http"]
+requires_python = ">=3.9"
+summary = "File-system specification"
+groups = ["default"]
+dependencies = [
+ "aiohttp!=4.0.0a0,!=4.0.0a1",
+ "fsspec==2025.9.0",
+]
+files = [
+ {file = "fsspec-2025.9.0-py3-none-any.whl", hash = "sha256:530dc2a2af60a414a832059574df4a6e10cce927f6f4a78209390fe38955cfb7"},
+ {file = "fsspec-2025.9.0.tar.gz", hash = "sha256:19fd429483d25d28b65ec68f9f4adc16c17ea2c7c7bf54ec61360d478fb19c19"},
+]
+
[[package]]
name = "google-search-results"
version = "2.4.2"
@@ -3364,6 +3418,21 @@ files = [
{file = "multidict-6.6.4.tar.gz", hash = "sha256:d2d4e4787672911b48350df02ed3fa3fffdc2f2e8ca06dd6afdf34189b76a9dd"},
]
+[[package]]
+name = "multiprocess"
+version = "0.70.16"
+requires_python = ">=3.8"
+summary = "better multiprocessing and multithreading in Python"
+groups = ["default"]
+dependencies = [
+ "dill>=0.3.8",
+]
+files = [
+ {file = "multiprocess-0.70.16-py311-none-any.whl", hash = "sha256:af4cabb0dac72abfb1e794fa7855c325fd2b55a10a44628a3c1ad3311c04127a"},
+ {file = "multiprocess-0.70.16-py312-none-any.whl", hash = "sha256:fc0544c531920dde3b00c29863377f87e1632601092ea2daca74e4beb40faa2e"},
+ {file = "multiprocess-0.70.16.tar.gz", hash = "sha256:161af703d4652a0e1410be6abccecde4a7ddffd19341be0a7011b94aeb171ac1"},
+]
+
[[package]]
name = "mypy-extensions"
version = "1.1.0"
@@ -4217,6 +4286,44 @@ files = [
{file = "pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42"},
]
+[[package]]
+name = "pyarrow"
+version = "21.0.0"
+requires_python = ">=3.9"
+summary = "Python library for Apache Arrow"
+groups = ["default"]
+files = [
+ {file = "pyarrow-21.0.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:c077f48aab61738c237802836fc3844f85409a46015635198761b0d6a688f87b"},
+ {file = "pyarrow-21.0.0-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:689f448066781856237eca8d1975b98cace19b8dd2ab6145bf49475478bcaa10"},
+ {file = "pyarrow-21.0.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:479ee41399fcddc46159a551705b89c05f11e8b8cb8e968f7fec64f62d91985e"},
+ {file = "pyarrow-21.0.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:40ebfcb54a4f11bcde86bc586cbd0272bac0d516cfa539c799c2453768477569"},
+ {file = "pyarrow-21.0.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8d58d8497814274d3d20214fbb24abcad2f7e351474357d552a8d53bce70c70e"},
+ {file = "pyarrow-21.0.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:585e7224f21124dd57836b1530ac8f2df2afc43c861d7bf3d58a4870c42ae36c"},
+ {file = "pyarrow-21.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:555ca6935b2cbca2c0e932bedd853e9bc523098c39636de9ad4693b5b1df86d6"},
+ {file = "pyarrow-21.0.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:3a302f0e0963db37e0a24a70c56cf91a4faa0bca51c23812279ca2e23481fccd"},
+ {file = "pyarrow-21.0.0-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:b6b27cf01e243871390474a211a7922bfbe3bda21e39bc9160daf0da3fe48876"},
+ {file = "pyarrow-21.0.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:e72a8ec6b868e258a2cd2672d91f2860ad532d590ce94cdf7d5e7ec674ccf03d"},
+ {file = "pyarrow-21.0.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:b7ae0bbdc8c6674259b25bef5d2a1d6af5d39d7200c819cf99e07f7dfef1c51e"},
+ {file = "pyarrow-21.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:58c30a1729f82d201627c173d91bd431db88ea74dcaa3885855bc6203e433b82"},
+ {file = "pyarrow-21.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:072116f65604b822a7f22945a7a6e581cfa28e3454fdcc6939d4ff6090126623"},
+ {file = "pyarrow-21.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:cf56ec8b0a5c8c9d7021d6fd754e688104f9ebebf1bf4449613c9531f5346a18"},
+ {file = "pyarrow-21.0.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:e99310a4ebd4479bcd1964dff9e14af33746300cb014aa4a3781738ac63baf4a"},
+ {file = "pyarrow-21.0.0-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:d2fe8e7f3ce329a71b7ddd7498b3cfac0eeb200c2789bd840234f0dc271a8efe"},
+ {file = "pyarrow-21.0.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:f522e5709379d72fb3da7785aa489ff0bb87448a9dc5a75f45763a795a089ebd"},
+ {file = "pyarrow-21.0.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:69cbbdf0631396e9925e048cfa5bce4e8c3d3b41562bbd70c685a8eb53a91e61"},
+ {file = "pyarrow-21.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:731c7022587006b755d0bdb27626a1a3bb004bb56b11fb30d98b6c1b4718579d"},
+ {file = "pyarrow-21.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:dc56bc708f2d8ac71bd1dcb927e458c93cec10b98eb4120206a4091db7b67b99"},
+ {file = "pyarrow-21.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:186aa00bca62139f75b7de8420f745f2af12941595bbbfa7ed3870ff63e25636"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:a7a102574faa3f421141a64c10216e078df467ab9576684d5cd696952546e2da"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-macosx_12_0_x86_64.whl", hash = "sha256:1e005378c4a2c6db3ada3ad4c217b381f6c886f0a80d6a316fe586b90f77efd7"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:65f8e85f79031449ec8706b74504a316805217b35b6099155dd7e227eef0d4b6"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:3a81486adc665c7eb1a2bde0224cfca6ceaba344a82a971ef059678417880eb8"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:fc0d2f88b81dcf3ccf9a6ae17f89183762c8a94a5bdcfa09e05cfe413acf0503"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:6299449adf89df38537837487a4f8d3bd91ec94354fdd2a7d30bc11c48ef6e79"},
+ {file = "pyarrow-21.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:222c39e2c70113543982c6b34f3077962b44fca38c0bd9e68bb6781534425c10"},
+ {file = "pyarrow-21.0.0.tar.gz", hash = "sha256:5051f2dccf0e283ff56335760cbc8622cf52264d67e359d5569541ac11b6d5bc"},
+]
+
[[package]]
name = "pycparser"
version = "2.23"
@@ -6223,6 +6330,111 @@ files = [
{file = "xmltodict-1.0.2.tar.gz", hash = "sha256:54306780b7c2175a3967cad1db92f218207e5bc1aba697d887807c0fb68b7649"},
]
+[[package]]
+name = "xxhash"
+version = "3.6.0"
+requires_python = ">=3.7"
+summary = "Python binding for xxHash"
+groups = ["default"]
+files = [
+ {file = "xxhash-3.6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b47bbd8cf2d72797f3c2772eaaac0ded3d3af26481a26d7d7d41dc2d3c46b04a"},
+ {file = "xxhash-3.6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2b6821e94346f96db75abaa6e255706fb06ebd530899ed76d32cd99f20dc52fa"},
+ {file = "xxhash-3.6.0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:d0a9751f71a1a65ce3584e9cae4467651c7e70c9d31017fa57574583a4540248"},
+ {file = "xxhash-3.6.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8b29ee68625ab37b04c0b40c3fafdf24d2f75ccd778333cfb698f65f6c463f62"},
+ {file = "xxhash-3.6.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:6812c25fe0d6c36a46ccb002f40f27ac903bf18af9f6dd8f9669cb4d176ab18f"},
+ {file = "xxhash-3.6.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4ccbff013972390b51a18ef1255ef5ac125c92dc9143b2d1909f59abc765540e"},
+ {file = "xxhash-3.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:297b7fbf86c82c550e12e8fb71968b3f033d27b874276ba3624ea868c11165a8"},
+ {file = "xxhash-3.6.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:dea26ae1eb293db089798d3973a5fc928a18fdd97cc8801226fae705b02b14b0"},
+ {file = "xxhash-3.6.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:7a0b169aafb98f4284f73635a8e93f0735f9cbde17bd5ec332480484241aaa77"},
+ {file = "xxhash-3.6.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:08d45aef063a4531b785cd72de4887766d01dc8f362a515693df349fdb825e0c"},
+ {file = "xxhash-3.6.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:929142361a48ee07f09121fe9e96a84950e8d4df3bb298ca5d88061969f34d7b"},
+ {file = "xxhash-3.6.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:51312c768403d8540487dbbfb557454cfc55589bbde6424456951f7fcd4facb3"},
+ {file = "xxhash-3.6.0-cp311-cp311-win32.whl", hash = "sha256:d1927a69feddc24c987b337ce81ac15c4720955b667fe9b588e02254b80446fd"},
+ {file = "xxhash-3.6.0-cp311-cp311-win_amd64.whl", hash = "sha256:26734cdc2d4ffe449b41d186bbeac416f704a482ed835d375a5c0cb02bc63fef"},
+ {file = "xxhash-3.6.0-cp311-cp311-win_arm64.whl", hash = "sha256:d72f67ef8bf36e05f5b6c65e8524f265bd61071471cd4cf1d36743ebeeeb06b7"},
+ {file = "xxhash-3.6.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:01362c4331775398e7bb34e3ab403bc9ee9f7c497bc7dee6272114055277dd3c"},
+ {file = "xxhash-3.6.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b7b2df81a23f8cb99656378e72501b2cb41b1827c0f5a86f87d6b06b69f9f204"},
+ {file = "xxhash-3.6.0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:dc94790144e66b14f67b10ac8ed75b39ca47536bf8800eb7c24b50271ea0c490"},
+ {file = "xxhash-3.6.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:93f107c673bccf0d592cdba077dedaf52fe7f42dcd7676eba1f6d6f0c3efffd2"},
+ {file = "xxhash-3.6.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2aa5ee3444c25b69813663c9f8067dcfaa2e126dc55e8dddf40f4d1c25d7effa"},
+ {file = "xxhash-3.6.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f7f99123f0e1194fa59cc69ad46dbae2e07becec5df50a0509a808f90a0f03f0"},
+ {file = "xxhash-3.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:49e03e6fe2cac4a1bc64952dd250cf0dbc5ef4ebb7b8d96bce82e2de163c82a2"},
+ {file = "xxhash-3.6.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:bd17fede52a17a4f9a7bc4472a5867cb0b160deeb431795c0e4abe158bc784e9"},
+ {file = "xxhash-3.6.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:6fb5f5476bef678f69db04f2bd1efbed3030d2aba305b0fc1773645f187d6a4e"},
+ {file = "xxhash-3.6.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:843b52f6d88071f87eba1631b684fcb4b2068cd2180a0224122fe4ef011a9374"},
+ {file = "xxhash-3.6.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:7d14a6cfaf03b1b6f5f9790f76880601ccc7896aff7ab9cd8978a939c1eb7e0d"},
+ {file = "xxhash-3.6.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:418daf3db71e1413cfe211c2f9a528456936645c17f46b5204705581a45390ae"},
+ {file = "xxhash-3.6.0-cp312-cp312-win32.whl", hash = "sha256:50fc255f39428a27299c20e280d6193d8b63b8ef8028995323bf834a026b4fbb"},
+ {file = "xxhash-3.6.0-cp312-cp312-win_amd64.whl", hash = "sha256:c0f2ab8c715630565ab8991b536ecded9416d615538be8ecddce43ccf26cbc7c"},
+ {file = "xxhash-3.6.0-cp312-cp312-win_arm64.whl", hash = "sha256:eae5c13f3bc455a3bbb68bdc513912dc7356de7e2280363ea235f71f54064829"},
+ {file = "xxhash-3.6.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:599e64ba7f67472481ceb6ee80fa3bd828fd61ba59fb11475572cc5ee52b89ec"},
+ {file = "xxhash-3.6.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7d8b8aaa30fca4f16f0c84a5c8d7ddee0e25250ec2796c973775373257dde8f1"},
+ {file = "xxhash-3.6.0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:d597acf8506d6e7101a4a44a5e428977a51c0fadbbfd3c39650cca9253f6e5a6"},
+ {file = "xxhash-3.6.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:858dc935963a33bc33490128edc1c12b0c14d9c7ebaa4e387a7869ecc4f3e263"},
+ {file = "xxhash-3.6.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ba284920194615cb8edf73bf52236ce2e1664ccd4a38fdb543506413529cc546"},
+ {file = "xxhash-3.6.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4b54219177f6c6674d5378bd862c6aedf64725f70dd29c472eaae154df1a2e89"},
+ {file = "xxhash-3.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:42c36dd7dbad2f5238950c377fcbf6811b1cdb1c444fab447960030cea60504d"},
+ {file = "xxhash-3.6.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f22927652cba98c44639ffdc7aaf35828dccf679b10b31c4ad72a5b530a18eb7"},
+ {file = "xxhash-3.6.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:b45fad44d9c5c119e9c6fbf2e1c656a46dc68e280275007bbfd3d572b21426db"},
+ {file = "xxhash-3.6.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:6f2580ffab1a8b68ef2b901cde7e55fa8da5e4be0977c68f78fc80f3c143de42"},
+ {file = "xxhash-3.6.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:40c391dd3cd041ebc3ffe6f2c862f402e306eb571422e0aa918d8070ba31da11"},
+ {file = "xxhash-3.6.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f205badabde7aafd1a31e8ca2a3e5a763107a71c397c4481d6a804eb5063d8bd"},
+ {file = "xxhash-3.6.0-cp313-cp313-win32.whl", hash = "sha256:2577b276e060b73b73a53042ea5bd5203d3e6347ce0d09f98500f418a9fcf799"},
+ {file = "xxhash-3.6.0-cp313-cp313-win_amd64.whl", hash = "sha256:757320d45d2fbcce8f30c42a6b2f47862967aea7bf458b9625b4bbe7ee390392"},
+ {file = "xxhash-3.6.0-cp313-cp313-win_arm64.whl", hash = "sha256:457b8f85dec5825eed7b69c11ae86834a018b8e3df5e77783c999663da2f96d6"},
+ {file = "xxhash-3.6.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:a42e633d75cdad6d625434e3468126c73f13f7584545a9cf34e883aa1710e702"},
+ {file = "xxhash-3.6.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:568a6d743219e717b07b4e03b0a828ce593833e498c3b64752e0f5df6bfe84db"},
+ {file = "xxhash-3.6.0-cp313-cp313t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:bec91b562d8012dae276af8025a55811b875baace6af510412a5e58e3121bc54"},
+ {file = "xxhash-3.6.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:78e7f2f4c521c30ad5e786fdd6bae89d47a32672a80195467b5de0480aa97b1f"},
+ {file = "xxhash-3.6.0-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3ed0df1b11a79856df5ffcab572cbd6b9627034c1c748c5566fa79df9048a7c5"},
+ {file = "xxhash-3.6.0-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:0e4edbfc7d420925b0dd5e792478ed393d6e75ff8fc219a6546fb446b6a417b1"},
+ {file = "xxhash-3.6.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fba27a198363a7ef87f8c0f6b171ec36b674fe9053742c58dd7e3201c1ab30ee"},
+ {file = "xxhash-3.6.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:794fe9145fe60191c6532fa95063765529770edcdd67b3d537793e8004cabbfd"},
+ {file = "xxhash-3.6.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:6105ef7e62b5ac73a837778efc331a591d8442f8ef5c7e102376506cb4ae2729"},
+ {file = "xxhash-3.6.0-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:f01375c0e55395b814a679b3eea205db7919ac2af213f4a6682e01220e5fe292"},
+ {file = "xxhash-3.6.0-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:d706dca2d24d834a4661619dcacf51a75c16d65985718d6a7d73c1eeeb903ddf"},
+ {file = "xxhash-3.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:5f059d9faeacd49c0215d66f4056e1326c80503f51a1532ca336a385edadd033"},
+ {file = "xxhash-3.6.0-cp313-cp313t-win32.whl", hash = "sha256:1244460adc3a9be84731d72b8e80625788e5815b68da3da8b83f78115a40a7ec"},
+ {file = "xxhash-3.6.0-cp313-cp313t-win_amd64.whl", hash = "sha256:b1e420ef35c503869c4064f4a2f2b08ad6431ab7b229a05cce39d74268bca6b8"},
+ {file = "xxhash-3.6.0-cp313-cp313t-win_arm64.whl", hash = "sha256:ec44b73a4220623235f67a996c862049f375df3b1052d9899f40a6382c32d746"},
+ {file = "xxhash-3.6.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:a40a3d35b204b7cc7643cbcf8c9976d818cb47befcfac8bbefec8038ac363f3e"},
+ {file = "xxhash-3.6.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a54844be970d3fc22630b32d515e79a90d0a3ddb2644d8d7402e3c4c8da61405"},
+ {file = "xxhash-3.6.0-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:016e9190af8f0a4e3741343777710e3d5717427f175adfdc3e72508f59e2a7f3"},
+ {file = "xxhash-3.6.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4f6f72232f849eb9d0141e2ebe2677ece15adfd0fa599bc058aad83c714bb2c6"},
+ {file = "xxhash-3.6.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:63275a8aba7865e44b1813d2177e0f5ea7eadad3dd063a21f7cf9afdc7054063"},
+ {file = "xxhash-3.6.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:3cd01fa2aa00d8b017c97eb46b9a794fbdca53fc14f845f5a328c71254b0abb7"},
+ {file = "xxhash-3.6.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0226aa89035b62b6a86d3c68df4d7c1f47a342b8683da2b60cedcddb46c4d95b"},
+ {file = "xxhash-3.6.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c6e193e9f56e4ca4923c61238cdaced324f0feac782544eb4c6d55ad5cc99ddd"},
+ {file = "xxhash-3.6.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:9176dcaddf4ca963d4deb93866d739a343c01c969231dbe21680e13a5d1a5bf0"},
+ {file = "xxhash-3.6.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:c1ce4009c97a752e682b897aa99aef84191077a9433eb237774689f14f8ec152"},
+ {file = "xxhash-3.6.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:8cb2f4f679b01513b7adbb9b1b2f0f9cdc31b70007eaf9d59d0878809f385b11"},
+ {file = "xxhash-3.6.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:653a91d7c2ab54a92c19ccf43508b6a555440b9be1bc8be553376778be7f20b5"},
+ {file = "xxhash-3.6.0-cp314-cp314-win32.whl", hash = "sha256:a756fe893389483ee8c394d06b5ab765d96e68fbbfe6fde7aa17e11f5720559f"},
+ {file = "xxhash-3.6.0-cp314-cp314-win_amd64.whl", hash = "sha256:39be8e4e142550ef69629c9cd71b88c90e9a5db703fecbcf265546d9536ca4ad"},
+ {file = "xxhash-3.6.0-cp314-cp314-win_arm64.whl", hash = "sha256:25915e6000338999236f1eb68a02a32c3275ac338628a7eaa5a269c401995679"},
+ {file = "xxhash-3.6.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:c5294f596a9017ca5a3e3f8884c00b91ab2ad2933cf288f4923c3fd4346cf3d4"},
+ {file = "xxhash-3.6.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1cf9dcc4ab9cff01dfbba78544297a3a01dafd60f3bde4e2bfd016cf7e4ddc67"},
+ {file = "xxhash-3.6.0-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:01262da8798422d0685f7cef03b2bd3f4f46511b02830861df548d7def4402ad"},
+ {file = "xxhash-3.6.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:51a73fb7cb3a3ead9f7a8b583ffd9b8038e277cdb8cb87cf890e88b3456afa0b"},
+ {file = "xxhash-3.6.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b9c6df83594f7df8f7f708ce5ebeacfc69f72c9fbaaababf6cf4758eaada0c9b"},
+ {file = "xxhash-3.6.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:627f0af069b0ea56f312fd5189001c24578868643203bca1abbc2c52d3a6f3ca"},
+ {file = "xxhash-3.6.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:aa912c62f842dfd013c5f21a642c9c10cd9f4c4e943e0af83618b4a404d9091a"},
+ {file = "xxhash-3.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:b465afd7909db30168ab62afe40b2fcf79eedc0b89a6c0ab3123515dc0df8b99"},
+ {file = "xxhash-3.6.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:a881851cf38b0a70e7c4d3ce81fc7afd86fbc2a024f4cfb2a97cf49ce04b75d3"},
+ {file = "xxhash-3.6.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:9b3222c686a919a0f3253cfc12bb118b8b103506612253b5baeaac10d8027cf6"},
+ {file = "xxhash-3.6.0-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:c5aa639bc113e9286137cec8fadc20e9cd732b2cc385c0b7fa673b84fc1f2a93"},
+ {file = "xxhash-3.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5c1343d49ac102799905e115aee590183c3921d475356cb24b4de29a4bc56518"},
+ {file = "xxhash-3.6.0-cp314-cp314t-win32.whl", hash = "sha256:5851f033c3030dd95c086b4a36a2683c2ff4a799b23af60977188b057e467119"},
+ {file = "xxhash-3.6.0-cp314-cp314t-win_amd64.whl", hash = "sha256:0444e7967dac37569052d2409b00a8860c2135cff05502df4da80267d384849f"},
+ {file = "xxhash-3.6.0-cp314-cp314t-win_arm64.whl", hash = "sha256:bb79b1e63f6fd84ec778a4b1916dfe0a7c3fdb986c06addd5db3a0d413819d95"},
+ {file = "xxhash-3.6.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:0f7b7e2ec26c1666ad5fc9dbfa426a6a3367ceaf79db5dd76264659d509d73b0"},
+ {file = "xxhash-3.6.0-pp311-pypy311_pp73-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:5dc1e14d14fa0f5789ec29a7062004b5933964bb9b02aae6622b8f530dc40296"},
+ {file = "xxhash-3.6.0-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:881b47fc47e051b37d94d13e7455131054b56749b91b508b0907eb07900d1c13"},
+ {file = "xxhash-3.6.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c6dc31591899f5e5666f04cc2e529e69b4072827085c1ef15294d91a004bc1bd"},
+ {file = "xxhash-3.6.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:15e0dac10eb9309508bfc41f7f9deaa7755c69e35af835db9cb10751adebc35d"},
+ {file = "xxhash-3.6.0.tar.gz", hash = "sha256:f0162a78b13a0d7617b2845b90c763339d1f1d82bb04a4b07f4ab535cc5e05d6"},
+]
+
[[package]]
name = "yarl"
version = "1.20.1"
diff --git a/src/local_deep_research/database/models/library.py b/src/local_deep_research/database/models/library.py
index ad55f98721..acc80cbe85 100644
--- a/src/local_deep_research/database/models/library.py
+++ b/src/local_deep_research/database/models/library.py
@@ -11,7 +11,6 @@ from sqlalchemy import (
ForeignKey,
Index,
Integer,
- LargeBinary,
String,
Text,
UniqueConstraint,
@@ -290,7 +289,9 @@ class DocumentChunk(Base):
# Indexes for efficient queries
__table_args__ = (
- UniqueConstraint("chunk_hash", "collection_name", name="uix_chunk_collection"),
+ UniqueConstraint(
+ "chunk_hash", "collection_name", name="uix_chunk_collection"
+ ),
Index("idx_chunk_source", "source_type", "source_id"),
Index("idx_chunk_collection", "collection_name", "created_at"),
Index("idx_chunk_embedding", "embedding_id"),
@@ -315,8 +316,12 @@ class LibraryCollection(Base):
collection_type = Column(String(50), default="user_uploads")
# Embedding model used for this collection (stored when first indexed)
- embedding_model = Column(String(100), nullable=True) # e.g., 'all-MiniLM-L6-v2'
- embedding_model_type = Column(String(50), nullable=True) # 'sentence_transformers', 'ollama'
+ embedding_model = Column(
+ String(100), nullable=True
+ ) # e.g., 'all-MiniLM-L6-v2'
+ embedding_model_type = Column(
+ String(50), nullable=True
+ ) # 'sentence_transformers', 'ollama'
embedding_dimension = Column(Integer, nullable=True) # Vector dimension
chunk_size = Column(Integer, nullable=True) # Chunk size used
chunk_overlap = Column(Integer, nullable=True) # Chunk overlap used
@@ -527,7 +532,9 @@ class UserDocument(Base):
# File identification
filename = Column(String(500), nullable=False) # Display name
original_filename = Column(String(500)) # Original name when uploaded
- file_path = Column(Text, nullable=True) # Path relative to data/user_uploads/ (optional - we store text directly)
+ file_path = Column(
+ Text, nullable=True
+ ) # Path relative to data/user_uploads/ (optional - we store text directly)
file_hash = Column(
String(64), nullable=False, unique=True, index=True
) # SHA256 for deduplication
@@ -551,7 +558,9 @@ class UserDocument(Base):
# Relationships
collections = relationship(
- "UserDocumentCollection", back_populates="document", cascade="all, delete-orphan"
+ "UserDocumentCollection",
+ back_populates="document",
+ cascade="all, delete-orphan",
)
def __repr__(self):
@@ -581,8 +590,12 @@ class UserDocumentCollection(Base):
)
# Indexing status (per collection!)
- indexed = Column(Boolean, default=False) # Whether indexed for this collection
- chunk_count = Column(Integer, default=0) # Number of chunks in this collection
+ indexed = Column(
+ Boolean, default=False
+ ) # Whether indexed for this collection
+ chunk_count = Column(
+ Integer, default=0
+ ) # Number of chunks in this collection
last_indexed_at = Column(UtcDateTime, nullable=True)
# Timestamps
@@ -624,11 +637,15 @@ class CollectionFolder(Base):
include_patterns = Column(
JSON, default=["*.pdf", "*.txt", "*.md", "*.html"]
) # File patterns to include
- exclude_patterns = Column(JSON) # Patterns to exclude (e.g., ["**/node_modules/**"])
+ exclude_patterns = Column(
+ JSON
+ ) # Patterns to exclude (e.g., ["**/node_modules/**"])
recursive = Column(Boolean, default=True) # Search subfolders
# Monitoring
- watch_enabled = Column(Boolean, default=False) # Auto-reindex on changes (future)
+ watch_enabled = Column(
+ Boolean, default=False
+ ) # Auto-reindex on changes (future)
last_scanned_at = Column(UtcDateTime, nullable=True)
file_count = Column(Integer, default=0) # Total files found
indexed_file_count = Column(Integer, default=0) # Files indexed
@@ -642,7 +659,9 @@ class CollectionFolder(Base):
# Relationships
collection = relationship("LibraryCollection", backref="linked_folders")
files = relationship(
- "CollectionFolderFile", back_populates="folder", cascade="all, delete-orphan"
+ "CollectionFolderFile",
+ back_populates="folder",
+ cascade="all, delete-orphan",
)
def __repr__(self):
@@ -696,4 +715,4 @@ class CollectionFolderFile(Base):
)
def __repr__(self):
- return f"<CollectionFolderFile(path='{self.relative_path}', indexed={self.indexed})>"
\ No newline at end of file
+ return f"<CollectionFolderFile(path='{self.relative_path}', indexed={self.indexed})>"
diff --git a/src/local_deep_research/research_library/routes/library_routes.py b/src/local_deep_research/research_library/routes/library_routes.py
index 82dd37e374..2fa7c8d038 100644
--- a/src/local_deep_research/research_library/routes/library_routes.py
+++ b/src/local_deep_research/research_library/routes/library_routes.py
@@ -194,8 +194,7 @@ def document_details_page(document_id):
return "Document not found", 404
return render_template_with_defaults(
- "pages/document_details.html",
- document=document
+ "pages/document_details.html", document=document
)
@@ -308,7 +307,9 @@ def get_documents():
return jsonify({"documents": documents})
-@library_bp.route("/api/document/<string:document_id>/favorite", methods=["POST"])
+@library_bp.route(
+ "/api/document/<string:document_id>/favorite", methods=["POST"]
+)
@login_required
def toggle_favorite(document_id):
"""Toggle favorite status of a document."""
@@ -366,7 +367,7 @@ def serve_pdf(document_id):
# Check if PDF storage is enabled
if file_path is None:
logger.warning(
- f"Document {doc_id} has no file path - PDF may not have been downloaded (privacy mode or download failed)"
+ f"Document {document_id} has no file path - PDF may not have been downloaded (privacy mode or download failed)"
)
return (
"PDF not downloaded. Enable PDF storage in settings and use Download Manager to download this file.",
@@ -413,7 +414,9 @@ def serve_text(document_id):
)
if not text_doc:
- logger.warning(f"Text document not found for document ID {document_id}")
+ logger.warning(
+ f"Text document not found for document ID {document_id}"
+ )
return jsonify({"error": "Text not found"}), 404
if not text_doc.text_content:
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.py
index 707d725fe6..a6ed1b8ec7 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -74,7 +74,11 @@ def collections_page():
@login_required
def collection_details_page(collection_id):
"""Render the Collection Details page."""
- return render_template("pages/collection_details.html", active_page="collections", collection_id=collection_id)
+ return render_template(
+ "pages/collection_details.html",
+ active_page="collections",
+ collection_id=collection_id,
+ )
# API Routes
@@ -470,7 +474,9 @@ def index_local_library():
import glob
folder_path = request.args.get("path")
- file_patterns = request.args.get("patterns", "*.pdf,*.txt,*.md,*.html").split(",")
+ file_patterns = request.args.get(
+ "patterns", "*.pdf,*.txt,*.md,*.html"
+ ).split(",")
recursive = request.args.get("recursive", "true").lower() == "true"
if not folder_path:
@@ -479,9 +485,16 @@ def index_local_library():
# Validate path exists and is a directory
path = Path(folder_path).expanduser().resolve()
if not path.exists():
- return jsonify({"success": False, "error": f"Path does not exist: {folder_path}"}), 400
+ return jsonify(
+ {"success": False, "error": f"Path does not exist: {folder_path}"}
+ ), 400
if not path.is_dir():
- return jsonify({"success": False, "error": f"Path is not a directory: {folder_path}"}), 400
+ return jsonify(
+ {
+ "success": False,
+ "error": f"Path is not a directory: {folder_path}",
+ }
+ ), 400
# Create RAG service in request context
rag_service = get_rag_service()
@@ -531,16 +544,17 @@ def index_local_library():
results["skipped"] += 1
else:
results["failed"] += 1
- results["errors"].append({
- "file": file_name,
- "error": result.get("error", "Unknown error")
- })
+ results["errors"].append(
+ {
+ "file": file_name,
+ "error": result.get("error", "Unknown error"),
+ }
+ )
except Exception as e:
results["failed"] += 1
- results["errors"].append({
- "file": file_name,
- "error": str(e)
- })
+ results["errors"].append(
+ {"file": file_name, "error": str(e)}
+ )
logger.exception(f"Error indexing file {file_path}")
# Send completion status
@@ -584,10 +598,16 @@ def get_collections():
"id": coll.id,
"name": coll.name,
"description": coll.description,
- "created_at": coll.created_at.isoformat() if coll.created_at else None,
+ "created_at": coll.created_at.isoformat()
+ if coll.created_at
+ else None,
"collection_type": coll.collection_type,
- "document_count": len(coll.user_documents) if hasattr(coll, 'user_documents') else 0,
- "folder_count": len(coll.linked_folders) if hasattr(coll, 'linked_folders') else 0,
+ "document_count": len(coll.user_documents)
+ if hasattr(coll, "user_documents")
+ else 0,
+ "folder_count": len(coll.linked_folders)
+ if hasattr(coll, "linked_folders")
+ else 0,
}
# Include embedding metadata if available
@@ -629,13 +649,16 @@ def create_collection():
username = session["username"]
with get_user_db_session(username) as db_session:
# Check if collection with this name already exists in this user's database
- existing = db_session.query(LibraryCollection).filter_by(
- name=name
- ).first()
+ existing = (
+ db_session.query(LibraryCollection).filter_by(name=name).first()
+ )
if existing:
return jsonify(
- {"success": False, "error": f"Collection '{name}' already exists"}
+ {
+ "success": False,
+ "error": f"Collection '{name}' already exists",
+ }
), 400
# Create new collection (no username needed - each user has their own DB)
@@ -650,16 +673,18 @@ def create_collection():
db_session.add(collection)
db_session.commit()
- return jsonify({
- "success": True,
- "collection": {
- "id": collection.id,
- "name": collection.name,
- "description": collection.description,
- "created_at": collection.created_at.isoformat(),
- "collection_type": collection.collection_type
+ return jsonify(
+ {
+ "success": True,
+ "collection": {
+ "id": collection.id,
+ "name": collection.name,
+ "description": collection.description,
+ "created_at": collection.created_at.isoformat(),
+ "collection_type": collection.collection_type,
+ },
}
- })
+ )
except Exception as e:
logger.exception("Error creating collection")
return jsonify({"success": False, "error": str(e)}), 500
@@ -680,9 +705,11 @@ def update_collection(collection_id):
username = session["username"]
with get_user_db_session(username) as db_session:
# No need to filter by username - each user has their own database
- collection = db_session.query(LibraryCollection).filter_by(
- id=collection_id
- ).first()
+ collection = (
+ db_session.query(LibraryCollection)
+ .filter_by(id=collection_id)
+ .first()
+ )
if not collection:
return jsonify(
@@ -691,14 +718,21 @@ def update_collection(collection_id):
if name:
# Check if new name conflicts with existing collection
- existing = db_session.query(LibraryCollection).filter(
- LibraryCollection.name == name,
- LibraryCollection.id != collection_id
- ).first()
+ existing = (
+ db_session.query(LibraryCollection)
+ .filter(
+ LibraryCollection.name == name,
+ LibraryCollection.id != collection_id,
+ )
+ .first()
+ )
if existing:
return jsonify(
- {"success": False, "error": f"Collection '{name}' already exists"}
+ {
+ "success": False,
+ "error": f"Collection '{name}' already exists",
+ }
), 400
collection.name = name
@@ -708,16 +742,20 @@ def update_collection(collection_id):
db_session.commit()
- return jsonify({
- "success": True,
- "collection": {
- "id": collection.id,
- "name": collection.name,
- "description": collection.description,
- "created_at": collection.created_at.isoformat() if collection.created_at else None,
- "collection_type": collection.collection_type
+ return jsonify(
+ {
+ "success": True,
+ "collection": {
+ "id": collection.id,
+ "name": collection.name,
+ "description": collection.description,
+ "created_at": collection.created_at.isoformat()
+ if collection.created_at
+ else None,
+ "collection_type": collection.collection_type,
+ },
}
- })
+ )
except Exception as e:
logger.exception("Error updating collection")
return jsonify({"success": False, "error": str(e)}), 500
@@ -736,14 +774,14 @@ def delete_collection(collection_id):
from ...database.session_context import get_user_db_session
try:
- delete_documents = request.args.get("delete_documents", "false").lower() == "true"
-
username = session["username"]
with get_user_db_session(username) as db_session:
# No need to filter by username - each user has their own database
- collection = db_session.query(LibraryCollection).filter_by(
- id=collection_id
- ).first()
+ collection = (
+ db_session.query(LibraryCollection)
+ .filter_by(id=collection_id)
+ .first()
+ )
if not collection:
return jsonify(
@@ -754,9 +792,11 @@ def delete_collection(collection_id):
collection_name = f"collection_{collection.id}"
# Delete associated document chunks from vector store
- deleted_chunks = db_session.query(DocumentChunk).filter_by(
- collection_name=collection_name
- ).delete()
+ deleted_chunks = (
+ db_session.query(DocumentChunk)
+ .filter_by(collection_name=collection_name)
+ .delete()
+ )
# Delete junction table entries
db_session.query(UserDocumentCollection).filter_by(
@@ -777,19 +817,25 @@ def delete_collection(collection_id):
rag_service = get_rag_service()
rag_service.remove_collection_from_index(collection_name)
except Exception as e:
- logger.warning(f"Could not remove collection from vector index: {e}")
+ logger.warning(
+ f"Could not remove collection from vector index: {e}"
+ )
- return jsonify({
- "success": True,
- "message": f"Collection deleted successfully",
- "deleted_chunks": deleted_chunks
- })
+ return jsonify(
+ {
+ "success": True,
+ "message": "Collection deleted successfully",
+ "deleted_chunks": deleted_chunks,
+ }
+ )
except Exception as e:
logger.exception("Error deleting collection")
return jsonify({"success": False, "error": str(e)}), 500
-def extract_text_from_file(file_content: bytes, file_type: str, filename: str) -> Optional[str]:
+def extract_text_from_file(
+ file_content: bytes, file_type: str, filename: str
+) -> Optional[str]:
"""
Extract text from uploaded file content.
@@ -805,6 +851,7 @@ def extract_text_from_file(file_content: bytes, file_type: str, filename: str) -
if file_type == "pdf":
# Use the existing PDF text extraction functionality
from ..downloaders.base import BaseDownloader
+
text = BaseDownloader._extract_text_from_pdf(file_content)
if text:
logger.info(f"Successfully extracted text from PDF: {filename}")
@@ -823,7 +870,9 @@ def extract_text_from_file(file_content: bytes, file_type: str, filename: str) -
# Try with different encoding
try:
text = file_content.decode("utf-8", errors="ignore")
- logger.warning(f"Read text file with encoding errors ignored: {filename}")
+ logger.warning(
+ f"Read text file with encoding errors ignored: {filename}"
+ )
return text
except Exception:
logger.exception(f"Failed to decode text file: {filename}")
@@ -833,6 +882,7 @@ def extract_text_from_file(file_content: bytes, file_type: str, filename: str) -
# HTML files - extract text content
try:
from bs4 import BeautifulSoup
+
html_content = file_content.decode("utf-8", errors="ignore")
soup = BeautifulSoup(html_content, "html.parser")
@@ -845,22 +895,34 @@ def extract_text_from_file(file_content: bytes, file_type: str, filename: str) -
# Clean up whitespace
lines = (line.strip() for line in text.splitlines())
- chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
- text = '\n'.join(chunk for chunk in chunks if chunk)
+ chunks = (
+ phrase.strip()
+ for line in lines
+ for phrase in line.split(" ")
+ )
+ text = "\n".join(chunk for chunk in chunks if chunk)
- logger.info(f"Successfully extracted text from HTML: {filename}")
+ logger.info(
+ f"Successfully extracted text from HTML: {filename}"
+ )
return text
except Exception:
- logger.exception(f"Failed to extract text from HTML: {filename}")
+ logger.exception(
+ f"Failed to extract text from HTML: {filename}"
+ )
return None
elif file_type in ["docx", "doc"]:
# Word documents - would need python-docx library
- logger.warning(f"Word document extraction not yet implemented: {filename}")
+ logger.warning(
+ f"Word document extraction not yet implemented: {filename}"
+ )
return None
else:
- logger.warning(f"Unsupported file type for text extraction: {file_type} ({filename})")
+ logger.warning(
+ f"Unsupported file type for text extraction: {file_type} ({filename})"
+ )
return None
except Exception:
@@ -868,7 +930,9 @@ def extract_text_from_file(file_content: bytes, file_type: str, filename: str) -
return None
-@rag_bp.route("/api/collections/<string:collection_id>/upload", methods=["POST"])
+@rag_bp.route(
+ "/api/collections/<string:collection_id>/upload", methods=["POST"]
+)
@login_required
def upload_to_collection(collection_id):
"""Upload files to a collection."""
@@ -884,18 +948,24 @@ def upload_to_collection(collection_id):
try:
if "files" not in request.files:
- return jsonify({"success": False, "error": "No files provided"}), 400
+ return jsonify(
+ {"success": False, "error": "No files provided"}
+ ), 400
files = request.files.getlist("files")
if not files:
- return jsonify({"success": False, "error": "No files selected"}), 400
+ return jsonify(
+ {"success": False, "error": "No files selected"}
+ ), 400
username = session["username"]
with get_user_db_session(username) as db_session:
# Verify collection exists in this user's database
- collection = db_session.query(LibraryCollection).filter_by(
- id=collection_id
- ).first()
+ collection = (
+ db_session.query(LibraryCollection)
+ .filter_by(id=collection_id)
+ .first()
+ )
if not collection:
return jsonify(
@@ -918,17 +988,23 @@ def upload_to_collection(collection_id):
file_hash = hashlib.sha256(file_content).hexdigest()
# Check if document already exists
- existing_doc = db_session.query(UserDocument).filter_by(
- file_hash=file_hash
- ).first()
+ existing_doc = (
+ db_session.query(UserDocument)
+ .filter_by(file_hash=file_hash)
+ .first()
+ )
if existing_doc:
# Document exists, just add to collection
# Check if already in collection
- existing_link = db_session.query(UserDocumentCollection).filter_by(
- document_id=existing_doc.id,
- collection_id=collection_id
- ).first()
+ existing_link = (
+ db_session.query(UserDocumentCollection)
+ .filter_by(
+ document_id=existing_doc.id,
+ collection_id=collection_id,
+ )
+ .first()
+ )
if not existing_link:
# Add to collection
@@ -939,17 +1015,21 @@ def upload_to_collection(collection_id):
chunk_count=0,
)
db_session.add(collection_link)
- uploaded_files.append({
- "filename": existing_doc.filename,
- "status": "added_to_collection",
- "id": existing_doc.id
- })
+ uploaded_files.append(
+ {
+ "filename": existing_doc.filename,
+ "status": "added_to_collection",
+ "id": existing_doc.id,
+ }
+ )
else:
- uploaded_files.append({
- "filename": existing_doc.filename,
- "status": "already_in_collection",
- "id": existing_doc.id
- })
+ uploaded_files.append(
+ {
+ "filename": existing_doc.filename,
+ "status": "already_in_collection",
+ "id": existing_doc.id,
+ }
+ )
else:
# Create new document
filename = secure_filename(file.filename)
@@ -967,14 +1047,20 @@ def upload_to_collection(collection_id):
}.get(file_extension, "unknown")
# Extract text from the file
- extracted_text = extract_text_from_file(file_content, file_type, filename)
+ extracted_text = extract_text_from_file(
+ file_content, file_type, filename
+ )
if not extracted_text:
- errors.append({
- "filename": filename,
- "error": f"Could not extract text from {file_type} file"
- })
- logger.warning(f"Skipping file {filename} - no text could be extracted")
+ errors.append(
+ {
+ "filename": filename,
+ "error": f"Could not extract text from {file_type} file",
+ }
+ )
+ logger.warning(
+ f"Skipping file {filename} - no text could be extracted"
+ )
continue
# Create document with extracted text (no username needed - in user's own database)
@@ -1001,39 +1087,42 @@ def upload_to_collection(collection_id):
)
db_session.add(collection_link)
- uploaded_files.append({
- "filename": filename,
- "status": "uploaded",
- "id": new_doc.id,
- "text_length": len(extracted_text)
- })
+ uploaded_files.append(
+ {
+ "filename": filename,
+ "status": "uploaded",
+ "id": new_doc.id,
+ "text_length": len(extracted_text),
+ }
+ )
except Exception as e:
- errors.append({
- "filename": file.filename,
- "error": str(e)
- })
+ errors.append({"filename": file.filename, "error": str(e)})
logger.exception(f"Error uploading file {file.filename}")
db_session.commit()
- return jsonify({
- "success": True,
- "uploaded": uploaded_files,
- "errors": errors,
- "summary": {
- "total": len(files),
- "successful": len(uploaded_files),
- "failed": len(errors)
+ return jsonify(
+ {
+ "success": True,
+ "uploaded": uploaded_files,
+ "errors": errors,
+ "summary": {
+ "total": len(files),
+ "successful": len(uploaded_files),
+ "failed": len(errors),
+ },
}
- })
+ )
except Exception as e:
logger.exception("Error uploading files")
return jsonify({"success": False, "error": str(e)}), 500
-@rag_bp.route("/api/collections/<string:collection_id>/documents", methods=["GET"])
+@rag_bp.route(
+ "/api/collections/<string:collection_id>/documents", methods=["GET"]
+)
@login_required
def get_collection_documents(collection_id):
"""Get all documents in a collection."""
@@ -1048,9 +1137,11 @@ def get_collection_documents(collection_id):
username = session["username"]
with get_user_db_session(username) as db_session:
# Verify collection exists in this user's database
- collection = db_session.query(LibraryCollection).filter_by(
- id=collection_id
- ).first()
+ collection = (
+ db_session.query(LibraryCollection)
+ .filter_by(id=collection_id)
+ .first()
+ )
if not collection:
return jsonify(
@@ -1058,36 +1149,43 @@ def get_collection_documents(collection_id):
), 404
# Get documents through junction table
- doc_links = db_session.query(
- UserDocumentCollection, UserDocument
- ).join(
- UserDocument
- ).filter(
- UserDocumentCollection.collection_id == collection_id
- ).all()
+ doc_links = (
+ db_session.query(UserDocumentCollection, UserDocument)
+ .join(UserDocument)
+ .filter(UserDocumentCollection.collection_id == collection_id)
+ .all()
+ )
documents = []
for link, doc in doc_links:
- documents.append({
- "id": doc.id,
- "filename": doc.filename,
- "file_type": doc.file_type,
- "file_size": doc.file_size,
- "uploaded_at": doc.uploaded_at.isoformat() if doc.uploaded_at else None,
- "indexed": link.indexed,
- "chunk_count": link.chunk_count,
- "last_indexed_at": link.last_indexed_at.isoformat() if link.last_indexed_at else None,
- })
-
- return jsonify({
- "success": True,
- "collection": {
- "id": collection.id,
- "name": collection.name,
- "description": collection.description,
- },
- "documents": documents
- })
+ documents.append(
+ {
+ "id": doc.id,
+ "filename": doc.filename,
+ "file_type": doc.file_type,
+ "file_size": doc.file_size,
+ "uploaded_at": doc.uploaded_at.isoformat()
+ if doc.uploaded_at
+ else None,
+ "indexed": link.indexed,
+ "chunk_count": link.chunk_count,
+ "last_indexed_at": link.last_indexed_at.isoformat()
+ if link.last_indexed_at
+ else None,
+ }
+ )
+
+ return jsonify(
+ {
+ "success": True,
+ "collection": {
+ "id": collection.id,
+ "name": collection.name,
+ "description": collection.description,
+ },
+ "documents": documents,
+ }
+ )
except Exception as e:
logger.exception("Error getting collection documents")
@@ -1116,9 +1214,11 @@ def index_collection(collection_id):
try:
with get_user_db_session(username) as db_session:
# Verify collection exists in this user's database
- collection = db_session.query(LibraryCollection).filter_by(
- id=collection_id
- ).first()
+ collection = (
+ db_session.query(LibraryCollection)
+ .filter_by(id=collection_id)
+ .first()
+ )
if not collection:
yield f"data: {json.dumps({'type': 'error', 'error': 'Collection not found'})}\n\n"
@@ -1130,33 +1230,39 @@ def index_collection(collection_id):
embedding_dim = None
try:
# Try to get dimension from the embedding manager's provider
- if hasattr(rag_service.embedding_manager, 'provider'):
+ if hasattr(rag_service.embedding_manager, "provider"):
provider = rag_service.embedding_manager.provider
- if hasattr(provider, 'embedding_dimension'):
+ if hasattr(provider, "embedding_dimension"):
embedding_dim = provider.embedding_dimension
except Exception as e:
- logger.warning(f"Could not get embedding dimension: {e}")
+ logger.warning(
+ f"Could not get embedding dimension: {e}"
+ )
# Store the embedding configuration used for this collection
collection.embedding_model = rag_service.embedding_model
- collection.embedding_model_type = rag_service.embedding_provider
+ collection.embedding_model_type = (
+ rag_service.embedding_provider
+ )
collection.embedding_dimension = embedding_dim
collection.chunk_size = rag_service.chunk_size
collection.chunk_overlap = rag_service.chunk_overlap
db_session.commit()
- logger.info(f"Stored embedding metadata for collection {collection.id}: {rag_service.embedding_provider}/{rag_service.embedding_model}")
+ logger.info(
+ f"Stored embedding metadata for collection {collection.id}: {rag_service.embedding_provider}/{rag_service.embedding_model}"
+ )
# Get documents to index
- query = db_session.query(
- UserDocumentCollection, UserDocument
- ).join(
- UserDocument
- ).filter(
- UserDocumentCollection.collection_id == collection_id
+ query = (
+ db_session.query(UserDocumentCollection, UserDocument)
+ .join(UserDocument)
+ .filter(
+ UserDocumentCollection.collection_id == collection_id
+ )
)
if not force_reindex:
- query = query.filter(UserDocumentCollection.indexed == False)
+ query = query.filter(not UserDocumentCollection.indexed)
doc_links = query.all()
@@ -1165,7 +1271,12 @@ def index_collection(collection_id):
return
total = len(doc_links)
- results = {"successful": 0, "skipped": 0, "failed": 0, "errors": []}
+ results = {
+ "successful": 0,
+ "skipped": 0,
+ "failed": 0,
+ "errors": [],
+ }
yield f"data: {json.dumps({'type': 'start', 'message': f'Indexing {total} documents in collection: {collection.name}'})}\n\n"
@@ -1190,17 +1301,22 @@ def index_collection(collection_id):
results["skipped"] += 1
else:
results["failed"] += 1
- results["errors"].append({
- "filename": doc.filename,
- "error": result.get("error", "Unknown error")
- })
+ results["errors"].append(
+ {
+ "filename": doc.filename,
+ "error": result.get(
+ "error", "Unknown error"
+ ),
+ }
+ )
except Exception as e:
results["failed"] += 1
- results["errors"].append({
- "filename": doc.filename,
- "error": str(e)
- })
- logger.exception(f"Error indexing document {doc.filename}")
+ results["errors"].append(
+ {"filename": doc.filename, "error": str(e)}
+ )
+ logger.exception(
+ f"Error indexing document {doc.filename}"
+ )
db_session.commit()
diff --git a/src/local_deep_research/research_library/services/library_rag_service.py b/src/local_deep_research/research_library/services/library_rag_service.py
index 30b1086209..f28ac02ed3 100644
--- a/src/local_deep_research/research_library/services/library_rag_service.py
+++ b/src/local_deep_research/research_library/services/library_rag_service.py
@@ -667,29 +667,37 @@ class LibraryRAGService:
# Read file content based on type
try:
- if file_path.suffix.lower() in ['.txt', '.md', '.markdown']:
+ if file_path.suffix.lower() in [".txt", ".md", ".markdown"]:
# Text files
- with open(file_path, 'r', encoding='utf-8') as f:
+ with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
- elif file_path.suffix.lower() in ['.html', '.htm']:
+ elif file_path.suffix.lower() in [".html", ".htm"]:
# HTML files - strip tags
from bs4 import BeautifulSoup
- with open(file_path, 'r', encoding='utf-8') as f:
- soup = BeautifulSoup(f.read(), 'html.parser')
+
+ with open(file_path, "r", encoding="utf-8") as f:
+ soup = BeautifulSoup(f.read(), "html.parser")
content = soup.get_text()
- elif file_path.suffix.lower() == '.pdf':
+ elif file_path.suffix.lower() == ".pdf":
# PDF files - extract text
import PyPDF2
+
content = ""
- with open(file_path, 'rb') as f:
+ with open(file_path, "rb") as f:
pdf_reader = PyPDF2.PdfReader(f)
for page in pdf_reader.pages:
content += page.extract_text()
else:
- return {"status": "skipped", "error": f"Unsupported file type: {file_path.suffix}"}
+ return {
+ "status": "skipped",
+ "error": f"Unsupported file type: {file_path.suffix}",
+ }
if not content or len(content.strip()) < 10:
- return {"status": "error", "error": "File has no extractable text content"}
+ return {
+ "status": "error",
+ "error": "File has no extractable text content",
+ }
# Create LangChain Document from text
doc = Document(
@@ -702,18 +710,23 @@ class LibraryRAGService:
"file_type": file_path.suffix.lower(),
"file_size": file_path.stat().st_size,
"source_type": "local_file",
- "collection": "local_library"
- }
+ "collection": "local_library",
+ },
)
# Split into chunks
chunks = self.text_splitter.split_documents([doc])
- logger.info(f"Split local file {file_path} into {len(chunks)} chunks")
+ logger.info(
+ f"Split local file {file_path} into {len(chunks)} chunks"
+ )
# Generate unique IDs for chunks
import hashlib
+
file_hash = hashlib.sha256(str(file_path).encode()).hexdigest()[:8]
- embedding_ids = [f"local_{file_hash}_{i}" for i in range(len(chunks))]
+ embedding_ids = [
+ f"local_{file_hash}_{i}" for i in range(len(chunks))
+ ]
# Store chunks in database
self.embedding_manager._store_chunks_to_db(
@@ -731,19 +744,25 @@ class LibraryRAGService:
self.faiss_index.add_documents(chunks, ids=embedding_ids)
# Save FAISS index
- index_path = Path(self.rag_index_record.index_path) if self.rag_index_record else None
+ index_path = (
+ Path(self.rag_index_record.index_path)
+ if self.rag_index_record
+ else None
+ )
if index_path:
self.faiss_index.save_local(
str(index_path.parent), index_name=index_path.stem
)
logger.info(f"Saved FAISS index to {index_path}")
- logger.info(f"Successfully indexed local file {file_path} with {len(chunks)} chunks")
+ logger.info(
+ f"Successfully indexed local file {file_path} with {len(chunks)} chunks"
+ )
return {
"status": "success",
"chunk_count": len(chunks),
- "embedding_ids": embedding_ids
+ "embedding_ids": embedding_ids,
}
except Exception as e:
@@ -764,15 +783,16 @@ class LibraryRAGService:
Returns:
Dict with status, chunk_count, and any errors
"""
- from ...database.models import UserDocumentCollection, DocumentChunk
- from ...database.session_context import get_user_db_session
try:
# Use the pre-extracted text content
content = user_doc.text_content
if not content or len(content.strip()) < 10:
- return {"status": "error", "error": "Document has no extractable text content"}
+ return {
+ "status": "error",
+ "error": "Document has no extractable text content",
+ }
# Create LangChain Document
doc = Document(
@@ -785,12 +805,14 @@ class LibraryRAGService:
"file_type": user_doc.file_type,
"file_size": user_doc.file_size,
"collection": collection_name,
- }
+ },
)
# Split into chunks
chunks = self.text_splitter.split_documents([doc])
- logger.info(f"Split user document {user_doc.filename} into {len(chunks)} chunks")
+ logger.info(
+ f"Split user document {user_doc.filename} into {len(chunks)} chunks"
+ )
# Store chunks in database
embedding_ids = self.embedding_manager._store_chunks_to_db(
@@ -855,25 +877,35 @@ class LibraryRAGService:
)
# Save FAISS index
- index_path = Path(self.rag_index_record.index_path) if self.rag_index_record else None
+ index_path = (
+ Path(self.rag_index_record.index_path)
+ if self.rag_index_record
+ else None
+ )
if index_path:
self.faiss_index.save_local(
str(index_path.parent), index_name=index_path.stem
)
- logger.info(f"Successfully indexed user document {user_doc.filename} with {len(chunks)} chunks")
+ logger.info(
+ f"Successfully indexed user document {user_doc.filename} with {len(chunks)} chunks"
+ )
return {
"status": "success",
"chunk_count": len(chunks),
- "embedding_ids": embedding_ids
+ "embedding_ids": embedding_ids,
}
except Exception as e:
- logger.exception(f"Error indexing user document {user_doc.filename}: {str(e)}")
+ logger.exception(
+ f"Error indexing user document {user_doc.filename}: {str(e)}"
+ )
return {"status": "error", "error": str(e)}
- def remove_collection_from_index(self, collection_name: str) -> Dict[str, Any]:
+ def remove_collection_from_index(
+ self, collection_name: str
+ ) -> Dict[str, Any]:
"""
Remove all documents from a collection from the FAISS index.
@@ -889,39 +921,54 @@ class LibraryRAGService:
try:
with get_user_db_session(self.username) as session:
# Get all chunk IDs for this collection
- chunks = session.query(DocumentChunk).filter_by(
- collection_name=collection_name
- ).all()
+ chunks = (
+ session.query(DocumentChunk)
+ .filter_by(collection_name=collection_name)
+ .all()
+ )
if not chunks:
return {"status": "success", "deleted_count": 0}
- chunk_ids = [f"{collection_name}_{chunk.id}" for chunk in chunks]
+ chunk_ids = [
+ f"{collection_name}_{chunk.id}" for chunk in chunks
+ ]
# Load FAISS index if not already loaded
if self.faiss_index is None:
self.faiss_index = self._load_or_create_faiss_index()
# Remove from FAISS index
- if hasattr(self.faiss_index, 'delete'):
+ if hasattr(self.faiss_index, "delete"):
try:
self.faiss_index.delete(chunk_ids)
# Save updated index
- index_path = Path(self.rag_index_record.index_path) if self.rag_index_record else None
+ index_path = (
+ Path(self.rag_index_record.index_path)
+ if self.rag_index_record
+ else None
+ )
if index_path:
self.faiss_index.save_local(
- str(index_path.parent), index_name=index_path.stem
+ str(index_path.parent),
+ index_name=index_path.stem,
)
except Exception as e:
- logger.warning(f"Could not delete chunks from FAISS: {e}")
+ logger.warning(
+ f"Could not delete chunks from FAISS: {e}"
+ )
- logger.info(f"Removed {len(chunk_ids)} chunks from collection {collection_name}")
+ logger.info(
+ f"Removed {len(chunk_ids)} chunks from collection {collection_name}"
+ )
return {"status": "success", "deleted_count": len(chunk_ids)}
except Exception as e:
- logger.exception(f"Error removing collection {collection_name} from index: {str(e)}")
+ logger.exception(
+ f"Error removing collection {collection_name} from index: {str(e)}"
+ )
return {"status": "error", "error": str(e)}
def search_library(
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.py
index 6e9aec0292..9d21f688ff 100644
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@ -1540,7 +1540,9 @@ def api_get_available_models():
), 500
-def _get_engine_icon_and_category(engine_data: dict, engine_class=None) -> tuple:
+def _get_engine_icon_and_category(
+ engine_data: dict, engine_class=None
+) -> tuple:
"""
Get icon emoji and category label for a search engine based on its attributes.
@@ -1553,17 +1555,17 @@ def _get_engine_icon_and_category(engine_data: dict, engine_class=None) -> tuple
"""
# Check attributes from either the class or the engine data
if engine_class:
- is_scientific = getattr(engine_class, 'is_scientific', False)
- is_generic = getattr(engine_class, 'is_generic', False)
- is_local = getattr(engine_class, 'is_local', False)
- is_news = getattr(engine_class, 'is_news', False)
- is_code = getattr(engine_class, 'is_code', False)
+ is_scientific = getattr(engine_class, "is_scientific", False)
+ is_generic = getattr(engine_class, "is_generic", False)
+ is_local = getattr(engine_class, "is_local", False)
+ is_news = getattr(engine_class, "is_news", False)
+ is_code = getattr(engine_class, "is_code", False)
else:
- is_scientific = engine_data.get('is_scientific', False)
- is_generic = engine_data.get('is_generic', False)
- is_local = engine_data.get('is_local', False)
- is_news = engine_data.get('is_news', False)
- is_code = engine_data.get('is_code', False)
+ is_scientific = engine_data.get("is_scientific", False)
+ is_generic = engine_data.get("is_generic", False)
+ is_local = engine_data.get("is_local", False)
+ is_news = engine_data.get("is_news", False)
+ is_code = engine_data.get("is_code", False)
# Return icon and category based on engine type
# Priority: local > scientific > news > code > generic > default
@@ -1614,14 +1616,20 @@ def api_get_available_search_engines():
# Handle relative imports
package = None
if module_path.startswith("."):
- package = "local_deep_research.web_search_engines"
+ package = (
+ "local_deep_research.web_search_engines"
+ )
module = import_module(module_path, package=package)
engine_class = getattr(module, class_name, None)
except Exception as e:
- logger.debug(f"Could not load engine class for {engine_id}: {e}")
+ logger.debug(
+ f"Could not load engine class for {engine_id}: {e}"
+ )
# Get icon and category from engine attributes
- icon, category = _get_engine_icon_and_category(engine_data, engine_class)
+ icon, category = _get_engine_icon_and_category(
+ engine_data, engine_class
+ )
# Build display name with icon and category
base_name = engine_data.get("display_name", engine_id)
diff --git a/src/local_deep_research/web/static/js/collection_details.js b/src/local_deep_research/web/static/js/collection_details.js
index 619d551942..49c26b5ea9 100644
--- a/src/local_deep_research/web/static/js/collection_details.js
+++ b/src/local_deep_research/web/static/js/collection_details.js
@@ -37,7 +37,7 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById('cancel-upload-btn').addEventListener('click', hideUploadModal);
// Setup close buttons
- document.querySelectorAll('.modal .close').forEach(btn => {
+ document.querySelectorAll('.modal .ldr-close').forEach(btn => {
btn.addEventListener('click', () => {
hideUploadModal();
});
@@ -162,10 +162,10 @@ function filterDocuments(filter) {
currentFilter = filter;
// Update button states
- document.querySelectorAll('.filter-controls .btn').forEach(btn => {
- btn.classList.remove('active');
+ document.querySelectorAll('.ldr-filter-controls .ldr-btn').forEach(btn => {
+ btn.classList.remove('ldr-active');
});
- event.target.classList.add('active');
+ event.target.classList.add('ldr-active');
renderDocuments();
}
@@ -194,7 +194,7 @@ function hideUploadModal() {
function handleDragOver(event) {
event.preventDefault();
event.stopPropagation();
- event.currentTarget.classList.add('drag-over');
+ event.currentTarget.classList.add('ldr-drag-over');
}
/**
@@ -203,7 +203,7 @@ function handleDragOver(event) {
function handleDragLeave(event) {
event.preventDefault();
event.stopPropagation();
- event.currentTarget.classList.remove('drag-over');
+ event.currentTarget.classList.remove('ldr-drag-over');
}
/**
@@ -212,7 +212,7 @@ function handleDragLeave(event) {
function handleDrop(event) {
event.preventDefault();
event.stopPropagation();
- event.currentTarget.classList.remove('drag-over');
+ event.currentTarget.classList.remove('ldr-drag-over');
const files = event.dataTransfer.files;
if (files.length > 0) {
diff --git a/src/local_deep_research/web/static/js/collections_manager.js b/src/local_deep_research/web/static/js/collections_manager.js
index 9258bf1aac..cc1d97b703 100644
--- a/src/local_deep_research/web/static/js/collections_manager.js
+++ b/src/local_deep_research/web/static/js/collections_manager.js
@@ -32,7 +32,7 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById('cancel-create-btn').addEventListener('click', hideCreateCollectionModal);
// Setup close buttons
- document.querySelectorAll('.modal .close').forEach(btn => {
+ document.querySelectorAll('.modal .ldr-close').forEach(btn => {
btn.addEventListener('click', () => {
hideCreateCollectionModal();
});
diff --git a/src/local_deep_research/web/static/js/rag_manager.js b/src/local_deep_research/web/static/js/rag_manager.js
index 94af9c849b..409569a9fd 100644
--- a/src/local_deep_research/web/static/js/rag_manager.js
+++ b/src/local_deep_research/web/static/js/rag_manager.js
@@ -973,16 +973,16 @@ function setupDragAndDrop() {
// Drag events
dropZone.addEventListener('dragover', (e) => {
e.preventDefault();
- dropZone.classList.add('dragging');
+ dropZone.classList.add('ldr-dragging');
});
dropZone.addEventListener('dragleave', () => {
- dropZone.classList.remove('dragging');
+ dropZone.classList.remove('ldr-dragging');
});
dropZone.addEventListener('drop', (e) => {
e.preventDefault();
- dropZone.classList.remove('dragging');
+ dropZone.classList.remove('ldr-dragging');
handleFiles(e.dataTransfer.files);
});
}
diff --git a/src/local_deep_research/web/templates/pages/collection_details.html b/src/local_deep_research/web/templates/pages/collection_details.html
index 6ce6c4208b..e437238eb2 100644
--- a/src/local_deep_research/web/templates/pages/collection_details.html
+++ b/src/local_deep_research/web/templates/pages/collection_details.html
@@ -3,7 +3,7 @@
{% block extra_head %}
<link rel="stylesheet" href="/static/css/rag_manager.css">
<style>
-.drop-zone {
+.ldr-drop-zone {
border: 2px dashed var(--ldr-border-color, #ccc);
border-radius: 8px;
padding: 40px 20px;
@@ -13,42 +13,42 @@
cursor: pointer;
}
-.drop-zone:hover {
+.ldr-drop-zone:hover {
border-color: var(--ldr-primary-color, #007bff);
background-color: var(--ldr-hover-bg, #e9ecef);
}
-.drop-zone.drag-over {
+.ldr-drop-zone.ldr-drag-over {
border-color: var(--ldr-success-color, #28a745);
background-color: var(--ldr-success-bg, #d4edda);
border-style: solid;
}
-.drop-zone-text {
+.ldr-drop-zone-text {
margin: 15px 0 5px;
font-size: 18px;
font-weight: 500;
}
-.drop-zone-subtext {
+.ldr-drop-zone-subtext {
margin: 5px 0 15px;
color: var(--ldr-text-secondary, #6c757d);
}
-.selected-files {
+.ldr-selected-files {
margin-top: 15px;
padding: 15px;
background-color: var(--ldr-card-bg, #f8f9fa);
border-radius: 6px;
}
-.selected-files ul {
+.ldr-selected-files ul {
list-style: none;
padding: 0;
margin: 10px 0 0;
}
-.selected-files li {
+.ldr-selected-files li {
padding: 8px 12px;
margin: 5px 0;
background-color: var(--ldr-bg, white);
@@ -59,32 +59,32 @@
gap: 10px;
}
-.selected-files li i {
+.ldr-selected-files li i {
color: var(--ldr-primary-color, #007bff);
}
</style>
{% endblock %}
{% block content %}
-<div class="rag-manager-container">
+<div class="ldr-rag-manager-container">
<!-- Back button and header -->
- <div class="rag-header">
+ <div class="ldr-rag-header">
<div style="display: flex; align-items: center; gap: 15px; margin-bottom: 10px;">
<a href="/library/collections" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Collections
</a>
</div>
<h1 id="collection-title"><i class="fas fa-folder-open"></i> <span id="collection-name">Loading...</span></h1>
- <p class="subtitle" id="collection-description"></p>
+ <p class="ldr-subtitle" id="collection-description"></p>
</div>
<!-- Collection Actions -->
- <div class="rag-section">
- <div class="section-header">
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
<h2><i class="fas fa-tasks"></i> Actions</h2>
</div>
- <div class="collection-actions-grid">
+ <div class="ldr-collection-actions-grid">
<button id="upload-files-btn" class="btn btn-primary btn-lg">
<i class="fas fa-upload"></i> Upload Files
</button>
@@ -101,65 +101,65 @@
</div>
<!-- Statistics -->
- <div class="rag-section">
- <div class="section-header">
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
<h2><i class="fas fa-chart-bar"></i> Statistics</h2>
</div>
- <div class="stats-grid">
- <div class="stat-card">
- <div class="stat-value" id="stat-total-docs">-</div>
- <div class="stat-label">Total Documents</div>
+ <div class="ldr-stats-grid">
+ <div class="ldr-stat-card">
+ <div class="ldr-stat-value" id="stat-total-docs">-</div>
+ <div class="ldr-stat-label">Total Documents</div>
</div>
- <div class="stat-card stat-success">
- <div class="stat-value" id="stat-indexed-docs">-</div>
- <div class="stat-label">Indexed Documents</div>
+ <div class="ldr-stat-card ldr-stat-success">
+ <div class="ldr-stat-value" id="stat-indexed-docs">-</div>
+ <div class="ldr-stat-label">Indexed Documents</div>
</div>
- <div class="stat-card stat-warning">
- <div class="stat-value" id="stat-unindexed-docs">-</div>
- <div class="stat-label">Not Indexed</div>
+ <div class="ldr-stat-card ldr-stat-warning">
+ <div class="ldr-stat-value" id="stat-unindexed-docs">-</div>
+ <div class="ldr-stat-label">Not Indexed</div>
</div>
- <div class="stat-card">
- <div class="stat-value" id="stat-total-chunks">-</div>
- <div class="stat-label">Total Chunks</div>
+ <div class="ldr-stat-card">
+ <div class="ldr-stat-value" id="stat-total-chunks">-</div>
+ <div class="ldr-stat-label">Total Chunks</div>
</div>
</div>
</div>
<!-- Indexing Progress -->
- <div id="indexing-progress" class="rag-section" style="display: none;">
- <div class="section-header">
+ <div id="indexing-progress" class="ldr-rag-section" style="display: none;">
+ <div class="ldr-section-header">
<h2><i class="fas fa-spinner fa-spin"></i> Indexing Progress</h2>
</div>
- <div class="progress-container">
- <div class="progress-bar">
- <div id="progress-fill" class="progress-fill" style="width: 0%"></div>
+ <div class="ldr-progress-container">
+ <div class="ldr-progress-bar">
+ <div id="progress-fill" class="ldr-progress-fill" style="width: 0%"></div>
</div>
- <p id="progress-text" class="progress-text">Starting...</p>
+ <p id="progress-text" class="ldr-progress-text">Starting...</p>
</div>
- <div id="progress-log" class="progress-log"></div>
+ <div id="progress-log" class="ldr-progress-log"></div>
</div>
<!-- Documents List -->
- <div class="rag-section">
- <div class="section-header">
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
<h2><i class="fas fa-file"></i> Documents</h2>
- <div class="filter-controls">
+ <div class="ldr-filter-controls">
<button class="btn btn-outline-primary active" onclick="filterDocuments('all')">All</button>
<button class="btn btn-outline-success" onclick="filterDocuments('indexed')">Indexed</button>
<button class="btn btn-outline-warning" onclick="filterDocuments('unindexed')">Not Indexed</button>
</div>
</div>
- <div id="documents-list" class="documents-list">
- <div class="loading-spinner">
+ <div id="documents-list" class="ldr-documents-list">
+ <div class="ldr-loading-spinner">
<i class="fas fa-spinner fa-spin"></i> Loading documents...
</div>
</div>
- <div id="no-documents-message" class="empty-state" style="display: none;">
+ <div id="no-documents-message" class="ldr-empty-state" style="display: none;">
<i class="fas fa-file fa-3x"></i>
<p>No documents in this collection yet</p>
<button class="btn btn-primary" onclick="document.getElementById('upload-files-btn').click()">
@@ -170,22 +170,22 @@
</div>
<!-- Upload Files Modal -->
-<div id="upload-files-modal" class="modal">
- <div class="modal-content">
- <div class="modal-header">
+<div id="upload-files-modal" class="ldr-modal">
+ <div class="ldr-modal-content">
+ <div class="ldr-modal-header">
<h3>Upload Files to Collection</h3>
- <span class="close">&times;</span>
+ <span class="ldr-close">&times;</span>
</div>
- <div class="modal-body">
+ <div class="ldr-modal-body">
<form id="upload-files-form">
- <div class="form-group">
+ <div class="ldr-form-group">
<label>Upload Files (PDF, TXT, MD, HTML)</label>
<!-- Drag and drop zone -->
- <div id="drop-zone" class="drop-zone">
+ <div id="drop-zone" class="ldr-drop-zone">
<i class="fas fa-cloud-upload-alt fa-3x"></i>
- <p class="drop-zone-text">Drag and drop files here</p>
- <p class="drop-zone-subtext">or</p>
+ <p class="ldr-drop-zone-text">Drag and drop files here</p>
+ <p class="ldr-drop-zone-subtext">or</p>
<button type="button" class="btn btn-primary" onclick="document.getElementById('files-input').click()">
<i class="fas fa-folder-open"></i> Browse Files
</button>
@@ -193,21 +193,21 @@
</div>
<!-- Selected files preview -->
- <div id="selected-files" class="selected-files" style="display: none;">
+ <div id="selected-files" class="ldr-selected-files" style="display: none;">
<p><strong>Selected files:</strong></p>
<ul id="file-list"></ul>
</div>
- <p class="form-help">Accepted formats: PDF, TXT, MD, HTML. Text will be extracted and stored securely.</p>
+ <p class="ldr-form-help">Accepted formats: PDF, TXT, MD, HTML. Text will be extracted and stored securely.</p>
</div>
- <div id="upload-progress" class="upload-progress" style="display: none;">
- <div class="progress-bar">
- <div class="progress-fill"></div>
+ <div id="upload-progress" class="ldr-upload-progress" style="display: none;">
+ <div class="ldr-progress-bar">
+ <div class="ldr-progress-fill"></div>
</div>
- <p class="progress-text"></p>
+ <p class="ldr-progress-text"></p>
</div>
- <div id="upload-results" class="upload-results" style="display: none;"></div>
- <div class="form-actions">
+ <div id="upload-results" class="ldr-upload-results" style="display: none;"></div>
+ <div class="ldr-form-actions">
<button type="button" class="btn btn-secondary" id="cancel-upload-btn">Cancel</button>
<button type="submit" class="btn btn-primary" id="upload-submit-btn">Upload Files</button>
</div>
diff --git a/src/local_deep_research/web/templates/pages/collections.html b/src/local_deep_research/web/templates/pages/collections.html
index a420b3a44d..bb8ba06878 100644
--- a/src/local_deep_research/web/templates/pages/collections.html
+++ b/src/local_deep_research/web/templates/pages/collections.html
@@ -5,51 +5,51 @@
{% endblock %}
{% block content %}
-<div class="rag-manager-container">
- <div class="rag-header">
+<div class="ldr-rag-manager-container">
+ <div class="ldr-rag-header">
<h1><i class="fas fa-folder-open"></i> Document Collections</h1>
- <p class="subtitle">Manage your document collections for RAG-enabled searches</p>
+ <p class="ldr-subtitle">Manage your document collections for RAG-enabled searches</p>
</div>
<!-- Collections Section -->
- <div class="rag-section">
- <div class="section-header">
+ <div class="ldr-rag-section">
+ <div class="ldr-section-header">
<h2><i class="fas fa-folder"></i> My Collections</h2>
<button id="create-collection-btn" class="btn btn-primary">
<i class="fas fa-plus"></i> Create Collection
</button>
</div>
- <div id="collections-container" class="collections-grid">
+ <div id="collections-container" class="ldr-collections-grid">
<!-- Collections will be loaded here -->
</div>
- <div id="no-collections-message" class="empty-state" style="display: none;">
+ <div id="no-collections-message" class="ldr-empty-state" style="display: none;">
<i class="fas fa-folder-open fa-3x"></i>
<p>No collections yet</p>
- <p class="text-muted">Create your first collection to organize your documents</p>
+ <p class="ldr-text-muted">Create your first collection to organize your documents</p>
</div>
</div>
</div>
<!-- Create Collection Modal -->
-<div id="create-collection-modal" class="modal">
- <div class="modal-content">
- <div class="modal-header">
+<div id="create-collection-modal" class="ldr-modal">
+ <div class="ldr-modal-content">
+ <div class="ldr-modal-header">
<h3>Create New Collection</h3>
- <span class="close">&times;</span>
+ <span class="ldr-close">&times;</span>
</div>
- <div class="modal-body">
+ <div class="ldr-modal-body">
<form id="create-collection-form">
- <div class="form-group">
+ <div class="ldr-form-group">
<label for="collection-name">Collection Name *</label>
<input type="text" id="collection-name" name="name" required placeholder="e.g., Research Papers, Work Documents">
</div>
- <div class="form-group">
+ <div class="ldr-form-group">
<label for="collection-description">Description</label>
<textarea id="collection-description" name="description" rows="3" placeholder="Describe what this collection is for..."></textarea>
</div>
- <div class="form-actions">
+ <div class="ldr-form-actions">
<button type="button" class="btn btn-secondary" id="cancel-create-btn">Cancel</button>
<button type="submit" class="btn btn-primary">Create Collection</button>
</div>
diff --git a/src/local_deep_research/web/templates/pages/document_details.html b/src/local_deep_research/web/templates/pages/document_details.html
index 5204a1cbf4..4905a64f1e 100644
--- a/src/local_deep_research/web/templates/pages/document_details.html
+++ b/src/local_deep_research/web/templates/pages/document_details.html
@@ -2,37 +2,37 @@
{% block extra_head %}
<style>
-.document-details-container {
+.ldr-document-details-container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
-.document-header {
+.ldr-document-header {
margin-bottom: 30px;
}
-.document-title {
+.ldr-document-title {
font-size: 28px;
font-weight: 600;
margin-bottom: 10px;
color: var(--ldr-text-primary, #212529);
}
-.document-subtitle {
+.ldr-document-subtitle {
font-size: 16px;
color: var(--ldr-text-secondary, #6c757d);
margin-bottom: 15px;
}
-.document-actions {
+.ldr-document-actions {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-top: 20px;
}
-.metadata-section {
+.ldr-metadata-section {
background-color: var(--ldr-card-bg, #ffffff);
border: 1px solid var(--ldr-border-color, #dee2e6);
border-radius: 8px;
@@ -40,7 +40,7 @@
margin-bottom: 20px;
}
-.metadata-section h2 {
+.ldr-metadata-section h2 {
font-size: 20px;
font-weight: 600;
margin-bottom: 15px;
@@ -49,19 +49,19 @@
padding-bottom: 10px;
}
-.metadata-grid {
+.ldr-metadata-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 15px;
}
-.metadata-item {
+.ldr-metadata-item {
display: flex;
flex-direction: column;
gap: 5px;
}
-.metadata-label {
+.ldr-metadata-label {
font-weight: 600;
color: var(--ldr-text-secondary, #6c757d);
font-size: 13px;
@@ -69,22 +69,22 @@
letter-spacing: 0.5px;
}
-.metadata-value {
+.ldr-metadata-value {
color: var(--ldr-text-primary, #212529);
font-size: 15px;
word-break: break-word;
}
-.metadata-value a {
+.ldr-metadata-value a {
color: var(--ldr-primary-color, #007bff);
text-decoration: none;
}
-.metadata-value a:hover {
+.ldr-metadata-value a:hover {
text-decoration: underline;
}
-.badge {
+.ldr-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 4px;
@@ -92,36 +92,36 @@
font-weight: 500;
}
-.badge-success {
+.ldr-badge-success {
background-color: var(--ldr-success-bg, #d4edda);
color: var(--ldr-success-color, #155724);
}
-.badge-info {
+.ldr-badge-info {
background-color: var(--ldr-info-bg, #d1ecf1);
color: var(--ldr-info-color, #0c5460);
}
-.badge-warning {
+.ldr-badge-warning {
background-color: var(--ldr-warning-bg, #fff3cd);
color: var(--ldr-warning-color, #856404);
}
-.authors-list {
+.ldr-authors-list {
list-style: none;
padding: 0;
margin: 0;
}
-.authors-list li {
+.ldr-authors-list li {
display: inline;
}
-.authors-list li:not(:last-child):after {
+.ldr-authors-list li:not(:last-child):after {
content: ", ";
}
-.content-preview {
+.ldr-content-preview {
background-color: var(--ldr-bg, #f8f9fa);
padding: 15px;
border-radius: 4px;
@@ -133,17 +133,17 @@
overflow-y: auto;
}
-.rag-status {
+.ldr-rag-status {
display: flex;
align-items: center;
gap: 10px;
}
-.rag-status i {
+.ldr-rag-status i {
font-size: 18px;
}
-.btn {
+.ldr-btn {
padding: 8px 16px;
border: none;
border-radius: 4px;
@@ -157,34 +157,34 @@
transition: all 0.2s;
}
-.btn-primary {
+.ldr-btn-primary {
background-color: var(--ldr-primary-color, #007bff);
color: white;
}
-.btn-primary:hover {
+.ldr-btn-primary:hover {
background-color: var(--ldr-primary-hover, #0056b3);
}
-.btn-secondary {
+.ldr-btn-secondary {
background-color: var(--ldr-secondary-bg, #6c757d);
color: white;
}
-.btn-secondary:hover {
+.ldr-btn-secondary:hover {
background-color: var(--ldr-secondary-hover, #545b62);
}
-.btn-success {
+.ldr-btn-success {
background-color: var(--ldr-success-color, #28a745);
color: white;
}
-.btn-success:hover {
+.ldr-btn-success:hover {
background-color: var(--ldr-success-hover, #218838);
}
-.empty-value {
+.ldr-empty-value {
color: var(--ldr-text-secondary, #6c757d);
font-style: italic;
}
@@ -192,20 +192,20 @@
{% endblock %}
{% block content %}
-<div class="document-details-container">
+<div class="ldr-document-details-container">
<!-- Back button and header -->
- <div class="document-header">
- <a href="/library" class="btn btn-secondary">
+ <div class="ldr-document-header">
+ <a href="/library" class="ldr-btn ldr-btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Library
</a>
- <h1 class="document-title">
+ <h1 class="ldr-document-title">
<i class="fas fa-file-pdf"></i> {{ document.document_title or "Untitled Document" }}
</h1>
{% if document.authors %}
- <div class="document-subtitle">
- <ul class="authors-list">
+ <div class="ldr-document-subtitle">
+ <ul class="ldr-authors-list">
{% for author in document.authors %}
<li>{{ author }}</li>
{% endfor %}
@@ -213,21 +213,21 @@
</div>
{% endif %}
- <div class="document-actions">
+ <div class="ldr-document-actions">
{% if document.file_exists and document.file_absolute_path %}
- <a href="/library/api/document/{{ document.id }}/pdf" target="_blank" class="btn btn-primary">
+ <a href="/library/api/document/{{ document.id }}/pdf" target="_blank" class="ldr-btn ldr-btn-primary">
<i class="fas fa-file-pdf"></i> View PDF
</a>
{% endif %}
{% if document.has_text %}
- <button onclick="viewText()" class="btn btn-success">
+ <button onclick="viewText()" class="ldr-btn ldr-btn-success">
<i class="fas fa-file-alt"></i> View Text
</button>
{% endif %}
{% if document.original_url %}
- <a href="{{ document.original_url }}" target="_blank" class="btn btn-secondary">
+ <a href="{{ document.original_url }}" target="_blank" class="ldr-btn ldr-btn-secondary">
<i class="fas fa-external-link-alt"></i> Original Source
</a>
{% endif %}
@@ -235,46 +235,46 @@
</div>
<!-- Document Information -->
- <div class="metadata-section">
+ <div class="ldr-metadata-section">
<h2><i class="fas fa-info-circle"></i> Document Information</h2>
- <div class="metadata-grid">
- <div class="metadata-item">
- <div class="metadata-label">Document ID</div>
- <div class="metadata-value"><code>{{ document.id }}</code></div>
+ <div class="ldr-metadata-grid">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Document ID</div>
+ <div class="ldr-metadata-value"><code>{{ document.id }}</code></div>
</div>
- <div class="metadata-item">
- <div class="metadata-label">File Type</div>
- <div class="metadata-value">
- <span class="badge badge-info">{{ document.file_type | upper }}</span>
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">File Type</div>
+ <div class="ldr-metadata-value">
+ <span class="ldr-badge ldr-badge-info">{{ document.file_type | upper }}</span>
</div>
</div>
- <div class="metadata-item">
- <div class="metadata-label">File Size</div>
- <div class="metadata-value">{{ document.file_size_formatted }}</div>
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">File Size</div>
+ <div class="ldr-metadata-value">{{ document.file_size_formatted }}</div>
</div>
- <div class="metadata-item">
- <div class="metadata-label">Download Status</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Download Status</div>
+ <div class="ldr-metadata-value">
{% if document.download_status == 'completed' %}
- <span class="badge badge-success">Completed</span>
+ <span class="ldr-badge ldr-badge-success">Completed</span>
{% else %}
- <span class="badge badge-warning">{{ document.download_status | title }}</span>
+ <span class="ldr-badge ldr-badge-warning">{{ document.download_status | title }}</span>
{% endif %}
</div>
</div>
- <div class="metadata-item">
- <div class="metadata-label">Downloaded At</div>
- <div class="metadata-value">{{ document.downloaded_at or "N/A" }}</div>
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Downloaded At</div>
+ <div class="ldr-metadata-value">{{ document.downloaded_at or "N/A" }}</div>
</div>
{% if document.domain %}
- <div class="metadata-item">
- <div class="metadata-label">Source Domain</div>
- <div class="metadata-value">{{ document.domain }}</div>
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Source Domain</div>
+ <div class="ldr-metadata-value">{{ document.domain }}</div>
</div>
{% endif %}
</div>
@@ -282,49 +282,49 @@
<!-- Academic Identifiers -->
{% if document.doi or document.arxiv_id or document.pmid or document.pmcid or document.isbn %}
- <div class="metadata-section">
+ <div class="ldr-metadata-section">
<h2><i class="fas fa-fingerprint"></i> Academic Identifiers</h2>
- <div class="metadata-grid">
+ <div class="ldr-metadata-grid">
{% if document.doi %}
- <div class="metadata-item">
- <div class="metadata-label">DOI</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">DOI</div>
+ <div class="ldr-metadata-value">
<a href="https://doi.org/{{ document.doi }}" target="_blank">{{ document.doi }}</a>
</div>
</div>
{% endif %}
{% if document.arxiv_id %}
- <div class="metadata-item">
- <div class="metadata-label">arXiv ID</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">arXiv ID</div>
+ <div class="ldr-metadata-value">
<a href="https://arxiv.org/abs/{{ document.arxiv_id }}" target="_blank">{{ document.arxiv_id }}</a>
</div>
</div>
{% endif %}
{% if document.pmid %}
- <div class="metadata-item">
- <div class="metadata-label">PubMed ID</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">PubMed ID</div>
+ <div class="ldr-metadata-value">
<a href="https://pubmed.ncbi.nlm.nih.gov/{{ document.pmid }}" target="_blank">{{ document.pmid }}</a>
</div>
</div>
{% endif %}
{% if document.pmcid %}
- <div class="metadata-item">
- <div class="metadata-label">PMC ID</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">PMC ID</div>
+ <div class="ldr-metadata-value">
<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/{{ document.pmcid }}" target="_blank">{{ document.pmcid }}</a>
</div>
</div>
{% endif %}
{% if document.isbn %}
- <div class="metadata-item">
- <div class="metadata-label">ISBN</div>
- <div class="metadata-value">{{ document.isbn }}</div>
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">ISBN</div>
+ <div class="ldr-metadata-value">{{ document.isbn }}</div>
</div>
{% endif %}
</div>
@@ -333,25 +333,25 @@
<!-- Publication Information -->
{% if document.published_date %}
- <div class="metadata-section">
+ <div class="ldr-metadata-section">
<h2><i class="fas fa-calendar"></i> Publication Information</h2>
- <div class="metadata-grid">
- <div class="metadata-item">
- <div class="metadata-label">Published Date</div>
- <div class="metadata-value">{{ document.published_date }}</div>
+ <div class="ldr-metadata-grid">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Published Date</div>
+ <div class="ldr-metadata-value">{{ document.published_date }}</div>
</div>
</div>
</div>
{% endif %}
<!-- RAG/Indexing Status -->
- <div class="metadata-section">
+ <div class="ldr-metadata-section">
<h2><i class="fas fa-search"></i> RAG & Indexing Status</h2>
- <div class="metadata-grid">
- <div class="metadata-item">
- <div class="metadata-label">RAG Indexed</div>
- <div class="metadata-value">
- <div class="rag-status">
+ <div class="ldr-metadata-grid">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">RAG Indexed</div>
+ <div class="ldr-metadata-value">
+ <div class="ldr-rag-status">
{% if document.rag_indexed %}
<i class="fas fa-check-circle" style="color: var(--ldr-success-color, #28a745);"></i>
<span>Yes ({{ document.chunk_count }} chunks)</span>
@@ -364,17 +364,17 @@
</div>
{% if document.last_indexed_at %}
- <div class="metadata-item">
- <div class="metadata-label">Last Indexed</div>
- <div class="metadata-value">{{ document.last_indexed_at }}</div>
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Last Indexed</div>
+ <div class="ldr-metadata-value">{{ document.last_indexed_at }}</div>
</div>
{% endif %}
{% if document.has_text %}
- <div class="metadata-item">
- <div class="metadata-label">Text Content</div>
- <div class="metadata-value">
- <div class="rag-status">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Text Content</div>
+ <div class="ldr-metadata-value">
+ <div class="ldr-rag-status">
<i class="fas fa-file-alt" style="color: var(--ldr-success-color, #28a745);"></i>
<span>Available ({{ document.word_count or 0 }} words)</span>
</div>
@@ -386,20 +386,20 @@
<!-- File Path Information -->
{% if document.file_path %}
- <div class="metadata-section">
+ <div class="ldr-metadata-section">
<h2><i class="fas fa-folder-open"></i> File Location</h2>
- <div class="metadata-grid">
- <div class="metadata-item">
- <div class="metadata-label">File Path</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-grid">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">File Path</div>
+ <div class="ldr-metadata-value">
<code>{{ document.file_path }}</code>
</div>
</div>
{% if document.file_absolute_path %}
- <div class="metadata-item">
- <div class="metadata-label">Absolute Path</div>
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-label">Absolute Path</div>
+ <div class="ldr-metadata-value">
<code>{{ document.file_absolute_path }}</code>
</div>
</div>
@@ -410,10 +410,10 @@
<!-- Original URL -->
{% if document.original_url %}
- <div class="metadata-section">
+ <div class="ldr-metadata-section">
<h2><i class="fas fa-link"></i> Source URL</h2>
- <div class="metadata-item">
- <div class="metadata-value">
+ <div class="ldr-metadata-item">
+ <div class="ldr-metadata-value">
<a href="{{ document.original_url }}" target="_blank">{{ document.original_url }}</a>
</div>
</div>
@@ -447,12 +447,12 @@ function viewText() {
word-wrap: break-word;
font-family: inherit;
}
- .header {
+ .ldr-header {
border-bottom: 2px solid #007bff;
padding-bottom: 10px;
margin-bottom: 20px;
}
- .meta {
+ .ldr-meta {
color: #6c757d;
font-size: 14px;
margin-bottom: 20px;
@@ -460,10 +460,10 @@ function viewText() {
</style>
</head>
<body>
- <div class="header">
+ <div class="ldr-header">
<h1>${data.title || 'Document Text'}</h1>
</div>
- <div class="meta">
+ <div class="ldr-meta">
<strong>Extraction Method:</strong> ${data.extraction_method || 'Unknown'}<br>
<strong>Word Count:</strong> ${data.word_count || 'Unknown'}
</div>
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_collection.py b/src/local_deep_research/web_search_engines/engines/search_engine_collection.py
index adc354e387..1f4749d751 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_collection.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_collection.py
@@ -62,7 +62,7 @@ class CollectionSearchEngine(LibraryRAGSearchEngine):
If the collection has stored embedding settings, use those instead of global settings.
"""
if not self.username:
- logger.warning(f"Cannot load collection settings without username")
+ logger.warning("Cannot load collection settings without username")
return
try:
@@ -70,9 +70,11 @@ class CollectionSearchEngine(LibraryRAGSearchEngine):
from ...database.session_context import get_user_db_session
with get_user_db_session(self.username) as db_session:
- collection = db_session.query(LibraryCollection).filter_by(
- id=self.collection_id
- ).first()
+ collection = (
+ db_session.query(LibraryCollection)
+ .filter_by(id=self.collection_id)
+ .first()
+ )
if not collection:
logger.warning(f"Collection {self.collection_id} not found")
@@ -87,7 +89,9 @@ class CollectionSearchEngine(LibraryRAGSearchEngine):
self.embedding_model = collection.embedding_model
self.embedding_provider = collection.embedding_model_type
self.chunk_size = collection.chunk_size or self.chunk_size
- self.chunk_overlap = collection.chunk_overlap or self.chunk_overlap
+ self.chunk_overlap = (
+ collection.chunk_overlap or self.chunk_overlap
+ )
else:
logger.warning(
f"Collection {self.collection_id} has no embedding metadata stored. "
@@ -95,7 +99,9 @@ class CollectionSearchEngine(LibraryRAGSearchEngine):
)
except Exception:
- logger.exception(f"Error loading collection {self.collection_id} settings")
+ logger.exception(
+ f"Error loading collection {self.collection_id} settings"
+ )
def search(
self,
@@ -119,14 +125,18 @@ class CollectionSearchEngine(LibraryRAGSearchEngine):
# Get results from parent (all library documents)
# Request 3x the limit to ensure we have enough after filtering
all_results = super().search(
- query, limit=limit * 3, llm_callback=llm_callback, extra_params=extra_params
+ query,
+ limit=limit * 3,
+ llm_callback=llm_callback,
+ extra_params=extra_params,
)
# Filter to only results from this collection
filtered_results = [
result
for result in all_results
- if result.get("metadata", {}).get("collection") == self.collection_key
+ if result.get("metadata", {}).get("collection")
+ == self.collection_key
]
# Limit to requested number
diff --git a/src/local_deep_research/web_search_engines/search_engines_config.py b/src/local_deep_research/web_search_engines/search_engines_config.py
index 11132e6e56..28ec530508 100644
--- a/src/local_deep_research/web_search_engines/search_engines_config.py
+++ b/src/local_deep_research/web_search_engines/search_engines_config.py
@@ -247,7 +247,9 @@ def search_config(
# Get username from settings_snapshot if available
collection_username = (
- settings_snapshot.get("_username") if settings_snapshot else username
+ settings_snapshot.get("_username")
+ if settings_snapshot
+ else username
)
if collection_username: