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: resolve utils module import error in Research Library

LearningCircuitff521f041625
diff --git a/src/local_deep_research/research_library/utils.py b/src/local_deep_research/research_library/utils.py
deleted file mode 100644
index 255e835b7e..0000000000
--- a/src/local_deep_research/research_library/utils.py
+++ /dev/null
@@ -1,123 +0,0 @@
-"""Shared utility functions for the Research Library."""
-
-import hashlib
-import os
-import subprocess
-import sys
-from pathlib import Path
-
-from loguru import logger
-
-
-def get_url_hash(url: str) -> str:
- """
- Generate a SHA256 hash of a URL.
-
- Args:
- url: The URL to hash
-
- Returns:
- The SHA256 hash of the URL
- """
- return hashlib.sha256(url.lower().encode()).hexdigest()
-
-
-def get_library_storage_path(username: str) -> Path:
- """
- Get the storage path for a user's library.
-
- Args:
- username: The username
-
- Returns:
- Path to the user's library storage directory
- """
- base_dir = (
- Path.home() / "Documents" / "LocalDeepResearch" / "Library" / username
- )
- base_dir.mkdir(parents=True, exist_ok=True)
- return base_dir
-
-
-def open_file_location(file_path: str) -> bool:
- """
- Open the file location in the system file manager.
-
- Args:
- file_path: Path to the file
-
- Returns:
- True if successful, False otherwise
- """
- try:
- folder = str(Path(file_path).parent)
- if sys.platform == "win32":
- os.startfile(folder)
- elif sys.platform == "darwin": # macOS
- subprocess.run(["open", folder])
- else: # Linux
- subprocess.run(["xdg-open", folder])
- return True
- except Exception:
- logger.exception("Failed to open file location")
- return False
-
-
-def get_relative_library_path(absolute_path: str, username: str) -> str:
- """
- Get the relative path from the library root.
-
- Args:
- absolute_path: The absolute file path
- username: The username
-
- Returns:
- The relative path from the library root
- """
- try:
- library_root = get_library_storage_path(username)
- return str(Path(absolute_path).relative_to(library_root))
- except ValueError:
- # Path is not relative to library root
- return Path(absolute_path).name
-
-
-def get_absolute_library_path(relative_path: str, username: str) -> Path:
- """
- Get the absolute path from a relative library path.
-
- Args:
- relative_path: The relative path from library root
- username: The username
-
- Returns:
- The absolute path
- """
- library_root = get_library_storage_path(username)
- return library_root / relative_path
-
-
-def get_absolute_path_from_settings(relative_path: str) -> Path:
- """
- Get absolute path using settings manager for library root.
-
- Args:
- relative_path: The relative path from library root
-
- Returns:
- The absolute path
- """
- from ..utilities.db_utils import get_settings_manager
-
- settings = get_settings_manager()
- library_root = Path(
- settings.get_setting(
- "research_library.storage_path",
- "~/.local-deep-research/library",
- )
- ).expanduser()
-
- if not relative_path:
- return library_root
-
- return library_root / relative_path
diff --git a/src/local_deep_research/research_library/utils/__init__.py b/src/local_deep_research/research_library/utils/__init__.py
index 9e7776f832..a6ba7d2279 100644
--- a/src/local_deep_research/research_library/utils/__init__.py
+++ b/src/local_deep_research/research_library/utils/__init__.py
@@ -1 +1,123 @@
-"""Research Library Utilities"""
+"""Shared utility functions for the Research Library."""
+
+import hashlib
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+from loguru import logger
+
+
+def get_url_hash(url: str) -> str:
+ """
+ Generate a SHA256 hash of a URL.
+
+ Args:
+ url: The URL to hash
+
+ Returns:
+ The SHA256 hash of the URL
+ """
+ return hashlib.sha256(url.lower().encode()).hexdigest()
+
+
+def get_library_storage_path(username: str) -> Path:
+ """
+ Get the storage path for a user's library.
+
+ Args:
+ username: The username
+
+ Returns:
+ Path to the user's library storage directory
+ """
+ base_dir = (
+ Path.home() / "Documents" / "LocalDeepResearch" / "Library" / username
+ )
+ base_dir.mkdir(parents=True, exist_ok=True)
+ return base_dir
+
+
+def open_file_location(file_path: str) -> bool:
+ """
+ Open the file location in the system file manager.
+
+ Args:
+ file_path: Path to the file
+
+ Returns:
+ True if successful, False otherwise
+ """
+ try:
+ folder = str(Path(file_path).parent)
+ if sys.platform == "win32":
+ os.startfile(folder)
+ elif sys.platform == "darwin": # macOS
+ subprocess.run(["open", folder])
+ else: # Linux
+ subprocess.run(["xdg-open", folder])
+ return True
+ except Exception:
+ logger.exception("Failed to open file location")
+ return False
+
+
+def get_relative_library_path(absolute_path: str, username: str) -> str:
+ """
+ Get the relative path from the library root.
+
+ Args:
+ absolute_path: The absolute file path
+ username: The username
+
+ Returns:
+ The relative path from the library root
+ """
+ try:
+ library_root = get_library_storage_path(username)
+ return str(Path(absolute_path).relative_to(library_root))
+ except ValueError:
+ # Path is not relative to library root
+ return Path(absolute_path).name
+
+
+def get_absolute_library_path(relative_path: str, username: str) -> Path:
+ """
+ Get the absolute path from a relative library path.
+
+ Args:
+ relative_path: The relative path from library root
+ username: The username
+
+ Returns:
+ The absolute path
+ """
+ library_root = get_library_storage_path(username)
+ return library_root / relative_path
+
+
+def get_absolute_path_from_settings(relative_path: str) -> Path:
+ """
+ Get absolute path using settings manager for library root.
+
+ Args:
+ relative_path: The relative path from library root
+
+ Returns:
+ The absolute path
+ """
+ from ...utilities.db_utils import get_settings_manager
+
+ settings = get_settings_manager()
+ library_root = Path(
+ settings.get_setting(
+ "research_library.storage_path",
+ "~/.local-deep-research/library",
+ )
+ ).expanduser()
+
+ if not relative_path:
+ return library_root
+
+ return library_root / relative_path