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).
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
import json
|
|
|
|
|
|
class HumanAgent:
|
|
def __init__(self, websocket=None, stream_output=None, headers=None):
|
|
self.websocket = websocket
|
|
self.stream_output = stream_output
|
|
self.headers = headers or {}
|
|
|
|
async def review_plan(self, research_state: dict):
|
|
print(f"HumanAgent websocket: {self.websocket}")
|
|
print(f"HumanAgent stream_output: {self.stream_output}")
|
|
task = research_state.get("task")
|
|
layout = research_state.get("sections")
|
|
|
|
user_feedback = None
|
|
|
|
if task.get("include_human_feedback"):
|
|
# Stream response to the user if a websocket is provided (such as from web app)
|
|
if self.websocket and self.stream_output:
|
|
try:
|
|
await self.stream_output(
|
|
"human_feedback",
|
|
"request",
|
|
f"Any feedback on this plan of topics to research? {layout}? If not, please reply with 'no'.",
|
|
self.websocket,
|
|
)
|
|
# because websocket is wrapped inside a CustomLogsHandler in websocket_manager
|
|
response = await self.websocket.websocket.receive_text()
|
|
print(f"Received response: {response}", flush=True)
|
|
response_data = json.loads(response)
|
|
if response_data.get("type") == "human_feedback":
|
|
user_feedback = response_data.get("content")
|
|
else:
|
|
print(
|
|
f"Unexpected response type: {response_data.get('type')}",
|
|
flush=True,
|
|
)
|
|
except Exception as e:
|
|
print(f"Error receiving human feedback: {e}", flush=True)
|
|
# Otherwise, prompt the user for feedback in the console
|
|
else:
|
|
user_feedback = input(
|
|
f"Any feedback on this plan? {layout}? If not, please reply with 'no'.\n>> "
|
|
)
|
|
|
|
if user_feedback and "no" in user_feedback.strip().lower():
|
|
user_feedback = None
|
|
|
|
plan_revision_count = research_state.get("plan_revision_count", 0)
|
|
if user_feedback:
|
|
plan_revision_count += 1
|
|
|
|
print(f"User feedback before return: {user_feedback}")
|
|
|
|
return {
|
|
"human_feedback": user_feedback,
|
|
"plan_revision_count": plan_revision_count,
|
|
}
|