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.

feat: Integrate LLM domain classification with link analytics

LearningCircuitf91aa8430fa3
diff --git a/src/local_deep_research/web/routes/metrics_routes.py b/src/local_deep_research/web/routes/metrics_routes.py
index e3f551c97c..7af8f6a7fc 100644
--- a/src/local_deep_research/web/routes/metrics_routes.py
+++ b/src/local_deep_research/web/routes/metrics_routes.py
@@ -180,17 +180,19 @@ def get_link_analytics(period="30d", username=None):
# Extract domains from URLs
from urllib.parse import urlparse
+ from ...domain_classifier.classifier import DomainClassifier
domain_counts = {}
domain_researches = {} # Track which researches used each domain
source_types = {}
- academic_sources = 0
- general_sources = 0
- news_sources = 0
- reference_sources = 0
temporal_data = {} # Track links over time
- content_types = {} # Track content types
domain_connections = {} # Track domain co-occurrences
+
+ # Generic category counting from LLM classifications
+ category_counts = {}
+
+ # Initialize domain classifier for LLM-based categorization
+ domain_classifier = DomainClassifier(username=username)
quality_metrics = {
"with_title": 0,
"with_preview": 0,
@@ -224,8 +226,19 @@ def get_link_analytics(period="30d", username=None):
temporal_data.get(date_str, 0) + 1
)
- # All sources are unclassified until LLM classifier processes them
- general_sources += 1
+ # Count categories from LLM classification
+ classification = domain_classifier.get_classification(
+ domain
+ )
+ if classification:
+ category = classification.category
+ category_counts[category] = (
+ category_counts.get(category, 0) + 1
+ )
+ else:
+ category_counts["Unclassified"] = (
+ category_counts.get("Unclassified", 0) + 1
+ )
# Track source type from metadata if available
if resource.source_type:
@@ -242,12 +255,6 @@ def get_link_analytics(period="30d", username=None):
if resource.title and resource.content_preview:
quality_metrics["with_both"] += 1
- # Content types will be available after LLM classification
- # For now, mark as unclassified
- content_types["unclassified"] = (
- content_types.get("unclassified", 0) + 1
- )
-
# Track domain co-occurrences for network visualization
research_id = resource.research_id
if research_id not in domain_connections:
@@ -347,11 +354,38 @@ def get_link_analytics(period="30d", username=None):
"others": others_count,
},
"source_type_analysis": source_types,
+ "category_distribution": category_counts,
+ # Backward compatibility for frontend
"academic_vs_general": {
- "academic": academic_sources,
- "news": news_sources,
- "reference": reference_sources,
- "general": general_sources,
+ "academic": category_counts.get(
+ "Academic & Research", 0
+ ),
+ "news": category_counts.get("News & Media", 0),
+ "reference": sum(
+ [
+ category_counts.get(
+ "Reference & Documentation", 0
+ ),
+ category_counts.get(
+ "Government & Organization", 0
+ ),
+ ]
+ ),
+ "general": sum(
+ [
+ category_counts.get("Technology", 0),
+ category_counts.get("Business & Commerce", 0),
+ category_counts.get("Social & Community", 0),
+ category_counts.get(
+ "Entertainment & Lifestyle", 0
+ ),
+ category_counts.get(
+ "Professional & Industry", 0
+ ),
+ category_counts.get("Other", 0),
+ category_counts.get("Unclassified", 0),
+ ]
+ ),
},
"total_links": len(resources),
"total_researches": len(unique_research_ids),