enh: better fc example

This commit is contained in:
Timothy J. Baek 2024-05-31 22:35:17 -07:00
parent 828ad33cce
commit 6b42931cb5

View File

@ -77,12 +77,21 @@ And answer according to the language of the user's question.""",
print(location, unit)
return f"{location}: Sunny"
def get_user_name(self, user_id: str) -> str:
def calculator(self, equation: str) -> str:
"""
Get the user's name from the user_id.
Calculate the result of an equation.
:param equation: The equation to calculate.
"""
print(user_id)
return "John Doe"
# Avoid using eval in production code
# https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
try:
result = eval(equation)
return f"{equation} = {result}"
except Exception as e:
print(e)
return "Invalid equation"
self.functions = Functions()