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: address code review feedback for ScaleSerp integration

LearningCircuit4fcf930ea9d3
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_scaleserp.py b/src/local_deep_research/web_search_engines/engines/search_engine_scaleserp.py
index cc9901bc65..81afad6a10 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_scaleserp.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_scaleserp.py
@@ -74,12 +74,12 @@ class ScaleSerpSearchEngine(BaseSearchEngine):
if not scaleserp_api_key:
raise ValueError(
- "ScaleSerp API key not found. Please provide api_key parameter or set it in the UI settings."
+ "ScaleSerp API key not found. Please provide api_key parameter or set it in the UI settings. "
+ "Get your API key at https://scaleserp.com"
)
self.api_key = scaleserp_api_key
self.base_url = "https://api.scaleserp.com/search"
- self.engine_type = "scaleserp" # Required for rate limiting
# If full content is requested, initialize FullSearchResults
if include_full_content:
@@ -129,15 +129,14 @@ class ScaleSerpSearchEngine(BaseSearchEngine):
if self.safe_search:
params["safe"] = "on"
- # Add caching parameter if enabled - this is ScaleSerp's key feature!
- # Cached results don't count against quota and are free for 1 hour
+ # ScaleSerp automatically caches identical queries for 1 hour
+ # Cached results are served instantly and don't consume API credits
if self.enable_cache:
params["output"] = (
- "json" # Ensure JSON output format (not related to caching)
+ "json" # Ensure JSON output for cache detection
)
- # ScaleSerp automatically caches for 1 hour; no special parameter is needed for caching
logger.info(
- "Using ScaleSerp caching - repeated searches within 1 hour are free"
+ "ScaleSerp caching enabled - identical searches within 1 hour are free"
)
# Apply rate limiting before request
@@ -169,19 +168,17 @@ class ScaleSerpSearchEngine(BaseSearchEngine):
for idx, result in enumerate(organic_results):
# Extract display link safely using urlparse
- display_link = ""
link = result.get("link", "")
+ display_link = ""
if link:
try:
parsed_url = urlparse(link)
- # Use netloc for domain, fallback to truncated link (not path which could be a file path)
display_link = (
- parsed_url.netloc
- if parsed_url.netloc
- else (link[:50] if link else "")
+ parsed_url.netloc or parsed_url.path or ""
)
except Exception:
- display_link = link[:50] if link else ""
+ # Fallback to truncated URL if parsing fails
+ display_link = link[:50]
preview = {
"id": idx,
@@ -228,8 +225,8 @@ class ScaleSerpSearchEngine(BaseSearchEngine):
if "related_questions" in data:
self._related_questions = data["related_questions"]
- # Check if result was served from cache
- if "request_info" in data and data["request_info"].get("cached"):
+ # Log if result was served from cache
+ if from_cache:
logger.info(
"Result served from ScaleSerp cache - no API credit used!"
)
@@ -240,7 +237,9 @@ class ScaleSerpSearchEngine(BaseSearchEngine):
raise # Re-raise rate limit errors
except requests.exceptions.RequestException as e:
error_msg = str(e)
- logger.exception("Error getting ScaleSerp API results")
+ logger.exception(
+ "Error getting ScaleSerp API results. Check API docs: https://docs.scaleserp.com"
+ )
# Check for rate limit patterns in error message
if any(