Skip to content

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

  1. Clone the repository:

    git clone https://github.com/malvavisc0/enhancedtoolkits.git
    cd enhancedtoolkits
    

  2. Create development environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    

  3. Install development dependencies:

    pip install -e ".[dev]"
    

  4. Run tests:

    pytest
    

๐Ÿ“ 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:

pip install pre-commit
pre-commit install

Configuration Files

  • pyproject.toml: Project metadata and tool configuration
  • .github/workflows/: CI/CD pipeline configuration
  • pytest.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

  1. Update version in pyproject.toml
  2. Update CHANGELOG.md with new features and fixes
  3. Run full test suite: pytest
  4. Build package: python -m build
  5. Create GitHub release with tag
  6. Deploy documentation: mkdocs gh-deploy

๐Ÿค Contributing

Getting Started

  1. Fork the repository on GitHub
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes with tests
  4. Run the test suite: pytest
  5. 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:

  1. Create the toolkit file in src/enhancedtoolkits/
  2. Inherit from StrictToolkit
  3. Implement required methods with proper validation
  4. Add comprehensive tests
  5. Update documentation
  6. 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

External Resources

Community

๐Ÿ†˜ 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! ๐Ÿš€