Address copilot feedback

This commit is contained in:
oobabooga 2026-03-12 19:55:02 -07:00
parent 24fdcc52b3
commit 04213dff14
6 changed files with 14 additions and 6 deletions

View file

@ -16,7 +16,11 @@ def _eval(node):
if isinstance(node, ast.Constant) and isinstance(node.value, (int, float)):
return node.value
elif isinstance(node, ast.BinOp) and type(node.op) in OPERATORS:
return OPERATORS[type(node.op)](_eval(node.left), _eval(node.right))
left = _eval(node.left)
right = _eval(node.right)
if isinstance(node.op, ast.Pow) and isinstance(right, (int, float)) and abs(right) > 10000:
raise ValueError("Exponent too large (max 10000)")
return OPERATORS[type(node.op)](left, right)
elif isinstance(node, ast.UnaryOp) and type(node.op) in OPERATORS:
return OPERATORS[type(node.op)](_eval(node.operand))
raise ValueError(f"Unsupported expression")

View file

@ -17,7 +17,7 @@ tool = {
def execute(arguments):
count = arguments.get("count", 1)
sides = arguments.get("sides", 20)
count = max(1, min(arguments.get("count", 1), 1000))
sides = max(2, min(arguments.get("sides", 20), 1000))
rolls = [random.randint(1, sides) for _ in range(count)]
return {"rolls": rolls, "total": sum(rolls)}