Calculator
Calculator enables an Agent to perform mathematical calculations.
Example
The following agent will calculate the result of 10*5 and then raise it to the power of 2:
1from kern.agent import Agent2from kern.tools.calculator import CalculatorTools34agent = Agent(5 tools=[6 CalculatorTools()7 ],8 markdown=True,9)1011agent.print_response("What is 10*5 then to the power of 2, do it step by step")Toolkit Functions
| Function | Description |
|---|---|
add | Adds two numbers and returns the result. |
subtract | Subtracts the second number from the first and returns the result. |
multiply | Multiplies two numbers and returns the result. |
divide | Divides the first number by the second and returns the result. Handles division by zero. |
exponentiate | Raises the first number to the power of the second number and returns the result. |
factorial | Calculates the factorial of a number and returns the result. Handles negative numbers. |
is_prime | Checks if a number is prime and returns the result. |
square_root | Calculates the square root of a number and returns the result. Handles negative numbers. |
You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.
Developer Resources
- View Tools