Local research agents (Ollama, LMStudio) typically only have Google search. Adding Reddit search provides a unique signal: real community opinions, recommendations, complaints, and discussions that official documentation and marketing pages miss. This tutorial adds Reddit as a second research source.
Prerequisites
- A local research agent with web search capability
- Python 3.8+
- A Scavio API key
Walkthrough
Step 1: Add Reddit search function
Create a function that searches Reddit and formats results for your local agent.
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def reddit_search(query: str) -> str:
resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': 'reddit', 'query': query}, timeout=10)
threads = resp.json().get('organic', [])[:5]
if not threads:
return 'No Reddit discussions found.'
lines = ['Reddit discussions:']
for t in threads:
score = t.get('score', 0)
lines.append(f"- [{t.get('title','')}]({t.get('link','')}) (score: {score})")
if t.get('snippet'):
lines.append(f" {t['snippet'][:200]}")
return '\n'.join(lines)Step 2: Integrate with your research pipeline
Add Reddit as a second source alongside Google in your research workflow.
def multi_source_research(query: str) -> str:
# Google for official/factual sources
google_resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': 'google', 'query': query}, timeout=10)
google_results = google_resp.json().get('organic', [])[:5]
# Reddit for community opinions
reddit_results = reddit_search(query)
# Format for local LLM context
context = 'Google (official sources):\n'
for r in google_results:
context += f"- {r.get('title','')}: {r.get('snippet','')}\n"
context += f"\n{reddit_results}\n"
context += '\nNote: Google results are official sources. Reddit results are community opinions (may be biased or outdated).'
return contextStep 3: Use Reddit for specific research patterns
Reddit excels at certain query types. Route appropriately.
def smart_research(query: str) -> str:
# Patterns where Reddit adds unique value:
opinion_keywords = ['best', 'recommend', 'worth it', 'vs', 'alternative', 'review', 'experience']
use_reddit = any(kw in query.lower() for kw in opinion_keywords)
google_ctx = google_search(query) # Your existing Google search
if use_reddit:
reddit_ctx = reddit_search(query)
return f"Official sources:\n{google_ctx}\n\nCommunity opinions:\n{reddit_ctx}"
else:
return f"Results:\n{google_ctx}"
# Reddit adds value for:
# - 'best X for Y' queries (real recommendations)
# - 'X vs Y' comparisons (real user experiences)
# - 'is X worth it' evaluations (honest opinions)
# - 'alternative to X' searches (community suggestions)Python Example
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def reddit_research(query):
r = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': 'reddit', 'query': query}).json()
return '\n'.join(f"- {t['title']} (score:{t.get('score',0)})" for t in r.get('organic',[])[:5])JavaScript Example
async function redditResearch(query) {
const r = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
body: JSON.stringify({platform: 'reddit', query})
});
return (await r.json()).organic?.slice(0,5).map(t => `- ${t.title} (score:${t.score})`).join('\n');
}Expected Output
A local research agent enhanced with Reddit community data, providing real user opinions alongside official Google results.