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: add NASA ADS search engine for physics and astronomy papers

LearningCircuit9a99e3f7f37c
diff --git a/src/local_deep_research/defaults/settings_nasa_ads.json b/src/local_deep_research/defaults/settings_nasa_ads.json
new file mode 100644
index 0000000000..0444586a81
--- /dev/null
+++ b/src/local_deep_research/defaults/settings_nasa_ads.json
@@ -0,0 +1,254 @@
+{
+ "search.engine.web.nasa_ads": {
+ "category": "nasa_ads",
+ "description": "NASA Astrophysics Data System search engine configuration",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "NASA ADS Search Engine",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": {
+ "module_path": ".engines.search_engine_nasa_ads",
+ "class_name": "NasaAdsSearchEngine",
+ "requires_api_key": true,
+ "requires_llm": true,
+ "description": "Search millions of astronomy and physics papers with natural language queries",
+ "reliability": 0.95
+ },
+ "visible": false
+ },
+ "search.engine.web.nasa_ads.display_name": {
+ "category": "nasa_ads",
+ "description": "Display name to use in the U.I. for this search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Display Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "NASA ADS",
+ "visible": false
+ },
+ "search.engine.web.nasa_ads.description": {
+ "category": "nasa_ads",
+ "description": "Human-readable description of the search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Description",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "NASA Astrophysics Data System - comprehensive database of astronomy, astrophysics, physics, and geophysics papers. Includes both ArXiv preprints and published papers.",
+ "visible": false
+ },
+ "search.engine.web.nasa_ads.class_name": {
+ "category": "nasa_ads",
+ "description": "Setting for nasa_ads.class_name",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Class Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "NasaAdsSearchEngine",
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.module_path": {
+ "category": "nasa_ads",
+ "description": "Setting for nasa_ads.module_path",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Module Path",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": ".engines.search_engine_nasa_ads",
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.reliability": {
+ "category": "nasa_ads",
+ "description": "Setting for nasa_ads.reliability",
+ "editable": true,
+ "max_value": 1.0,
+ "min_value": 0.0,
+ "name": "Reliability",
+ "options": null,
+ "step": 0.05,
+ "type": "SEARCH",
+ "ui_element": "range",
+ "value": 0.95,
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.requires_api_key": {
+ "category": "nasa_ads",
+ "description": "Setting for nasa_ads.requires_api_key",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires Api Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.api_key": {
+ "category": "nasa_ads",
+ "description": "NASA ADS API key for higher rate limits (optional but recommended). Get one at https://ui.adsabs.harvard.edu/user/settings/token",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "API Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.default_params.max_results": {
+ "category": "nasa_ads",
+ "description": "Maximum number of results to retrieve from NASA ADS",
+ "editable": true,
+ "max_value": 200,
+ "min_value": 1,
+ "name": "Max Results",
+ "options": null,
+ "step": 1,
+ "type": "SEARCH",
+ "ui_element": "number",
+ "value": 25,
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.default_params.sort_by": {
+ "category": "nasa_ads",
+ "description": "How to sort the search results",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Sort By",
+ "options": [
+ {"label": "Relevance", "value": "relevance"},
+ {"label": "Citation Count", "value": "citation_count"},
+ {"label": "Publication Date", "value": "date"}
+ ],
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "select",
+ "value": "relevance",
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.default_params.include_arxiv": {
+ "category": "nasa_ads",
+ "description": "Include ArXiv preprints in search results",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Include ArXiv",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.default_params.min_citations": {
+ "category": "nasa_ads",
+ "description": "Minimum number of citations required (0 for no filter)",
+ "editable": true,
+ "max_value": 1000,
+ "min_value": 0,
+ "name": "Minimum Citations",
+ "options": null,
+ "step": 1,
+ "type": "SEARCH",
+ "ui_element": "number",
+ "value": 0,
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.default_params.from_publication_date": {
+ "category": "nasa_ads",
+ "description": "Only return papers published after this date (YYYY-MM-DD format, leave empty for all dates)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "From Publication Date",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.journal_reputation.enabled": {
+ "category": "nasa_ads",
+ "description": "Enable journal quality filtering for this search engine.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Filter Low-Quality Journals",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.strengths": {
+ "category": "nasa_ads",
+ "description": "Setting for nasa_ads.strengths",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Strengths",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": [
+ "astronomy papers",
+ "astrophysics research",
+ "physics papers",
+ "space science",
+ "planetary science",
+ "cosmology",
+ "high energy physics",
+ "historical papers",
+ "citation tracking",
+ "natural language queries"
+ ],
+ "visible": true
+ },
+ "search.engine.web.nasa_ads.weaknesses": {
+ "category": "nasa_ads",
+ "description": "Setting for nasa_ads.weaknesses",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Weaknesses",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": [
+ "biomedical content",
+ "computer science papers",
+ "social sciences",
+ "humanities",
+ "requires API key for good performance"
+ ],
+ "visible": true
+ }
+}
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_nasa_ads.py b/src/local_deep_research/web_search_engines/engines/search_engine_nasa_ads.py
new file mode 100644
index 0000000000..04577c5852
--- /dev/null
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_nasa_ads.py
@@ -0,0 +1,358 @@
+"""NASA Astrophysics Data System (ADS) search engine implementation."""
+
+from typing import Any, Dict, List, Optional
+
+import requests
+from langchain_core.language_models import BaseLLM
+from loguru import logger
+
+from ...advanced_search_system.filters.journal_reputation_filter import (
+ JournalReputationFilter,
+)
+from ..rate_limiting import RateLimitError
+from ..search_engine_base import BaseSearchEngine
+
+
+class NasaAdsSearchEngine(BaseSearchEngine):
+ """NASA ADS search engine for physics, astronomy, and astrophysics papers."""
+
+ def __init__(
+ self,
+ max_results: int = 25,
+ api_key: Optional[str] = None,
+ sort_by: str = "relevance",
+ min_citations: int = 0,
+ from_publication_date: Optional[str] = None,
+ include_arxiv: bool = True,
+ llm: Optional[BaseLLM] = None,
+ max_filtered_results: Optional[int] = None,
+ settings_snapshot: Optional[Dict[str, Any]] = None,
+ **kwargs,
+ ):
+ """
+ Initialize the NASA ADS search engine.
+
+ Args:
+ max_results: Maximum number of search results
+ api_key: NASA ADS API key (required for higher rate limits)
+ sort_by: Sort order ('relevance', 'citation_count', 'date')
+ min_citations: Minimum citation count filter
+ from_publication_date: Filter papers from this date (YYYY-MM-DD)
+ include_arxiv: Include ArXiv preprints in results
+ llm: Language model for relevance filtering
+ max_filtered_results: Maximum number of results to keep after filtering
+ settings_snapshot: Settings snapshot for configuration
+ **kwargs: Additional parameters to pass to parent class
+ """
+ # Initialize journal reputation filter if needed
+ content_filters = []
+ journal_filter = JournalReputationFilter.create_default(
+ model=llm,
+ engine_name="nasa_ads",
+ settings_snapshot=settings_snapshot,
+ )
+ if journal_filter is not None:
+ content_filters.append(journal_filter)
+
+ # Initialize the BaseSearchEngine
+ super().__init__(
+ llm=llm,
+ max_filtered_results=max_filtered_results,
+ max_results=max_results,
+ content_filters=content_filters,
+ settings_snapshot=settings_snapshot,
+ **kwargs,
+ )
+
+ self.sort_by = sort_by
+ self.min_citations = min_citations
+ self.include_arxiv = include_arxiv
+ # Handle from_publication_date
+ self.from_publication_date = (
+ from_publication_date
+ if from_publication_date and from_publication_date != "False"
+ else None
+ )
+
+ # Get API key from settings if not provided
+ if not api_key and settings_snapshot:
+ from ...config.search_config import get_setting_from_snapshot
+
+ try:
+ api_key = get_setting_from_snapshot(
+ "search.engine.web.nasa_ads.api_key",
+ settings_snapshot=settings_snapshot,
+ )
+ except Exception:
+ pass
+
+ # Handle "False" string for api_key
+ self.api_key = api_key if api_key and api_key != "False" else None
+
+ # API configuration
+ self.api_base = "https://api.adsabs.harvard.edu/v1"
+ self.headers = {
+ "User-Agent": "Local-Deep-Research-Agent",
+ "Accept": "application/json",
+ }
+
+ if self.api_key:
+ self.headers["Authorization"] = f"Bearer {self.api_key}"
+ logger.info("Using NASA ADS with API key")
+ else:
+ logger.warning(
+ "Using NASA ADS without API key - rate limits will be very restrictive (1 request/second, 5000/day)"
+ )
+
+ def _get_previews(self, query: str) -> List[Dict[str, Any]]:
+ """
+ Get preview information for NASA ADS search results.
+
+ Args:
+ query: The search query (natural language supported)
+
+ Returns:
+ List of preview dictionaries
+ """
+ logger.info(f"Searching NASA ADS for: {query}")
+
+ # Build the search query - NASA ADS has good natural language support
+ # We can use the query directly or enhance it slightly
+ search_query = query
+
+ # Build filters
+ filters = []
+ if self.from_publication_date:
+ # Convert YYYY-MM-DD to ADS format
+ year = self.from_publication_date.split("-")[0]
+ filters.append(f"year:{year}-9999")
+
+ if self.min_citations > 0:
+ filters.append(f"citation_count:[{self.min_citations} TO *]")
+
+ if not self.include_arxiv:
+ filters.append('-bibstem:"arXiv"')
+
+ # Combine query with filters
+ if filters:
+ full_query = f"{search_query} {' '.join(filters)}"
+ else:
+ full_query = search_query
+
+ # Build request parameters
+ params = {
+ "q": full_query,
+ "fl": "id,bibcode,title,author,year,pubdate,abstract,citation_count,bibstem,doi,identifier,pub,keyword,aff",
+ "rows": min(
+ self.max_results, 200
+ ), # NASA ADS allows up to 200 per request
+ "start": 0,
+ }
+
+ # Add sorting
+ sort_map = {
+ "relevance": "score desc",
+ "citation_count": "citation_count desc",
+ "date": "date desc",
+ }
+ params["sort"] = sort_map.get(self.sort_by, "score desc")
+
+ try:
+ # Apply rate limiting
+ if not self.api_key:
+ # Without API key: 1 request per second
+ self._last_wait_time = self.rate_tracker.apply_rate_limit(
+ self.engine_type, min_delay=1.0
+ )
+ else:
+ # With API key: more lenient, but still respectful
+ self._last_wait_time = self.rate_tracker.apply_rate_limit(
+ self.engine_type, min_delay=0.1
+ )
+
+ logger.debug(
+ f"Applied rate limit wait: {self._last_wait_time:.2f}s"
+ )
+
+ # Make the API request
+ logger.info(
+ f"Making NASA ADS API request with query: {params['q'][:100]}..."
+ )
+ response = requests.get(
+ f"{self.api_base}/search/query",
+ params=params,
+ headers=self.headers,
+ timeout=30,
+ )
+
+ # Log rate limit headers if available
+ if "X-RateLimit-Remaining" in response.headers:
+ remaining = response.headers.get("X-RateLimit-Remaining")
+ limit = response.headers.get("X-RateLimit-Limit", "unknown")
+ logger.debug(
+ f"NASA ADS rate limit: {remaining}/{limit} requests remaining"
+ )
+
+ if response.status_code == 200:
+ data = response.json()
+ docs = data.get("response", {}).get("docs", [])
+ num_found = data.get("response", {}).get("numFound", 0)
+
+ logger.info(
+ f"NASA ADS returned {len(docs)} results (total available: {num_found:,})"
+ )
+
+ # Format results as previews
+ previews = []
+ for doc in docs:
+ preview = self._format_doc_preview(doc)
+ if preview:
+ previews.append(preview)
+
+ logger.info(f"Successfully formatted {len(previews)} previews")
+ return previews
+
+ elif response.status_code == 429:
+ # Rate limited
+ logger.warning("NASA ADS rate limit reached")
+ raise RateLimitError("NASA ADS rate limit exceeded")
+
+ elif response.status_code == 401:
+ logger.error("NASA ADS API key is invalid or missing")
+ return []
+
+ else:
+ logger.error(
+ f"NASA ADS API error: {response.status_code} - {response.text[:200]}"
+ )
+ return []
+
+ except Exception:
+ logger.exception("Error searching NASA ADS")
+ return []
+
+ def _format_doc_preview(
+ self, doc: Dict[str, Any]
+ ) -> Optional[Dict[str, Any]]:
+ """
+ Format a NASA ADS document as a preview dictionary.
+
+ Args:
+ doc: NASA ADS document object
+
+ Returns:
+ Formatted preview dictionary or None if formatting fails
+ """
+ try:
+ # Extract basic information
+ bibcode = doc.get("bibcode", "")
+ title = (
+ doc.get("title", ["No title"])[0]
+ if doc.get("title")
+ else "No title"
+ )
+
+ # Get abstract or create snippet
+ abstract = doc.get("abstract", "")
+ if not abstract:
+ abstract = f"Academic paper: {title}"
+ snippet = abstract[:500] if abstract else f"Academic paper: {title}"
+
+ # Get publication info
+ year = doc.get("year", "")
+ pubdate = doc.get("pubdate", "")
+
+ # Get journal/source
+ journal = ""
+ if doc.get("pub"):
+ journal = doc.get("pub")
+ elif doc.get("bibstem"):
+ bibstem = doc.get("bibstem", [])
+ if bibstem:
+ journal = (
+ bibstem[0] if isinstance(bibstem, list) else bibstem
+ )
+
+ # Get authors
+ authors = doc.get("author", [])
+ authors_str = ", ".join(authors[:5])
+ if len(authors) > 5:
+ authors_str += " et al."
+
+ # Get metrics
+ citation_count = doc.get("citation_count", 0)
+
+ # Get URL - prefer DOI, fallback to ADS URL
+ url = None
+ if doc.get("doi"):
+ dois = doc.get("doi", [])
+ if dois:
+ doi = dois[0] if isinstance(dois, list) else dois
+ url = f"https://doi.org/{doi}"
+
+ if not url:
+ url = f"https://ui.adsabs.harvard.edu/abs/{bibcode}"
+
+ # Check if it's ArXiv
+ is_arxiv = "arXiv" in str(doc.get("bibstem", []))
+
+ # Get keywords
+ keywords = doc.get("keyword", [])
+
+ preview = {
+ "id": bibcode,
+ "title": title,
+ "link": url,
+ "snippet": snippet,
+ "authors": authors_str,
+ "year": year,
+ "date": pubdate,
+ "journal": journal,
+ "citations": citation_count,
+ "abstract": abstract,
+ "is_arxiv": is_arxiv,
+ "keywords": keywords[:5] if keywords else [],
+ "type": "academic_paper",
+ }
+
+ return preview
+
+ except Exception:
+ logger.exception(
+ f"Error formatting NASA ADS document: {doc.get('bibcode', 'unknown')}"
+ )
+ return None
+
+ def _get_full_content(
+ self, relevant_items: List[Dict[str, Any]]
+ ) -> List[Dict[str, Any]]:
+ """
+ Get full content for relevant items (NASA ADS provides most content in preview).
+
+ Args:
+ relevant_items: List of relevant preview dictionaries
+
+ Returns:
+ List of result dictionaries with full content
+ """
+ # NASA ADS returns comprehensive data in the initial search,
+ # so we don't need a separate full content fetch
+ results = []
+ for item in relevant_items:
+ result = {
+ "title": item.get("title", ""),
+ "link": item.get("link", ""),
+ "snippet": item.get("snippet", ""),
+ "content": item.get("abstract", item.get("snippet", "")),
+ "metadata": {
+ "authors": item.get("authors", ""),
+ "year": item.get("year", ""),
+ "journal": item.get("journal", ""),
+ "citations": item.get("citations", 0),
+ "is_arxiv": item.get("is_arxiv", False),
+ "keywords": item.get("keywords", []),
+ },
+ }
+ results.append(result)
+
+ return results