MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / evaluate_case

Function evaluate_case

masfactory/compatibility/dify/runtime.py:238–261  ·  view source on GitHub ↗
(case: dict[str, Any], state: DifyRuntimeState)

Source from the content-addressed store, hash-verified

236
237
238def evaluate_case(case: dict[str, Any], state: DifyRuntimeState) -> bool:
239 conditions = case.get("conditions") or []
240 if not conditions:
241 return False
242 logical = str(case.get("logical_operator") or "and").lower()
243 results: list[bool] = []
244 for cond in conditions:
245 if not isinstance(cond, dict):
246 continue
247 selector = cond.get("variable_selector") or []
248 left = state.resolve_selector(selector)
249 results.append(
250 _compare(
251 left,
252 str(cond.get("comparison_operator") or "="),
253 cond.get("value"),
254 str(cond.get("varType")) if cond.get("varType") is not None else None,
255 )
256 )
257 if not results:
258 return False
259 if logical == "or":
260 return any(results)
261 return all(results)
262
263
264def evaluate_handle(handle: str, cases: list[dict[str, Any]], state: DifyRuntimeState) -> bool:

Callers 1

evaluate_handleFunction · 0.85

Calls 2

resolve_selectorMethod · 0.80
_compareFunction · 0.70

Tested by

no test coverage detected