Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
"""GroundRoute search retriever for GPT Researcher.
|
|
|
|
GroundRoute routes each query across multiple web-search engines (Serper, Brave,
|
|
Exa, Tavily, Firecrawl, Perplexity), picks the cheapest that meets a quality bar,
|
|
caches repeats, and fails over — exposed as one search API.
|
|
"""
|
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
|
|
class GroundRouteSearch:
|
|
"""GroundRoute multi-engine search retriever."""
|
|
|
|
def __init__(self, query, headers=None, topic="general", query_domains=None):
|
|
self.query = query
|
|
self.headers = headers or {}
|
|
self.topic = topic
|
|
self.base_url = "https://api.groundroute.ai/v1/search"
|
|
self.api_key = self.get_api_key()
|
|
self.query_domains = query_domains or None
|
|
|
|
def get_api_key(self):
|
|
"""Get the GroundRoute API key from headers or the environment."""
|
|
api_key = self.headers.get("groundroute_api_key")
|
|
if not api_key:
|
|
try:
|
|
api_key = os.environ["GROUNDROUTE_API_KEY"]
|
|
except KeyError:
|
|
raise Exception(
|
|
"GroundRoute API key not found. Set the GROUNDROUTE_API_KEY "
|
|
"environment variable. Create a key at https://groundroute.ai/overview"
|
|
)
|
|
return api_key
|
|
|
|
def search(self, max_results=7):
|
|
"""Search via GroundRoute. Returns [{"href": url, "body": content}, ...]."""
|
|
try:
|
|
response = requests.post(
|
|
self.base_url,
|
|
headers={
|
|
"Authorization": f"Bearer {self.api_key}",
|
|
"Content-Type": "application/json",
|
|
},
|
|
json={"query": self.query, "max_results": max_results},
|
|
timeout=20,
|
|
)
|
|
response.raise_for_status()
|
|
results = response.json().get("results", [])
|
|
return [
|
|
{"href": r.get("url"), "body": r.get("content") or r.get("snippet") or ""}
|
|
for r in results
|
|
if r.get("url")
|
|
]
|
|
except Exception as e:
|
|
print(f"Error performing GroundRoute search: {e}")
|
|
return []
|