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).
94 lines
2.7 KiB
Python
94 lines
2.7 KiB
Python
import textwrap
|
|
from typing import Any, Optional
|
|
from uuid import UUID
|
|
|
|
|
|
class R2RException(Exception):
|
|
def __init__(
|
|
self, message: str, status_code: int, detail: Optional[Any] = None
|
|
):
|
|
self.message = message
|
|
self.status_code = status_code
|
|
super().__init__(self.message)
|
|
|
|
def to_dict(self):
|
|
return {
|
|
"message": self.message,
|
|
"status_code": self.status_code,
|
|
"detail": self.detail,
|
|
"error_type": self.__class__.__name__,
|
|
}
|
|
|
|
|
|
class R2RClientException(R2RException):
|
|
"""An exception raised within the R2R client SDK."""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str,
|
|
status_code: int = 400,
|
|
detail: Optional[Any] = None,
|
|
):
|
|
super().__init__(message, status_code, detail)
|
|
self.detail = detail
|
|
|
|
def to_dict(self):
|
|
result = super().to_dict()
|
|
result["detail"] = self.detail
|
|
return result
|
|
|
|
|
|
class R2RDocumentProcessingError(R2RException):
|
|
def __init__(
|
|
self, error_message: str, document_id: UUID, status_code: int = 500
|
|
):
|
|
detail = {
|
|
"document_id": str(document_id),
|
|
"error_type": "document_processing_error",
|
|
}
|
|
super().__init__(error_message, status_code, detail)
|
|
|
|
def to_dict(self):
|
|
result = super().to_dict()
|
|
result["document_id"] = self.document_id
|
|
return result
|
|
|
|
|
|
class PDFParsingError(R2RException):
|
|
"""Custom exception for PDF parsing errors."""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str,
|
|
original_error: Exception | None = None,
|
|
status_code: int = 500,
|
|
):
|
|
detail = {
|
|
"original_error": str(original_error) if original_error else None
|
|
}
|
|
super().__init__(message, status_code, detail)
|
|
|
|
|
|
class PopplerNotFoundError(PDFParsingError):
|
|
"""Specific error for when Poppler is not installed."""
|
|
|
|
def __init__(self):
|
|
installation_instructions = textwrap.dedent("""
|
|
PDF processing requires Poppler to be installed. Please install Poppler and ensure it's in your system PATH.
|
|
|
|
Installing poppler:
|
|
- Ubuntu: sudo apt-get install poppler-utils
|
|
- Archlinux: sudo pacman -S poppler
|
|
- MacOS: brew install poppler
|
|
- Windows:
|
|
1. Download poppler from @oschwartz10612
|
|
2. Move extracted directory to desired location
|
|
3. Add bin/ directory to PATH
|
|
4. Test by running 'pdftoppm -h' in terminal
|
|
""")
|
|
super().__init__(
|
|
message=installation_instructions,
|
|
status_code=422,
|
|
original_error=None,
|
|
)
|