The Calculator Tool is a utility within the Atomic Agents ecosystem designed for performing a variety of mathematical calculations. It's essentially a wrapper around the sympy library to allow for expression-based calculations.
- Python 3.9 or later
- atomic-agents (See here for installation instructions)
- pydantic
- sympy
You can install the tool using any of the following options:
- Using the CLI tool that comes with Atomic Agents. Simply run
atomic
and select the tool from the list of available tools. After doing so you will be asked for a target directory to download the tool into. - Good old fashioned copy/paste: Just like any other tool inside the Atomic Forge, you can copy the code from this repo directly into your own project, provided you already have atomic-agents installed according to the instructions in the main README.
expression
(str): Mathematical expression to evaluate. For example, '2 + 2'.
result
(str): Result of the calculation.
Here's an example of how to use the Calculator Tool:
from tool.calculator import CalculatorTool, CalculatorToolConfig
# Initialize the tool
calculator = CalculatorTool(config=CalculatorToolConfig())
# Define input data
input_data = CalculatorTool.input_schema(
expression="sin(pi/2) + cos(pi/4)"
)
# Perform the calculation
result = calculator.run(input_data)
print(result) # Expected output: {"result":"1.70710678118655"}
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new feature branch.
- Commit your changes with clear messages.
- Open a pull request detailing your changes.
Please ensure you follow the project's coding standards and include tests for any new features or bug fixes.
This project is licensed under the same license as the main Atomic Agents project. See the LICENSE file in the repository root for more details.