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).
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""Abstraction for a prompt that can be formatted with inputs."""
|
|
|
|
import logging
|
|
from datetime import datetime
|
|
from typing import Any
|
|
from uuid import UUID, uuid4
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
logger = logging.getLogger()
|
|
|
|
|
|
class Prompt(BaseModel):
|
|
"""A prompt that can be formatted with inputs."""
|
|
|
|
id: UUID = Field(default_factory=uuid4)
|
|
name: str
|
|
template: str
|
|
input_types: dict[str, str]
|
|
created_at: datetime = Field(default_factory=datetime.utcnow)
|
|
updated_at: datetime = Field(default_factory=datetime.utcnow)
|
|
|
|
def format_prompt(self, inputs: dict[str, Any]) -> str:
|
|
self._validate_inputs(inputs)
|
|
return self.template.format(**inputs)
|
|
|
|
def _validate_inputs(self, inputs: dict[str, Any]) -> None:
|
|
for var, expected_type_name in self.input_types.items():
|
|
expected_type = self._convert_type(expected_type_name)
|
|
if var not in inputs:
|
|
raise ValueError(f"Missing input: {var}")
|
|
if not isinstance(inputs[var], expected_type):
|
|
raise TypeError(
|
|
f"Input '{var}' must be of type {expected_type.__name__}, got {type(inputs[var]).__name__} instead."
|
|
)
|
|
|
|
def _convert_type(self, type_name: str) -> type:
|
|
type_mapping = {"int": int, "str": str}
|
|
return type_mapping.get(type_name, str)
|