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: Fix citation formatting issues and add title fields to news subscriptions

LearningCircuit1c44b0f02a2e
diff --git a/src/local_deep_research/news/flask_api.py b/src/local_deep_research/news/flask_api.py
index 422e798278..013e37df88 100644
--- a/src/local_deep_research/news/flask_api.py
+++ b/src/local_deep_research/news/flask_api.py
@@ -443,6 +443,9 @@ def run_subscription_now(subscription_id: str) -> Dict[str, Any]:
], # Store original query with placeholder
"processed_query": query, # Store processed query with replaced date
"news_date": current_date, # Store the actual date used
+ "title": subscription.get("name")
+ if subscription.get("name")
+ else None,
},
}
@@ -971,6 +974,7 @@ def check_overdue_subscriptions():
"original_query": sub.query_or_topic,
"processed_query": query,
"news_date": current_date,
+ "title": sub.name if sub.name else None,
},
}
diff --git a/src/local_deep_research/news/subscription_manager/scheduler.py b/src/local_deep_research/news/subscription_manager/scheduler.py
index 404055437b..141b4e2710 100644
--- a/src/local_deep_research/news/subscription_manager/scheduler.py
+++ b/src/local_deep_research/news/subscription_manager/scheduler.py
@@ -600,7 +600,7 @@ class NewsScheduler:
f"Using user's default search tool: '{default_search_tool}' for {subscription['id']}"
)
- logger.info(
+ logger.debug(
f"Settings snapshot has {len(settings_snapshot)} settings"
)
# Log a few key settings to verify they're present
@@ -619,6 +619,7 @@ class NewsScheduler:
"subscription_id": subscription["id"],
"triggered_by": "scheduler",
"subscription_name": subscription["name"],
+ "title": subscription["name"] if subscription["name"] else None,
"scheduled_at": datetime.utcnow().isoformat(),
"original_query": subscription["original_query"],
"user_id": username,
diff --git a/src/local_deep_research/text_optimization/citation_formatter.py b/src/local_deep_research/text_optimization/citation_formatter.py
index 626284971d..0941399f97 100644
--- a/src/local_deep_research/text_optimization/citation_formatter.py
+++ b/src/local_deep_research/text_optimization/citation_formatter.py
@@ -29,7 +29,8 @@ class CitationFormatter:
self.citation_pattern = re.compile(r"(?<!\[)\[(\d+)\](?!\])")
self.comma_citation_pattern = re.compile(r"\[(\d+(?:,\s*\d+)+)\]")
self.sources_pattern = re.compile(
- r"^\[(\d+)\]\s*(.+?)(?:\n\s*URL:\s*(.+?))?$", re.MULTILINE
+ r"^\[(\d+(?:,\s*\d+)*)\]\s*(.+?)(?:\n\s*URL:\s*(.+?))?$",
+ re.MULTILINE,
)
def format_document(self, content: str) -> str:
@@ -106,10 +107,19 @@ class CitationFormatter:
matches = list(self.sources_pattern.finditer(sources_content))
for match in matches:
- citation_num = match.group(1)
+ citation_nums_str = match.group(1)
title = match.group(2).strip()
url = match.group(3).strip() if match.group(3) else ""
- sources[citation_num] = (title, url)
+
+ # Handle comma-separated citation numbers like [36, 3]
+ # Split by comma and strip whitespace
+ individual_nums = [
+ num.strip() for num in citation_nums_str.split(",")
+ ]
+
+ # Add an entry for each individual number
+ for num in individual_nums:
+ sources[num] = (title, url)
return sources
@@ -457,7 +467,8 @@ class RISExporter:
def __init__(self):
self.sources_pattern = re.compile(
- r"^\[(\d+)\]\s*(.+?)(?:\n\s*URL:\s*(.+?))?$", re.MULTILINE
+ r"^\[(\d+(?:,\s*\d+)*)\]\s*(.+?)(?:\n\s*URL:\s*(.+?))?$",
+ re.MULTILINE,
)
def export_to_ris(self, content: str) -> str:
diff --git a/src/local_deep_research/web/routes/history_routes.py b/src/local_deep_research/web/routes/history_routes.py
index 9a725ef613..3236739951 100644
--- a/src/local_deep_research/web/routes/history_routes.py
+++ b/src/local_deep_research/web/routes/history_routes.py
@@ -50,6 +50,7 @@ def get_history():
for research in results:
item = {
"id": research.id,
+ "title": research.title,
"query": research.query,
"mode": research.mode,
"status": research.status,
diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.py
index 50951bedb7..8c677f4d82 100644
--- a/src/local_deep_research/web/routes/research_routes.py
+++ b/src/local_deep_research/web/routes/research_routes.py
@@ -1193,6 +1193,7 @@ def get_research_report(research_id):
{
"content": content,
"metadata": {
+ "title": research.title if research.title else None,
"query": research.query,
"mode": research.mode if research.mode else None,
"created_at": research.created_at
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index d08d103492..f1cdd1a304 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -863,11 +863,7 @@ def run_research_process(
)
# Prepare complete report content
- full_report_content = f"""# Quick Research Summary
-
-Query: {query}
-
-{formatted_content}
+ full_report_content = f"""{formatted_content}
## Research Metrics
- Search Iterations: {results["iterations"]}
diff --git a/src/local_deep_research/web/templates/pages/news-subscription-form.html b/src/local_deep_research/web/templates/pages/news-subscription-form.html
index d5cfe5d9d1..dbd7006bf9 100644
--- a/src/local_deep_research/web/templates/pages/news-subscription-form.html
+++ b/src/local_deep_research/web/templates/pages/news-subscription-form.html
@@ -198,6 +198,7 @@
<div class="mb-3">
<label for="subscription-strategy" class="form-label">Search Strategy</label>
<select class="form-select" id="subscription-strategy">
+ <option value="news_aggregation" {% if (subscription and subscription.search_strategy == 'news_aggregation') or (not subscription and default_settings.search_strategy == 'news_aggregation') %}selected{% endif %}>News Aggregation (Optimized for news)</option>
<option value="source-based" {% if (subscription and subscription.search_strategy == 'source-based') or (not subscription and default_settings.search_strategy == 'source-based') %}selected{% endif %}>Source Based (Comprehensive research)</option>
<option value="focused-iteration" {% if (subscription and subscription.search_strategy == 'focused-iteration') or (not subscription and default_settings.search_strategy == 'focused-iteration') %}selected{% endif %}>Focused Iteration (Fast Q&A)</option>
</select>