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.

Apply ruff-format: Fix line length for logger.exception() calls

tombii190ba5a1fb43
diff --git a/notifications/jinja_templates/research_completed.html b/notifications/jinja_templates/research_completed.html
deleted file mode 100644
index 170ea74b63..0000000000
--- a/notifications/jinja_templates/research_completed.html
+++ /dev/null
@@ -1,2 +0,0 @@
-{{ title }}
-{{ body }}
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 12146abb15..690fd3c117 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -106,6 +106,7 @@ include-package-data = true
[tool.setuptools.package-data]
"local_deep_research.web" = ["templates/*", "static/*", "static/**/*"]
"local_deep_research.defaults" = ["*.toml", "*.py", "*.template", ".env.template"]
+"local_deep_research.notifications" = ["templates/*.jinja2"]
diff --git a/src/local_deep_research/notifications/templates.py b/src/local_deep_research/notifications/templates.py
index a313ef2e6a..c89a5f8d0b 100644
--- a/src/local_deep_research/notifications/templates.py
+++ b/src/local_deep_research/notifications/templates.py
@@ -82,7 +82,9 @@ class NotificationTemplate:
f"Jinja2 environment initialized with templates from: {template_dir}"
)
except Exception as e:
- logger.error(f"Failed to initialize Jinja2 environment: {e}")
+ logger.exception(
+ f"Failed to initialize Jinja2 environment: {e}"
+ )
return None
return cls._jinja_env
@@ -145,7 +147,7 @@ class NotificationTemplate:
return {"title": title, "body": body}
except Exception as e:
- logger.error(
+ logger.exception(
f"Error rendering Jinja2 template {template_file}: {e}"
)
# Fall back to simple format
@@ -165,38 +167,14 @@ class NotificationTemplate:
Returns:
Dict with 'title' and 'body' keys
"""
- fallbacks = {
- EventType.RESEARCH_COMPLETED: {
- "title": "Research Completed: {query}",
- "body": "Your research on '{query}' has completed successfully.\n\nSummary: {summary}\n\nView full results: {url}",
- },
- EventType.RESEARCH_FAILED: {
- "title": "Research Failed: {query}",
- "body": "Research on '{query}' failed.\n\nError: {error}\n\nPlease check the logs for more details.",
- },
- EventType.TEST: {
- "title": "Test Notification",
- "body": "This is a test notification from Local Deep Research.\n\nIf you received this, your notification service is configured correctly!",
- },
- }
-
- template = fallbacks.get(
- event_type,
- {
- "title": f"Notification: {event_type.value}",
- "body": str(context),
- },
- )
+ # Generic fallback that works for all event types
+ # Reduces maintenance burden - no need to update for new events
+ event_display_name = event_type.value.replace("_", " ").title()
- try:
- title = template["title"].format(**context)
- body = template["body"].format(**context)
- return {"title": title, "body": body}
- except KeyError:
- return {
- "title": f"Notification: {event_type.value}",
- "body": str(context),
- }
+ return {
+ "title": f"Notification: {event_display_name}",
+ "body": f"Event: {event_display_name}\n\nDetails: {str(context)}\n\nPlease check the application for complete information.",
+ }
@classmethod
def get_required_context(cls, event_type: EventType) -> list[str]:
@@ -216,27 +194,9 @@ class NotificationTemplate:
# Try to parse Jinja2 template to get variables
jinja_env = cls._get_jinja_env()
if jinja_env is None:
- # Fallback to hardcoded variable lists
- fallback_vars = {
- EventType.RESEARCH_COMPLETED: ["query", "summary", "url"],
- EventType.RESEARCH_FAILED: ["query", "error"],
- EventType.RESEARCH_QUEUED: ["query", "position", "wait_time"],
- EventType.SUBSCRIPTION_UPDATE: [
- "subscription_name",
- "item_count",
- "url",
- ],
- EventType.SUBSCRIPTION_ERROR: ["subscription_name", "error"],
- EventType.API_QUOTA_WARNING: [
- "service",
- "current",
- "limit",
- "reset_time",
- ],
- EventType.AUTH_ISSUE: ["service"],
- EventType.TEST: [],
- }
- return fallback_vars.get(event_type, [])
+ # No Jinja2 environment available, return empty list
+ # With simplified fallback approach, we don't need to track required variables
+ return []
try:
template = jinja_env.get_template(template_file)
@@ -264,5 +224,7 @@ class NotificationTemplate:
return sorted(variables)
except Exception as e:
- logger.error(f"Error parsing Jinja2 template {template_file}: {e}")
+ logger.exception(
+ f"Error parsing Jinja2 template {template_file}: {e}"
+ )
return []