caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
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).
2026-07-10 16:23:13 +03:00

56 lines
1.7 KiB
Python

import os
from shared.abstractions import R2RClientException
class BaseClient:
def __init__(
self,
base_url: str | None = None,
timeout: float = 300.0,
):
self.base_url = base_url or os.getenv(
"R2R_API_BASE", "http://localhost:7272"
)
self.timeout = timeout
self.access_token: str | None = None
self._refresh_token: str | None = None
self._user_id: str | None = None
self.api_key: str | None = os.getenv("R2R_API_KEY", None)
self.project_name: str | None = None
def _get_auth_header(self) -> dict[str, str]:
if self.access_token and self.api_key:
raise R2RClientException(
message="Cannot have both access token and api key.",
)
if self.access_token:
return {"Authorization": f"Bearer {self.access_token}"}
elif self.api_key:
return {"x-api-key": self.api_key}
else:
return {}
def _get_full_url(self, endpoint: str, version: str = "v3") -> str:
return f"{self.base_url}/{version}/{endpoint}"
def _prepare_request_args(self, endpoint: str, **kwargs) -> dict:
headers = kwargs.pop("headers", {})
if (self.access_token or self.api_key) and endpoint not in [
"register",
"login",
"verify_email",
]:
headers.update(self._get_auth_header())
if self.project_name:
headers["x-project-name"] = self.project_name
if (
kwargs.get("params", None) == {}
or kwargs.get("params", None) is None
):
kwargs.pop("params", None)
return {"headers": headers, **kwargs}