Skip to content

Commit 675eefb

Browse files
author
Tom Softreck
committed
update
1 parent ef484ed commit 675eefb

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ dependencies = [
3636
"grpcio-tools>=1.50.0,<2.0.0",
3737
"jinja2>=3.1.0,<4.0.0",
3838
"opencv-python>=4.7.0,<5.0.0",
39-
"numpy>=1.21.0,<2.0.0"
39+
"numpy>=1.21.0,<2.0.0",
40+
"python-nmap>=0.7.1,<1.0.0",
41+
"scapy>=2.5.0,<3.0.0",
42+
"python-rtsp-client>=0.2.7,<0.3.0",
43+
"imap-tools>=1.0.0,<2.0.0"
4044
]
4145

4246
[project.urls]

src/dialogchain/processors.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,28 @@ def _evaluate_condition(self, condition: str, context: Dict) -> bool:
138138
139139
The condition is evaluated as a Python expression with access to the context variables.
140140
For example: 'value > 10 and name == "test"'
141+
142+
Args:
143+
condition: The condition string, which may contain template variables like {{value}}
144+
context: Dictionary containing the variables to use for evaluation
145+
146+
Returns:
147+
bool: The result of the condition evaluation
141148
"""
142149
try:
143-
# Safely evaluate the condition with access to context variables
144-
return eval(condition, {"__builtins__": {}}, context)
150+
# First, render any template variables in the condition
151+
from jinja2 import Template
152+
template = Template(condition)
153+
rendered_condition = template.render(**context)
154+
155+
# Then evaluate the rendered condition as a Python expression
156+
# We use a safe evaluation context with only the context variables
157+
return eval(rendered_condition, {"__builtins__": {}}, context)
145158
except Exception as e:
146159
print(f"❌ Condition evaluation error: {e}, condition: {condition}")
160+
# In case of error, return False to filter out the message
161+
# but store the error in the context for debugging
162+
context['_filter_error'] = str(e)
147163
return False
148164

149165

0 commit comments

Comments
 (0)