Skip to content

Commit

Permalink
Add preprocessing for values in simple_eval_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
HamadaSalhab committed Sep 24, 2024
1 parent ecc95ea commit d28c77c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion agents-api/agents_api/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ def get_evaluator(
def simple_eval_dict(exprs: dict[str, str], values: dict[str, Any]) -> dict[str, Any]:
evaluator = get_evaluator(names=values)

return {k: evaluator.eval(v) for k, v in exprs.items()}
def preprocess_expression(expr: str) -> str:
# Replace Jinja-like syntax with Python format
return re2.sub(r'\{\{(.*?)\}\}', lambda m: f"str({m.group(1).strip()})", expr)

return {k: evaluator.eval(preprocess_expression(v)) for k, v in exprs.items()}

0 comments on commit d28c77c

Please sign in to comment.