llama.cpp/examples/agent/tools/unsafe_python_tools.py

9 lines
246 B
Python

import math
def eval_python_expression(expr: str) -> float:
"""
Evaluate a Python expression reliably.
This can be used to compute complex nested mathematical expressions, or any python, really.
"""
return eval(expr)