Migrated all interfaces to get and return strings. Added tests and evals for all functions (except the random generation) Math functions are now organized into different math categories --------- Co-authored-by: Nate Barbettini <nate@arcade-ai.com>
29 lines
864 B
Python
29 lines
864 B
Python
import math
|
|
from decimal import Decimal
|
|
from typing import Annotated
|
|
|
|
from arcade.sdk import tool
|
|
|
|
|
|
@tool
|
|
def log(
|
|
a: Annotated[str, "The number to take the logarithm of as a string"],
|
|
base: Annotated[str, "The logarithmic base as a string"],
|
|
) -> Annotated[str, "The logarithm of the number with the specified base as a string"]:
|
|
"""
|
|
Calculate the logarithm of a number with a given base
|
|
"""
|
|
# Use Decimal for arbitrary precision
|
|
return str(math.log(Decimal(a), Decimal(base)))
|
|
|
|
|
|
@tool
|
|
def power(
|
|
a: Annotated[str, "The base number as a string"],
|
|
b: Annotated[str, "The exponent as a string"],
|
|
) -> Annotated[str, "The result of raising a to the power of b as a string"]:
|
|
"""
|
|
Calculate one number raised to the power of another
|
|
"""
|
|
# Use Decimal for arbitrary precision
|
|
return str(Decimal(a) ** Decimal(b))
|