~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
fix: update Semantic Scholar search engine with proper rate limiting and settings
LearningCircuitc635417b269a
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.jsonindex d278d7d3b0..6454fd9cb6 100644--- a/src/local_deep_research/defaults/default_settings.json+++ b/src/local_deep_research/defaults/default_settings.json@@ -977,6 +977,10 @@"label": "OpenAlex","value": "openalex"},+ {+ "label": "Semantic Scholar",+ "value": "semantic_scholar"+ },{"label": "Github","value": "github"diff --git a/src/local_deep_research/defaults/settings_semantic_scholar.json b/src/local_deep_research/defaults/settings_semantic_scholar.jsonnew file mode 100644index 0000000000..df50bdf942--- /dev/null+++ b/src/local_deep_research/defaults/settings_semantic_scholar.json@@ -0,0 +1,275 @@+{+ "search.engine.web.semantic_scholar": {+ "category": "semantic_scholar",+ "description": "Semantic Scholar search engine configuration",+ "editable": false,+ "max_value": null,+ "min_value": null,+ "name": "Semantic Scholar Search Engine",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "json",+ "value": {+ "module_path": ".engines.search_engine_semantic_scholar",+ "class_name": "SemanticScholarSearchEngine",+ "requires_api_key": false,+ "requires_llm": true,+ "description": "Search millions of academic papers across all scientific fields with AI-powered features",+ "reliability": 0.90+ },+ "visible": false+ },+ "search.engine.web.semantic_scholar.display_name": {+ "category": "semantic_scholar",+ "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": "Semantic Scholar",+ "visible": false+ },+ "search.engine.web.semantic_scholar.description": {+ "category": "semantic_scholar",+ "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": "AI-powered search for scientific literature. Features include TLDR summaries, citation graphs, and semantic search across millions of papers.",+ "visible": false+ },+ "search.engine.web.semantic_scholar.class_name": {+ "category": "semantic_scholar",+ "description": "Class name for the search engine implementation",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Class Name",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "text",+ "value": "SemanticScholarSearchEngine",+ "visible": true+ },+ "search.engine.web.semantic_scholar.module_path": {+ "category": "semantic_scholar",+ "description": "Module path for the search engine implementation",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Module Path",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "text",+ "value": ".engines.search_engine_semantic_scholar",+ "visible": true+ },+ "search.engine.web.semantic_scholar.reliability": {+ "category": "semantic_scholar",+ "description": "Reliability rating for the search engine",+ "editable": true,+ "max_value": 1.0,+ "min_value": 0.0,+ "name": "Reliability",+ "options": null,+ "step": 0.05,+ "type": "SEARCH",+ "ui_element": "range",+ "value": 0.90,+ "visible": true+ },+ "search.engine.web.semantic_scholar.requires_api_key": {+ "category": "semantic_scholar",+ "description": "Whether this search engine requires an API key",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Requires API Key",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "checkbox",+ "value": false,+ "visible": true+ },+ "search.engine.web.semantic_scholar.api_key": {+ "category": "semantic_scholar",+ "description": "Semantic Scholar API key (optional but recommended for higher rate limits). Get one at https://www.semanticscholar.org/product/api",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "API Key (Optional)",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "password",+ "value": "",+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.max_results": {+ "category": "semantic_scholar",+ "description": "Maximum number of results to retrieve",+ "editable": true,+ "max_value": 100,+ "min_value": 1,+ "name": "Max Results",+ "options": null,+ "step": 1,+ "type": "SEARCH",+ "ui_element": "number",+ "value": 20,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.get_tldr": {+ "category": "semantic_scholar",+ "description": "Fetch AI-generated TLDR summaries for papers",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Get TLDR Summaries",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "checkbox",+ "value": true,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.get_abstracts": {+ "category": "semantic_scholar",+ "description": "Fetch full abstracts for papers",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Get Abstracts",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "checkbox",+ "value": true,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.get_citations": {+ "category": "semantic_scholar",+ "description": "Fetch citation information for papers",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Get Citations",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "checkbox",+ "value": false,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.get_references": {+ "category": "semantic_scholar",+ "description": "Fetch reference information for papers",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Get References",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "checkbox",+ "value": false,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.citation_limit": {+ "category": "semantic_scholar",+ "description": "Maximum number of citations to fetch per paper",+ "editable": true,+ "max_value": 50,+ "min_value": 1,+ "name": "Citation Limit",+ "options": null,+ "step": 1,+ "type": "SEARCH",+ "ui_element": "number",+ "value": 10,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.reference_limit": {+ "category": "semantic_scholar",+ "description": "Maximum number of references to fetch per paper",+ "editable": true,+ "max_value": 50,+ "min_value": 1,+ "name": "Reference Limit",+ "options": null,+ "step": 1,+ "type": "SEARCH",+ "ui_element": "number",+ "value": 10,+ "visible": true+ },+ "search.engine.web.semantic_scholar.default_params.optimize_queries": {+ "category": "semantic_scholar",+ "description": "Use LLM to optimize natural language queries for better search results",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Optimize Queries",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "checkbox",+ "value": true,+ "visible": true+ },+ "search.engine.web.semantic_scholar.strengths": {+ "category": "semantic_scholar",+ "description": "Strengths of this search engine",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Strengths",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "json",+ "value": [+ "AI-powered features",+ "TLDR summaries",+ "citation graphs",+ "semantic search",+ "all scientific fields",+ "no API key required",+ "computer science focus",+ "paper influence metrics"+ ],+ "visible": true+ },+ "search.engine.web.semantic_scholar.weaknesses": {+ "category": "semantic_scholar",+ "description": "Weaknesses of this search engine",+ "editable": true,+ "max_value": null,+ "min_value": null,+ "name": "Weaknesses",+ "options": null,+ "step": null,+ "type": "SEARCH",+ "ui_element": "json",+ "value": [+ "rate limits without API key",+ "not all papers have TLDR",+ "coverage varies by field",+ "newer papers may be missing"+ ],+ "visible": true+ }+}diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_semantic_scholar.py b/src/local_deep_research/web_search_engines/engines/search_engine_semantic_scholar.pyindex d96ec22a25..1860c416fb 100644--- a/src/local_deep_research/web_search_engines/engines/search_engine_semantic_scholar.py+++ b/src/local_deep_research/web_search_engines/engines/search_engine_semantic_scholar.py@@ -8,7 +8,7 @@ from loguru import loggerfrom requests.adapters import HTTPAdapterfrom urllib3.util import Retry-from ...config import search_config+from ..rate_limiting import RateLimitErrorfrom ..search_engine_base import BaseSearchEngine@@ -37,6 +37,8 @@ class SemanticScholarSearchEngine(BaseSearchEngine):retry_backoff_factor: float = 1.0,fields_of_study: Optional[List[str]] = None,publication_types: Optional[List[str]] = None,+ settings_snapshot: Optional[Dict[str, Any]] = None,+ **kwargs,):"""Initialize the Semantic Scholar search engine.@@ -59,14 +61,30 @@ class SemanticScholarSearchEngine(BaseSearchEngine):retry_backoff_factor: Backoff factor for retriesfields_of_study: List of fields of study to filter resultspublication_types: List of publication types to filter results+ settings_snapshot: Settings snapshot for configuration+ **kwargs: Additional parameters to pass to parent class"""# Initialize the BaseSearchEngine with LLM, max_filtered_results, and max_resultssuper().__init__(llm=llm,max_filtered_results=max_filtered_results,max_results=max_results,+ settings_snapshot=settings_snapshot,+ **kwargs,)+ # 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.semantic_scholar.api_key",+ settings_snapshot=settings_snapshot,+ )+ except Exception:+ pass+self.api_key = api_keyself.year_range = year_rangeself.get_abstracts = get_abstracts@@ -90,9 +108,15 @@ class SemanticScholarSearchEngine(BaseSearchEngine):# Create a session with retry capabilitiesself.session = self._create_session()- # Rate limiting- self.rate_limit_wait = 1.0 # Default 1 second between requests- self.last_request_time = 0+ # Log API key status+ if self.api_key:+ logger.info(+ "Using Semantic Scholar with API key (higher rate limits)"+ )+ else:+ logger.info(+ "Using Semantic Scholar without API key (lower rate limits)"+ )def _create_session(self) -> requests.Session:"""Create and configure a requests session with retry capabilities"""@@ -124,6 +148,7 @@ class SemanticScholarSearchEngine(BaseSearchEngine):self._last_wait_time = self.rate_tracker.apply_rate_limit(self.engine_type)+ logger.debug(f"Applied rate limit wait: {self._last_wait_time:.2f}s")def _make_request(self,@@ -156,14 +181,12 @@ class SemanticScholarSearchEngine(BaseSearchEngine):else:raise ValueError(f"Unsupported HTTP method: {method}")- # Handle rate limiting manually if retry strategy fails+ # Handle rate limitingif response.status_code == 429:- logger.warning("Rate limit exceeded, waiting and retrying...")- time.sleep(2.0) # Wait longer on rate limit- self.rate_limit_wait *= (- 1.5 # Increase wait time for future requests- )- return self._make_request(url, params, data, method) # Retry+ logger.warning("Semantic Scholar rate limit exceeded")+ # Wait and raise error for proper handling+ time.sleep(2.0)+ raise RateLimitError("Semantic Scholar rate limit exceeded")response.raise_for_status()return response.json()@@ -565,13 +588,8 @@ Format each query on a new line with no numbering or explanation. Keep each querReturns:List of result dictionaries with full content"""- # Check if we should add full content- if (- hasattr(search_config, "SEARCH_SNIPPETS_ONLY")- and search_config.SEARCH_SNIPPETS_ONLY- ):- logger.info("Snippet-only mode, skipping full content retrieval")- return relevant_items+ # For Semantic Scholar, we already have most content from the preview+ # Additional API calls are only needed for citations/referenceslogger.info(f"Getting content for {len(relevant_items)} Semantic Scholar papers"