feat(engine): select the engine with a version option

This commit is contained in:
Stefan
2026-11-21 13:39:17 +01:00
parent e3d32a210d
commit 97343a301c
12 changed files with 196 additions and 6 deletions
+8 -1
View File
@@ -239,10 +239,17 @@ impl PyZenEngine {
None => Arc::new(PyDecisionLoader::default()),
};
let engine = DecisionEngine::new(
let mut engine = DecisionEngine::new(
loader,
Arc::new(PyCustomNode::new(custom_node, make_locals())),
);
if let Some(version) = options.get_item("version")? {
let version: u32 = version.extract()?;
engine.set_version(
zen_engine::EngineVersion::try_from(version)
.map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))?,
);
}
engine.compile();
Ok(Self {
+1
View File
@@ -43,6 +43,7 @@ ZenLoaderCallback: TypeAlias = Callable[[str], Union[str, dict, ZenDecisionConte
class ZenEngineOptions(TypedDict, total=False):
loader: Union[ZenLoaderCallback, ZenLoaderConfig]
customHandler: Callable
version: Literal[1, 2]
class EvaluateBatchRequest(TypedDict):