~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor: Remove dead code and useless fallbacks
LearningCircuit309dfe48c03c
diff --git a/src/local_deep_research/news/utils/headline_generator.py b/src/local_deep_research/news/utils/headline_generator.pyindex beed97ece6..0b2c0c2a30 100644--- a/src/local_deep_research/news/utils/headline_generator.py+++ b/src/local_deep_research/news/utils/headline_generator.py@@ -26,66 +26,8 @@ def generate_headline(if llm_headline:return llm_headline- # If query is already short enough, use it as fallback- if len(query) <= max_length:- return query.strip()-- # If all else fails, truncate intelligently- return _truncate_intelligently(query, max_length)---def _extract_simple_headline(query: str) -> Optional[str]:- """Extract headline from common query patterns."""- query_lower = query.lower()-- # News table queries- if "CREATE TABLE" in query and "breaking news" in query_lower:- return "Today's Breaking News Analysis"-- # Common news search patterns- patterns = {- "breaking news today": "Today's Breaking News",- "latest news stories": "Latest News Stories",- "news analysis": "News Analysis Report",- "find news about": "News Update",- "research news on": "News Research Report",- "analyze news": "News Analysis",- "top stories": "Top Stories Today",- "current events": "Current Events Analysis",- }-- for pattern, headline in patterns.items():- if pattern in query_lower:- # Extract topic if possible- topic = _extract_topic(query, pattern)- if topic:- return f"{headline}: {topic}"- return headline-- return None---def _extract_topic(query: str, pattern: str) -> Optional[str]:- """Extract the main topic from a query after a pattern."""- query_lower = query.lower()- idx = query_lower.find(pattern)- if idx != -1:- # Get text after the pattern- remaining = query[idx + len(pattern) :].strip()- # Take first few words as topic- words = remaining.split()[:3]- if words:- topic = " ".join(words)- # Clean up common words- topic = (- topic.replace("about", "")- .replace("on", "")- .replace("the", "")- .strip()- )- if topic and len(topic) < 30:- return topic.title()- return None+ # No fallback - if LLM fails, indicate failure+ return "[Headline generation failed]"def _generate_with_llm(@@ -137,41 +79,3 @@ Generate only the headline text, nothing else."""logger.debug(f"LLM headline generation failed: {e}")return None---def _truncate_intelligently(query: str, max_length: int) -> str:- """Intelligently truncate a query to make a headline."""- # Remove common prefixes- prefixes_to_remove = [- "Find up to",- "Search for",- "Get information about",- "Research on",- "Analysis of",- "SEARCH STRATEGY:",- "CREATE TABLE:",- ]-- truncated = query- for prefix in prefixes_to_remove:- if truncated.upper().startswith(prefix.upper()):- truncated = truncated[len(prefix) :].strip()-- # Take first sentence or clause- for delimiter in [".", "?", "!", "\n", ":", ";", " - "]:- parts = truncated.split(delimiter)- if parts and parts[0].strip():- truncated = parts[0].strip()- if len(truncated) <= max_length:- return truncated-- # If still too long, truncate at word boundary- if len(truncated) > max_length:- truncated = truncated[:max_length]- # Find last complete word- last_space = truncated.rfind(" ")- if last_space > max_length * 0.7: # Keep at least 70% of the length- truncated = truncated[:last_space]- return truncated.strip() + "..."-- return truncateddiff --git a/src/local_deep_research/news/utils/topic_generator.py b/src/local_deep_research/news/utils/topic_generator.pyindex 1c50638dde..e7ef918300 100644--- a/src/local_deep_research/news/utils/topic_generator.py+++ b/src/local_deep_research/news/utils/topic_generator.py@@ -4,7 +4,7 @@ Uses LLM to extract relevant topics/tags from news content."""from loguru import logger-from typing import List, Dict, Any+from typing import Listimport json@@ -107,78 +107,6 @@ Return ONLY a JSON array of topic strings, like: ["Topic 1", "Topic 2", "Topic 3return []-def _extract_fallback_topics(- query: str, findings: str, category: str-) -> List[str]:- """Extract topics using pattern matching as fallback."""- topics = []-- # Add category if provided- if category and category not in ["News", "General"]:- topics.append(category)-- # Common news topics to look for- topic_patterns = {- # Geopolitical- "ukraine": "Ukraine",- "russia": "Russia",- "china": "China",- "united states": "United States",- "israel": "Israel",- "gaza": "Gaza",- "palestine": "Palestine",- "iran": "Iran",- # Event types- "conflict": "Conflict",- "war": "War",- "election": "Election",- "economy": "Economy",- "market": "Markets",- "disaster": "Disaster",- "earthquake": "Earthquake",- "flood": "Flooding",- "hurricane": "Hurricane",- "pandemic": "Pandemic",- "covid": "COVID-19",- # Sectors- "technology": "Technology",- "ai": "AI",- "climate": "Climate",- "energy": "Energy",- "health": "Healthcare",- "finance": "Finance",- "crypto": "Cryptocurrency",- # Organizations- "nato": "NATO",- "un": "United Nations",- "eu": "European Union",- # Removed "who": "WHO" - too many false positives as djpetti noted- }-- # Combine query and findings for analysis- text_to_analyze = (query + " " + findings).lower()-- # Extract matching topics- for pattern, topic in topic_patterns.items():- if pattern in text_to_analyze and topic not in topics:- topics.append(topic)-- # Extract year if mentioned- import re-- years = re.findall(r"\b20\d{2}\b", text_to_analyze)- if years:- latest_year = max(years)- if latest_year not in topics:- topics.append(latest_year)-- # Add "Breaking News" if it's a breaking news query- if "breaking" in text_to_analyze and "Breaking News" not in topics:- topics.append("Breaking News")-- return topics--def _validate_topics(topics: List[str], max_topics: int) -> List[str]:"""Validate and clean topics."""valid_topics = []@@ -212,35 +140,3 @@ def _validate_topics(topics: List[str], max_topics: int) -> List[str]:valid_topics = ["[No valid topics]"]return valid_topics---def batch_generate_topics(- news_items: List[Dict[str, Any]], max_topics_per_item: int = 5-) -> Dict[str, List[str]]:- """- Generate topics for multiple news items in batch.-- Args:- news_items: List of news item dictionaries- max_topics_per_item: Maximum topics per news item-- Returns:- Dictionary mapping news item IDs to topic lists- """- results = {}-- for item in news_items:- item_id = item.get("id", "")- if not item_id:- continue-- topics = generate_topics(- query=item.get("headline", ""),- findings=item.get("findings", ""),- category=item.get("category", ""),- max_topics=max_topics_per_item,- )-- results[item_id] = topics-- return results