mirror of
https://github.com/gorules/zen.git
synced 2026-11-30 00:07:34 +00:00
feat(engine): select the engine with a version option
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user