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: Update research details page to use LLM domain classification

LearningCircuit2e5953731c30
diff --git a/src/local_deep_research/web/routes/metrics_routes.py b/src/local_deep_research/web/routes/metrics_routes.py
index 39fdd0d94a..28aa5bc375 100644
--- a/src/local_deep_research/web/routes/metrics_routes.py
+++ b/src/local_deep_research/web/routes/metrics_routes.py
@@ -1072,14 +1072,15 @@ def api_research_link_metrics(research_id):
# Extract domain information
from urllib.parse import urlparse
+ from ...domain_classifier.classifier import DomainClassifier
domain_counts = {}
- source_types = {
- "academic": 0,
- "news": 0,
- "reference": 0,
- "general": 0,
- }
+
+ # Generic category counting from LLM classifications
+ category_counts = {}
+
+ # Initialize domain classifier for LLM-based categorization
+ domain_classifier = DomainClassifier(username=username)
for resource in resources:
if resource.url:
@@ -1091,29 +1092,19 @@ def api_research_link_metrics(research_id):
domain_counts[domain] = domain_counts.get(domain, 0) + 1
- # Categorize source
- if any(
- ext in domain
- for ext in [
- ".edu",
- "arxiv.org",
- "scholar.google",
- "pubmed",
- ]
- ):
- source_types["academic"] += 1
- elif any(
- news in domain
- for news in ["news", "cnn.", "bbc.", "reuters."]
- ):
- source_types["news"] += 1
- elif any(
- ref in domain
- for ref in ["wikipedia.", "docs.", "documentation."]
- ):
- source_types["reference"] += 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:
- source_types["general"] += 1
+ category_counts["Unclassified"] = (
+ category_counts.get("Unclassified", 0) + 1
+ )
except:
pass
@@ -1140,7 +1131,8 @@ def api_research_link_metrics(research_id):
:20
] # Top 20 domains
],
- "source_types": source_types,
+ "category_distribution": category_counts,
+ "domain_categories": category_counts, # Generic categories from LLM
"resources": [
{
"title": r.title or "Untitled",
diff --git a/src/local_deep_research/web/static/js/components/details.js b/src/local_deep_research/web/static/js/components/details.js
index 0d2de3a496..a09a30d2da 100644
--- a/src/local_deep_research/web/static/js/components/details.js
+++ b/src/local_deep_research/web/static/js/components/details.js
@@ -26,6 +26,33 @@
}
}
+ // Helper function to generate colors for dynamic number of categories
+ function generateChartColors(count) {
+ const baseColors = [
+ 'rgba(107, 70, 193, 0.8)', // Purple
+ 'rgba(245, 158, 11, 0.8)', // Orange
+ 'rgba(59, 130, 246, 0.8)', // Blue
+ 'rgba(16, 185, 129, 0.8)', // Green
+ 'rgba(239, 68, 68, 0.8)', // Red
+ 'rgba(139, 69, 19, 0.8)', // Brown
+ 'rgba(255, 192, 203, 0.8)', // Pink
+ 'rgba(128, 128, 128, 0.8)', // Gray
+ 'rgba(255, 165, 0, 0.8)', // Orange
+ 'rgba(75, 0, 130, 0.8)' // Indigo
+ ];
+
+ const background = [];
+ const border = [];
+
+ for (let i = 0; i < count; i++) {
+ const colorIndex = i % baseColors.length;
+ background.push(baseColors[colorIndex]);
+ border.push(baseColors[colorIndex].replace('0.8', '1'));
+ }
+
+ return { background, border };
+ }
+
// Get research ID from URL
function getResearchIdFromUrl() {
const id = URLBuilder.extractResearchIdFromPattern('details');
@@ -60,8 +87,29 @@
// Update summary metrics
document.getElementById('total-links').textContent = data.total_links || 0;
document.getElementById('unique-domains').textContent = data.unique_domains || 0;
- document.getElementById('academic-sources').textContent = data.source_types?.academic || 0;
- document.getElementById('news-sources').textContent = data.source_types?.news || 0;
+
+ // Update category metrics from LLM classification
+ const domainCategories = data.domain_categories || {};
+ const categoryEntries = Object.entries(domainCategories);
+
+ // Update the first two category cards with actual data
+ if (categoryEntries.length > 0) {
+ document.getElementById('academic-sources').textContent = categoryEntries[0]?.[1] || 0;
+ // Update label
+ const academicLabel = document.querySelector('#academic-sources').previousElementSibling;
+ if (academicLabel) academicLabel.textContent = categoryEntries[0]?.[0] || 'Category 1';
+ } else {
+ document.getElementById('academic-sources').textContent = 0;
+ }
+
+ if (categoryEntries.length > 1) {
+ document.getElementById('news-sources').textContent = categoryEntries[1]?.[1] || 0;
+ // Update label
+ const newsLabel = document.querySelector('#news-sources').previousElementSibling;
+ if (newsLabel) newsLabel.textContent = categoryEntries[1]?.[0] || 'Category 2';
+ } else {
+ document.getElementById('news-sources').textContent = 0;
+ }
// Display domain list
const domainList = document.getElementById('domain-list');
@@ -99,33 +147,25 @@
resourceSample.innerHTML = '<div style="text-align: center; color: var(--text-secondary); padding: 1rem;">No resource samples available</div>';
}
- // Create source type pie chart
- if (data.source_types) {
+ // Create generic source type pie chart
+ if (domainCategories && Object.keys(domainCategories).length > 0) {
const ctx = document.getElementById('source-type-chart');
if (ctx) {
+ // Generate dynamic labels and data from whatever categories the LLM provides
+ const labels = Object.keys(domainCategories);
+ const chartData = Object.values(domainCategories);
+
+ // Generate colors dynamically based on number of categories
+ const colors = generateChartColors(labels.length);
+
new Chart(ctx, {
type: 'pie',
data: {
- labels: ['Academic', 'News', 'Reference', 'General'],
+ labels: labels,
datasets: [{
- data: [
- data.source_types.academic || 0,
- data.source_types.news || 0,
- data.source_types.reference || 0,
- data.source_types.general || 0
- ],
- backgroundColor: [
- 'rgba(107, 70, 193, 0.8)',
- 'rgba(245, 158, 11, 0.8)',
- 'rgba(59, 130, 246, 0.8)',
- 'rgba(16, 185, 129, 0.8)'
- ],
- borderColor: [
- 'rgba(107, 70, 193, 1)',
- 'rgba(245, 158, 11, 1)',
- 'rgba(59, 130, 246, 1)',
- 'rgba(16, 185, 129, 1)'
- ],
+ data: chartData,
+ backgroundColor: colors.background,
+ borderColor: colors.border,
borderWidth: 1
}]
},