Skip to main content

A flexible calculation toolbox designed for LLM Function Calling

Project description

Easy Calc Tool

PyPI version Python 3.8+ License: MIT Codecov CI

🚀 A flexible calculation toolbox designed specifically for LLM Function Calling

✨ Features

  • 🎯 LLM-Optimized: Natural language parameter parsing, making it easier for LLMs to call
  • 📊 All-in-One: Basic arithmetic, statistical analysis, time series, unit conversion, and more
  • 🔌 LangChain Ready: Out-of-the-box LangChain tool integration
  • 🛡️ Secure: Safe expression evaluation, preventing injection attacks
  • 📦 Lightweight: Core dependencies only (pandas, numpy)
  • 🚀 High Performance: Built-in caching, batch computation support
  • 🌍 Multi-format Support: CSV, JSON, DataFrame, file paths

📦 Installation

# Basic installation
pip install easy-calc-tool

# With LangChain support
pip install easy-calc-tool[langchain]

# Full installation (includes development tools)
pip install easy-calc-tool[all]

🚀 Quick Start

Basic Usage

from easy_calc_tool import EasyCalc

calc = EasyCalc()

# 基础算术
result = calc.calculate("arithmetic", None, expression="100 * 2 + 5")
print(result["result"])  # 205

# 统计分析
data = [
    {"sales": 100, "profit": 20},
    {"sales": 200, "profit": 40},
    {"sales": 300, "profit": 60}
]
result = calc.calculate("statistics", data, columns="sales", operations=["sum", "mean"])
print(result["statistics"]["sales"]["sum"])  # 600

Natural Language Interface

# Natural language aggregation
result = calc.calculate("aggregate", data, 
                       what="group by profit and sum sales")
print(result["grouped_result"])

🛠️ LangChain Integration

from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from easy_calc_tool.langchain import get_tools

llm = ChatOpenAI(model="gpt-4")
tools = get_tools()  # 一键获取所有工具

agent = create_agent(model=llm, tools=tools)
response = agent.invoke({
    "messages": [{"role": "user", "content": "计算 12345 * 67890"}]
})

📚 Supported Scenarios

  1. Basic Calculations
  • Arithmetic operations (+, -, *, /, **, %)
  • Trigonometric functions (sin, cos, tan)
  • Logarithmic and exponential functions
  • Percentage calculations
  • Rounding operations
  1. Statistical Analysis
  • Descriptive statistics (mean, median, mode, std, var)

  • Group statistics (GroupBy operations)

  • Correlation analysis

  • Regression analysis

  • Hypothesis testing

  1. Data Processing
  • Aggregation (sum, mean, count, min, max)

  • Data filtering

  • Pivot tables

  • Data transformation (normalization, standardization)

  1. Time Series
  • Moving averages

  • Growth rates (MoM, YoY)

  • Cumulative sums

  • Lag/Difference operations

  • Date arithmetic

  1. Other Features
  • Unit conversion (length, weight, temperature, currency)

  • Date calculations (age, date differences)

  • Financial calculations (loans, IRR, NPV)

  • Matrix operations

🔧 Configuration

from easy_calc_tool import EasyCalc

# Custom configuration
calc = EasyCalc(config={
    "cache_enabled": True,      # Enable result caching
    "precision": 2,              # Floating point precision
    "timeout": 30,              # Computation timeout (seconds)
    "max_data_size": 1000000,    # Maximum data rows
    "safe_mode": True,          # Enable safe evaluation mode
})

📖 Documentation

Full documentation is available at https://easy-calc-tool.readthedocs.io

  • Installation Guide

  • Usage Examples

  • API Reference

  • Contributing Guide

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/easy-calc-tool/easy-calc-tool.git
cd easy-calc-tool

# Install development dependencies
make install-dev

# Run tests
make test

# Run linting
make lint

# Format code
make format

📊 Benchmarks

Operation Data Size Time
Basic arithmetic N/A < 0.1ms
Statistics (mean, sum) 1M rows ~50ms
Group by aggregation 1M rows, 10 groups ~100ms
Time series (moving average) 100K rows ~30ms

🗺️ Roadmap

  • v0.2.0 - More statistical functions (ANOVA, chi-square)

  • v0.3.0 - Machine learning predictions

  • v0.4.0 - Visualization support

  • v0.5.0 - GPU acceleration

  • v1.0.0 - Stable release with full documentation

🙏 Acknowledgments

  • Built with pandas and numpy

  • Inspired by the needs of LLM function calling applications

  • Thanks to all contributors and users

📄 License

MIT License - see LICENSE file for details.

📧 Contact

Issues: GitHub Issues

Email: team@easy-calc-tool.com

Discord: Join our Discord

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_calc_tool-0.1.4.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_calc_tool-0.1.4-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file easy_calc_tool-0.1.4.tar.gz.

File metadata

  • Download URL: easy_calc_tool-0.1.4.tar.gz
  • Upload date:
  • Size: 49.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for easy_calc_tool-0.1.4.tar.gz
Algorithm Hash digest
SHA256 51100ae04c2eb499a530dfd2eda88ddf2c67c277aa3d5ddcbc4c1f9b4ad75439
MD5 344b537d1becc620289b81100ebbd3f3
BLAKE2b-256 6694f485cc7c1e8e5188c0ff6a1c3e25dfd44e42dad012c5c00a314a33332df3

See more details on using hashes here.

File details

Details for the file easy_calc_tool-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: easy_calc_tool-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for easy_calc_tool-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dc6ebf646af9253afe0b303ae0be50b1dd206448cb2d0026b6916525c600166e
MD5 63353213a272bc6783b5f7afcae22ca8
BLAKE2b-256 69dd3be2151e63dcaa7e02a6a07c9080ef6534ff7826a2b8c0937c27e353ea41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page