trialdesignbench 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ """TrialDesignBench package.
2
+
3
+ TrialDesignBench is intended to provide benchmark tooling for evaluating AI
4
+ agents that reproduce clinical trial design characteristics from protocols and
5
+ statistical analysis plans.
6
+ """
7
+
8
+ from importlib.metadata import PackageNotFoundError, version
9
+
10
+ from trialdesignbench.cases import (
11
+ DocumentKind,
12
+ ExpectedDesign,
13
+ SourceDocument,
14
+ TrialDesignCase,
15
+ TrialPhase,
16
+ )
17
+
18
+ try:
19
+ __version__ = version("trialdesignbench")
20
+ except PackageNotFoundError:
21
+ __version__ = "0.0.0"
22
+
23
+ __all__ = [
24
+ "DocumentKind",
25
+ "ExpectedDesign",
26
+ "SourceDocument",
27
+ "TrialDesignCase",
28
+ "TrialPhase",
29
+ "__version__",
30
+ ]
@@ -0,0 +1,92 @@
1
+ """Core data structures for describing TrialDesignBench cases."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import Enum
6
+ from pathlib import Path
7
+
8
+ from pydantic import BaseModel, ConfigDict, Field, HttpUrl, model_validator
9
+
10
+
11
+ class DocumentKind(str, Enum):
12
+ """Supported source document categories for a trial design case."""
13
+
14
+ PROTOCOL = "protocol"
15
+ SAP = "statistical_analysis_plan"
16
+ PUBLICATION = "publication"
17
+ REGISTRY = "registry"
18
+
19
+
20
+ class TrialPhase(str, Enum):
21
+ """Clinical trial phases commonly represented in the benchmark."""
22
+
23
+ PHASE_1 = "phase_1"
24
+ PHASE_2 = "phase_2"
25
+ PHASE_3 = "phase_3"
26
+ PHASE_4 = "phase_4"
27
+
28
+
29
+ class SourceDocument(BaseModel):
30
+ """A source document used by an agent to reproduce a trial design."""
31
+
32
+ model_config = ConfigDict(frozen=True)
33
+
34
+ kind: DocumentKind
35
+ path: Path | None = None
36
+ url: HttpUrl | None = None
37
+ text: str | None = None
38
+
39
+ @model_validator(mode="after")
40
+ def require_source(self) -> SourceDocument:
41
+ """Require at least one way to access the document."""
42
+ if self.path is None and self.url is None and not self.text:
43
+ msg = "at least one of path, url, or text must be provided"
44
+ raise ValueError(msg)
45
+ return self
46
+
47
+
48
+ class ExpectedDesign(BaseModel):
49
+ """Objective design characteristics used for benchmark scoring."""
50
+
51
+ model_config = ConfigDict(frozen=True)
52
+
53
+ primary_endpoint: str | None = None
54
+ statistical_method: str | None = None
55
+ target_power: float | None = Field(default=None, ge=0.0, le=1.0)
56
+ alpha: float | None = Field(default=None, ge=0.0, le=1.0)
57
+ sample_size: int | None = Field(default=None, ge=1)
58
+
59
+
60
+ class TrialDesignCase(BaseModel):
61
+ """A single benchmark case for trial design reproduction."""
62
+
63
+ model_config = ConfigDict(frozen=True)
64
+
65
+ case_id: str
66
+ title: str
67
+ therapeutic_area: str
68
+ design_type: str
69
+ phase: TrialPhase | None = None
70
+ documents: tuple[SourceDocument, ...]
71
+ expected_design: ExpectedDesign = Field(default_factory=ExpectedDesign)
72
+
73
+ @model_validator(mode="after")
74
+ def require_documents(self) -> TrialDesignCase:
75
+ """Require at least one protocol or statistical analysis plan."""
76
+ kinds = {document.kind for document in self.documents}
77
+ if not ({DocumentKind.PROTOCOL, DocumentKind.SAP} & kinds):
78
+ msg = "case must include a protocol or statistical analysis plan"
79
+ raise ValueError(msg)
80
+ return self
81
+
82
+ def prompt(self) -> str:
83
+ """Create a concise agent prompt for the benchmark case."""
84
+ parts = [
85
+ f"Reproduce the clinical trial design for: {self.title}.",
86
+ f"Therapeutic area: {self.therapeutic_area}.",
87
+ f"Design type: {self.design_type}.",
88
+ "Produce executable R code and a short reproduction report.",
89
+ ]
90
+ if self.phase is not None:
91
+ parts.insert(2, f"Trial phase: {self.phase.value}.")
92
+ return " ".join(parts)
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: trialdesignbench
3
+ Version: 0.1.0
4
+ Summary: Evaluate whether AI agents can create efficient, reproducible, and safe clinical trial design
5
+ Author-email: Nan Xiao <me@nanx.me>
6
+ License-File: LICENSE
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Intended Audience :: Education
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: pydantic>=2.13.4
24
+ Requires-Dist: tqdm>=4.67.3
25
+ Description-Content-Type: text/markdown
26
+
27
+ # trialdesignbench
@@ -0,0 +1,6 @@
1
+ trialdesignbench/__init__.py,sha256=9MXgQfF7QjbjfnYfvtx93UDznTEbYnSp9O6hH7cZH2U,660
2
+ trialdesignbench/cases.py,sha256=MeDtfOhYiBkdO5mJwgzZwFJa1NqZ4F4FBEiJoLM9TdI,2995
3
+ trialdesignbench-0.1.0.dist-info/METADATA,sha256=KO50zhpkmMMJxlUJGgK-ziwry8-yZUI8ajBv97OGWVg,1105
4
+ trialdesignbench-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
5
+ trialdesignbench-0.1.0.dist-info/licenses/LICENSE,sha256=4zGHEsdfSEez2ga64vyYEJLVOtEg_YZb4QpIWB3xBmg,1069
6
+ trialdesignbench-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2026, trialdesignbench authors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.