22
33from __future__ import annotations
44
5- from typing import Any , Dict , List , Iterable , Optional
5+ from typing import Dict , List , Iterable , Optional
66from typing_extensions import Self , Literal , override
77
8+ from ..types import ScenarioCreateParams , ScenarioEnvironmentParam
89from .._client import AsyncRunloop
910from .async_scenario import AsyncScenario
1011from .async_snapshot import AsyncSnapshot
@@ -379,14 +380,14 @@ def with_validation_type(self, validation_type: Literal["UNSPECIFIED", "FORWARD"
379380 self ._validation_type = validation_type
380381 return self
381382
382- def _build_params (self ) -> Dict [ str , Any ] :
383+ def _build_params (self ) -> ScenarioCreateParams :
383384 """Build the scenario creation parameters.
384385
385386 Weights are automatically normalized to sum to 1.0.
386387
387388 :raises ValueError: If required fields are missing
388389 :return: Parameters for scenario creation
389- :rtype: Dict[str, Any]
390+ :rtype: ScenarioCreateParams
390391 """
391392 if not self ._problem_statement :
392393 raise ValueError ("Problem statement is required. Call with_problem_statement() first." )
@@ -399,15 +400,16 @@ def _build_params(self) -> Dict[str, Any]:
399400
400401 # Normalize weights to sum to 1.0
401402 total_weight = sum (s ["weight" ] for s in self ._scorers )
402- normalized_scorers = [{** s , "weight" : s ["weight" ] / total_weight } for s in self ._scorers ]
403+ for s in self ._scorers :
404+ s ["weight" ] = s ["weight" ] / total_weight
403405
404- params : Dict [ str , Any ] = {
406+ params : ScenarioCreateParams = {
405407 "name" : self ._name ,
406408 "input_context" : {
407409 "problem_statement" : self ._problem_statement ,
408410 },
409411 "scoring_contract" : {
410- "scoring_function_parameters" : normalized_scorers ,
412+ "scoring_function_parameters" : self . _scorers ,
411413 },
412414 }
413415
@@ -416,7 +418,7 @@ def _build_params(self) -> Dict[str, Any]:
416418 params ["input_context" ]["additional_context" ] = self ._additional_context
417419
418420 # Build environment parameters if any are set
419- env_params : Dict [ str , Any ] = {}
421+ env_params : ScenarioEnvironmentParam = {}
420422 if self ._blueprint :
421423 env_params ["blueprint_id" ] = self ._blueprint .id
422424 if self ._snapshot :
0 commit comments