Tools1 XVI. 작은 AI Agent에 5가지 기능을 추가한 프로그램(끝) # 1. Tools from pathlib import Path def calculator(expr:str)->str: """(20*4)+15와 같은 간단한 산술 표현식을 계산합니다.""" allowed = set("0123456789+-*/().") expr = expr.replace(" ", "") if not expr or not set(expr) allowed: return "오류: 숫자와 +-*/().만 허용됩니다." try: return str(eval(expr)) except (SyntaxError, ZeroDivisionError) as e: .. 2026. 8. 26. 이전 1 다음 반응형