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).
75 lines
2.5 KiB
Python
75 lines
2.5 KiB
Python
from .utils.views import print_agent_output
|
|
from .utils.llms import call_model
|
|
import json
|
|
|
|
sample_revision_notes = """
|
|
{
|
|
"draft": {
|
|
draft title: The revised draft that you are submitting for review
|
|
},
|
|
"revision_notes": Your message to the reviewer about the changes you made to the draft based on their feedback
|
|
}
|
|
"""
|
|
|
|
|
|
class ReviserAgent:
|
|
def __init__(self, websocket=None, stream_output=None, headers=None):
|
|
self.websocket = websocket
|
|
self.stream_output = stream_output
|
|
self.headers = headers or {}
|
|
|
|
async def revise_draft(self, draft_state: dict):
|
|
"""
|
|
Review a draft article
|
|
:param draft_state:
|
|
:return:
|
|
"""
|
|
review = draft_state.get("review")
|
|
task = draft_state.get("task")
|
|
draft_report = draft_state.get("draft")
|
|
prompt = [
|
|
{
|
|
"role": "system",
|
|
"content": "You are an expert writer. Your goal is to revise drafts based on reviewer notes.",
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": f"""Draft:\n{draft_report}" + "Reviewer's notes:\n{review}\n\n
|
|
You have been tasked by your reviewer with revising the following draft, which was written by a non-expert.
|
|
If you decide to follow the reviewer's notes, please write a new draft and make sure to address all of the points they raised.
|
|
Please keep all other aspects of the draft the same.
|
|
You MUST return nothing but a JSON in the following format:
|
|
{sample_revision_notes}
|
|
""",
|
|
},
|
|
]
|
|
|
|
response = await call_model(
|
|
prompt,
|
|
model=task.get("model"),
|
|
response_format="json",
|
|
)
|
|
return response
|
|
|
|
async def run(self, draft_state: dict):
|
|
print_agent_output(f"Rewriting draft based on feedback...", agent="REVISOR")
|
|
revision = await self.revise_draft(draft_state)
|
|
|
|
if draft_state.get("task").get("verbose"):
|
|
if self.websocket and self.stream_output:
|
|
await self.stream_output(
|
|
"logs",
|
|
"revision_notes",
|
|
f"Revision notes: {revision.get('revision_notes')}",
|
|
self.websocket,
|
|
)
|
|
else:
|
|
print_agent_output(
|
|
f"Revision notes: {revision.get('revision_notes')}", agent="REVISOR"
|
|
)
|
|
|
|
return {
|
|
"draft": revision.get("draft"),
|
|
"revision_notes": revision.get("revision_notes"),
|
|
}
|