Developer Guide¶
Welcome to the Enhanced Toolkits developer guide! This section provides information for developers who want to contribute to the project, understand the codebase, or deploy their own instances.
๐ Quick Start for Developers¶
Development Setup¶
-
Clone the repository:
-
Create development environment:
-
Install development dependencies:
-
Run tests:
๐ Project Structure¶
enhancedtoolkits/
โโโ src/enhancedtoolkits/ # Main package
โ โโโ __init__.py # Package initialization
โ โโโ base.py # StrictToolkit base class
โ โโโ reasoning.py # Reasoning tools
โ โโโ searxng.py # Search tools
โ โโโ thinking.py # Thinking tools
โ โโโ files.py # File operations
โ โโโ finance.py # Financial data
โ โโโ youtube.py # YouTube integration
โ โโโ weather.py # Weather data
โ โโโ downloader.py # Content downloading
โ โโโ calculators/ # Calculator modules
โ โ โโโ __init__.py
โ โ โโโ base.py # Calculator base classes
โ โ โโโ arithmetic.py # Basic math operations
โ โ โโโ time_value.py # Time value of money
โ โ โโโ investment.py # Investment analysis
โ โ โโโ loan.py # Loan calculations
โ โ โโโ bond.py # Bond valuations
โ โ โโโ risk.py # Risk metrics
โ โ โโโ depreciation.py # Asset depreciation
โ โ โโโ business.py # Business analysis
โ โ โโโ utility.py # Utility functions
โ โโโ utils/ # Utility modules
โ โโโ __init__.py
โ โโโ schema.py # Data schemas
โโโ docs/ # Documentation
โโโ tests/ # Test suite
โโโ pyproject.toml # Project configuration
โโโ README.md # Project overview
โโโ LICENSE # MIT License
๐๏ธ Architecture Overview¶
StrictToolkit Base Class¶
All toolkits inherit from StrictToolkit
, which provides:
- Parameter validation: Ensures all parameters are marked as required
- OpenAI compatibility: Consistent function calling interface
- Error handling: Standardized error responses
- Logging: Comprehensive logging and debugging
from enhancedtoolkits.base import StrictToolkit
class MyCustomToolkit(StrictToolkit):
def my_method(self, required_param: str, optional_param: str = "default") -> str:
"""All parameters become required in the JSON schema."""
return f"Result: {required_param}, {optional_param}"
Toolkit Design Patterns¶
1. Input Validation¶
def _validate_inputs(self, **kwargs):
"""Validate all input parameters."""
for key, value in kwargs.items():
if not isinstance(value, expected_type):
raise ValueError(f"Invalid {key}: {value}")
2. Error Handling¶
try:
result = self._perform_operation()
return self._format_success_response(result)
except SpecificError as e:
return self._format_error_response("operation", str(e))
3. Caching¶
@lru_cache(maxsize=128)
def _cached_operation(self, cache_key: str):
"""Cache expensive operations."""
return self._expensive_operation(cache_key)
๐งช Testing¶
Running Tests¶
# Run all tests
pytest
# Run with coverage
pytest --cov=enhancedtoolkits
# Run specific test file
pytest tests/test_reasoning.py
# Run with verbose output
pytest -v
Test Structure¶
tests/
โโโ conftest.py # Test configuration
โโโ test_base.py # Base class tests
โโโ test_reasoning.py # Reasoning tools tests
โโโ test_finance.py # Finance tools tests
โโโ test_calculators/ # Calculator tests
โ โโโ test_arithmetic.py
โ โโโ test_time_value.py
โ โโโ ...
โโโ integration/ # Integration tests
โโโ test_toolkit_integration.py
โโโ test_api_compatibility.py
Writing Tests¶
import pytest
from enhancedtoolkits import CalculatorTools
class TestArithmeticCalculator:
def setup_method(self):
self.calculator = CalculatorTools()
def test_add_positive_numbers(self):
result = self.calculator.add(5, 3)
assert result == "8"
def test_divide_by_zero_raises_error(self):
with pytest.raises(ZeroDivisionError):
self.calculator.divide(10, 0)
@pytest.mark.parametrize("a,b,expected", [
(1, 1, "2"),
(0, 5, "5"),
(-3, 3, "0")
])
def test_add_various_inputs(self, a, b, expected):
result = self.calculator.add(a, b)
assert result == expected
๐ง Development Tools¶
Code Quality¶
The project uses several tools to maintain code quality:
# Code formatting
black src/ tests/
# Import sorting
isort src/ tests/
# Linting
flake8 src/ tests/
# Type checking
mypy src/
Pre-commit Hooks¶
Install pre-commit hooks to automatically run quality checks:
Configuration Files¶
pyproject.toml
: Project metadata and tool configuration.github/workflows/
: CI/CD pipeline configurationpytest.ini
: Test configuration.gitignore
: Git ignore patterns
๐ฆ Building and Distribution¶
Building the Package¶
# Install build tools
pip install build
# Build the package
python -m build
# This creates:
# dist/enhancedtoolkits-x.x.x-py3-none-any.whl
# dist/enhancedtoolkits-x.x.x.tar.gz
Local Installation¶
# Install in development mode
pip install -e .
# Install with all dependencies
pip install -e ".[full]"
๐ Deployment¶
Documentation Deployment¶
# Install MkDocs dependencies
pip install -r docs/requirements.txt
# Serve documentation locally
mkdocs serve
# Deploy to GitHub Pages
mkdocs gh-deploy
Release Process¶
- Update version in
pyproject.toml
- Update CHANGELOG.md with new features and fixes
- Run full test suite:
pytest
- Build package:
python -m build
- Create GitHub release with tag
- Deploy documentation:
mkdocs gh-deploy
๐ค Contributing¶
Getting Started¶
- Fork the repository on GitHub
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes with tests
- Run the test suite:
pytest
- Submit a pull request
Contribution Guidelines¶
- Code Style: Follow PEP 8 and use Black for formatting
- Tests: Include tests for new features and bug fixes
- Documentation: Update documentation for new features
- Commit Messages: Use clear, descriptive commit messages
- Pull Requests: Include description of changes and testing done
Adding New Toolkits¶
To add a new toolkit:
- Create the toolkit file in
src/enhancedtoolkits/
- Inherit from StrictToolkit
- Implement required methods with proper validation
- Add comprehensive tests
- Update documentation
- Add to
__init__.py
exports
Example:
# src/enhancedtoolkits/my_toolkit.py
from .base import StrictToolkit
class MyToolkit(StrictToolkit):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def my_method(self, param: str) -> str:
"""Method description."""
try:
# Validate inputs
if not param:
raise ValueError("param cannot be empty")
# Perform operation
result = self._process(param)
# Return formatted result
return self._format_response(result)
except Exception as e:
return self._handle_error("my_method", e)
๐ Resources¶
Documentation¶
- Core Toolkits - Detailed toolkit documentation
- Calculator Modules - Calculator documentation
- API Reference - Complete API documentation
External Resources¶
- Agno Framework - AI agent framework
- OpenAI Function Calling - Function calling guide
- Python Packaging - Python packaging guide
Community¶
- GitHub Issues - Bug reports and feature requests
- GitHub Discussions - Community discussions
- Contributing Guide - Detailed contribution guidelines
๐ Getting Help¶
- Documentation Issues: Check existing docs or open an issue
- Bug Reports: Use GitHub issues with detailed reproduction steps
- Feature Requests: Discuss in GitHub discussions first
- Development Questions: Join community discussions
Thank you for contributing to Enhanced Toolkits! ๐