1111from openprotein .models .base import ProteinModel
1212from openprotein .protein import Protein
1313
14+ from .boltzgen_schema import BoltzGenDesignSpec
15+
1416
1517class BoltzGenRequest (BaseModel ):
1618 "Specification for an BoltzGen request."
1719
1820 n : int = 1
1921 # protein: Protein
2022 structure_text : str | None = None
21- design_spec : dict [str , Any ]
23+ design_spec : BoltzGenDesignSpec | dict [str , Any ]
2224 diffusion_batch_size : int | None = None
2325 step_scale : float | None = None
2426 noise_scale : float | None = None
@@ -120,7 +122,7 @@ def get_metadata(self) -> ModelMetadata:
120122
121123 def generate (
122124 self ,
123- design_spec : dict [str , Any ],
125+ design_spec : BoltzGenDesignSpec | dict [str , Any ],
124126 structure_file : str | bytes | BinaryIO | None = None ,
125127 n : int = 1 ,
126128 diffusion_batch_size : int | None = None ,
@@ -133,12 +135,22 @@ def generate(
133135
134136 Parameters
135137 ----------
136- design_spec : dict[str, Any]
137- The BoltzGen design specification to run. This is the Python representation
138- of the BoltzGen yaml request specification.
139- structure_file : BinaryIO, optional
140- An input PDB file (as a file-like object) used for inpainting or other
141- guided design tasks where parts of an existing structure are provided.
138+ design_spec : BoltzGenDesignSpec | dict[str, Any]
139+ The BoltzGen design specification to run. Can be a typed BoltzGenDesignSpec
140+ object or a dict representing the BoltzGen yaml request specification.
141+
142+ Note: If the design_spec includes FileEntity objects with `path` fields,
143+ those paths are placeholders. The actual structure file content must be
144+ provided via the `structure_file` parameter below, as the platform backend
145+ currently only accepts structure files this way.
146+ structure_file : str | bytes | BinaryIO | None, optional
147+ An input PDB/CIF file used for inpainting or other guided design tasks
148+ where parts of an existing structure are provided. This parameter provides
149+ the actual structure content that corresponds to any FileEntity `path`
150+ fields in the design_spec. Can be:
151+ - A file path (str) to read from
152+ - Raw file content (bytes)
153+ - A file-like object (BinaryIO)
142154 n : int, optional
143155 The number of unique design trajectories to run (default is 1).
144156 diffusion_batch_size : int, optional
@@ -163,6 +175,10 @@ def generate(
163175 A future object that can be used to retrieve the results of the design
164176 job upon completion.
165177 """
178+ # Validate design_spec if it's a dict
179+ if isinstance (design_spec , dict ):
180+ design_spec = BoltzGenDesignSpec .model_validate (design_spec )
181+
166182 request = BoltzGenRequest (
167183 n = n ,
168184 design_spec = design_spec ,
0 commit comments