Skip to main content

Smart error analysis tool with AI-powered solutions

Project description

AI LogMaster

Smart error analysis tool with AI-powered solutions and dynamic documentation retrieval

Wrap any command and get instant, intelligent debugging help powered by AI, dynamic documentation fetching, and pattern-based caching.

License: MIT Python 3.8+

โœจ Features

  • ๐Ÿค– AI-Powered Analysis - Uses LangChain and LLMs for intelligent error diagnosis
  • ๐Ÿ“š Dynamic Documentation Retrieval - Automatically fetches relevant docs based on actual errors
  • ๐ŸŽฏ Smart Library Detection - Identifies 20+ frameworks/libraries automatically
  • ๐Ÿ’ฐ API Quota Optimization - Intelligent agent minimizes API calls (70-80% reduction)
  • โšก Zero Setup - Just wrap your command and go
  • ๐Ÿ”ง Multi-Provider Support - Works with OpenAI, Anthropic, Google, NVIDIA, and more
  • ๐ŸŽจ Class-Based Architecture - Clean, modular, and easily extensible
  • โš™๏ธ JSON Configuration - Customize error solutions and library keywords without code changes

๐Ÿš€ Installation

pip install ai-logmaster

Or install from source:

git clone https://github.com/Divodude/ai-logmaster.git
cd ai-logmaster
pip install -e .

๐Ÿ“– Quick Start

1. Initialize Configuration

logmaster init

This creates ~/.ai-logmaster/config.yaml. Edit it to set your API key:

ai:
  provider: "nvidia"
  api_key: "your-api-key-here"

Or use environment variable:

export NVIDIA_API_KEY="your-api-key"

2. Run Your Command

logmaster run "python your_script.py"

That's it! The tool will:

  1. โœ… Execute your command
  2. โœ… Capture output in real-time
  3. โœ… Detect errors automatically
  4. โœ… Analyze with AI and dynamic documentation
  5. โœ… Show solutions with relevant fixes

๐Ÿ“‹ Example Output

[TRIAGE] Executing: python broken.py
============================================================
[ERROR]  TypeError: unsupported operand type(s) for /: 'int' and 'str'
============================================================

[TRIAGE] โš ๏ธ  Error detected! Analyzing...

[AGENT] Classifying error type...
[AGENT] Error type: type, Needs docs: True
[AGENT] Detected library: python
[AGENT] Fetching documentation from web...
[AGENT] Search 1/2: python unsupported operand type(s)...
[AGENT] โœ“ Fetched 1847 chars of documentation
[AGENT] Analyzing with AI...
[AGENT] โœ“ Analysis complete (API calls: 1)

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ ๐Ÿ” DIAGNOSIS                                             โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Type: TypeError                                          โ•‘
โ•‘ Confidence: 90%                                          โ•‘
โ•‘ Method: AI + Docs                                        โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ ๐Ÿ“‹ ROOT CAUSE                                            โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Division operation between integer and string           โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ ๐Ÿ’ก RECOMMENDED FIXES                                     โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ 1. Ensure divisor is numeric type                       โ•‘
โ•‘ 2. Convert string to int/float if needed                โ•‘
โ•‘ 3. Validate inputs before operations                    โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ—๏ธ Architecture

AI LogMaster uses a clean, modular class-based architecture:

Core Components

ai_logmaster/
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ classifier.py          # ErrorClassifier - Pattern matching
โ”‚   โ”œโ”€โ”€ doc_fetcher.py         # DocumentationFetcher - Dynamic docs
โ”‚   โ”œโ”€โ”€ llm_client.py          # LLMClient - AI interactions
โ”‚   โ”œโ”€โ”€ agent.py               # Agent - LangGraph workflow
โ”‚   โ””โ”€โ”€ analyzer.py            # ErrorAnalyzer - Main orchestrator
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ cached_solutions.json  # Error patterns & solutions
โ”‚   โ””โ”€โ”€ library_keywords.json  # Library detection keywords
โ””โ”€โ”€ cli.py                     # Command-line interface

How It Works

Error Detected
    โ†“
ErrorClassifier (Pattern Matching - FREE)
    โ†“
    โ”œโ”€โ†’ Common Error? โ†’ Cached Solution (0 API calls) โœ…
    โ”‚
    โ””โ”€โ†’ Complex Error? โ†’ DocumentationFetcher (FREE)
                            โ†“
                         Detect Library (FastAPI, Django, etc.)
                            โ†“
                         Fetch Relevant Docs (DuckDuckGo)
                            โ†“
                         LLMClient Analysis (1 API call) ๐Ÿ’ฐ

โš™๏ธ Configuration

AI Providers

Edit ~/.ai-logmaster/config.yaml:

NVIDIA (Default - Free Tier Available)

ai:
  provider: "nvidia"
  model: "mistralai/mistral-small-3.1-24b-instruct-2503"
  api_key: "${NVIDIA_API_KEY}"
  base_url: "https://integrate.api.nvidia.com/v1"

OpenAI

ai:
  provider: "openai"
  model: "gpt-4"
  api_key: "${OPENAI_API_KEY}"

Anthropic

ai:
  provider: "anthropic"
  model: "claude-3-opus-20240229"
  api_key: "${ANTHROPIC_API_KEY}"

Customizing Error Solutions

Edit ai_logmaster/config/cached_solutions.json to add or modify error patterns and solutions:

{
  "error_patterns": {
    "your_error": ["YourError", "your error message"]
  },
  "cached_solutions": {
    "your_error": {
      "type": "Your Error Type",
      "cause": "Root cause explanation",
      "fixes": ["Fix 1", "Fix 2", "Fix 3"],
      "confidence": 0.80,
      "method": "Cached"
    }
  }
}

Customizing Library Detection

Edit ai_logmaster/config/library_keywords.json to add new libraries:

{
  "libraries": {
    "your_library": {
      "keywords": ["your_lib", "yourlib"],
      "description": "Your library description"
    }
  }
}

Supported Libraries (20+): FastAPI, Django, Flask, Requests, NumPy, Pandas, TensorFlow, PyTorch, SQLAlchemy, Asyncio, LangChain, OpenAI, Scikit-learn, Matplotlib, Selenium, BeautifulSoup, Pytest, Pydantic, Celery, Redis

API Optimization

agent:
  use_cached_solutions: true  # Use cached solutions for common errors
  fetch_documentation: true   # Fetch docs from web
  
  # These errors use cached solutions (0 API calls)
  cached_error_types:
    - connection
    - import
    - memory
    - timeout
    - permission
  
  # These errors use AI + docs (1 API call each)
  complex_error_types:
    - syntax
    - type
    - value
    - unknown

Quota Management

quota:
  enabled: true
  daily_limit: 100      # Maximum API calls per day
  warn_threshold: 0.8   # Warn at 80%

๐Ÿ’ป Programmatic Usage

Class-Based API (New)

from ai_logmaster import ErrorAnalyzer

# Create analyzer
analyzer = ErrorAnalyzer()

# Analyze error
error_context = """
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    result = 10 / "invalid"
TypeError: unsupported operand type(s) for /: 'int' and 'str'
"""

result = analyzer.analyze(error_context)

print(f"Type: {result['type']}")
print(f"Cause: {result['cause']}")
print(f"Fixes: {result['fixes']}")
print(f"API Calls: {result.get('api_calls_used', 0)}")

Using Individual Components

from ai_logmaster.core import ErrorClassifier, DocumentationFetcher

# Use classifier standalone
classifier = ErrorClassifier()
error_type, needs_docs = classifier.classify(context)

# Use doc fetcher standalone
doc_fetcher = DocumentationFetcher()
library = doc_fetcher.detect_library("from fastapi import FastAPI")
# Returns: "fastapi"

Backward Compatible API

from ai_logmaster import analyze_error

# Still works!
result = analyze_error(error_context)

๐Ÿ“Š API Call Optimization

Without Agent: Every error = 1 API call

With Agent:

  • Connection errors: 0 API calls โœ…
  • Import errors: 0 API calls โœ…
  • Memory errors: 0 API calls โœ…
  • Timeout errors: 0 API calls โœ…
  • Permission errors: 0 API calls โœ…
  • Syntax errors: 1 API call ๐Ÿ’ฐ
  • Type errors: 1 API call ๐Ÿ’ฐ
  • Unknown errors: 1 API call ๐Ÿ’ฐ

Result: 70-80% reduction in API calls!

๐ŸŽฏ Usage Examples

Python Script

logmaster run "python app.py"

Node.js Application

logmaster run "node server.js"

Shell Script

logmaster run "bash deploy.sh"

Complex Command

logmaster run "npm run build && npm start"

With Custom Buffer Size

logmaster run "python script.py" --buffer 200

๐Ÿงช Development

Install from Source

git clone https://github.com/Divodude/ai-logmaster.git
cd ai-logmaster
pip install -e .

Run Tests

# Test class architecture
python test_class_architecture.py

# Test library detection
python test_library_keywords.py

# Test agent workflow
python run_agent_tests.py

Project Structure

ai-logmaster/
โ”œโ”€โ”€ ai_logmaster/
โ”‚   โ”œโ”€โ”€ core/                   # Core modules
โ”‚   โ”‚   โ”œโ”€โ”€ classifier.py       # Error classification
โ”‚   โ”‚   โ”œโ”€โ”€ doc_fetcher.py      # Documentation fetching
โ”‚   โ”‚   โ”œโ”€โ”€ llm_client.py       # LLM interactions
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py            # LangGraph agent
โ”‚   โ”‚   โ””โ”€โ”€ analyzer.py         # Main analyzer
โ”‚   โ”œโ”€โ”€ config/                 # Configuration
โ”‚   โ”‚   โ”œโ”€โ”€ cached_solutions.json
โ”‚   โ”‚   โ”œโ”€โ”€ library_keywords.json
โ”‚   โ”‚   โ””โ”€โ”€ config.yaml.example
โ”‚   โ”œโ”€โ”€ cli.py                  # CLI interface
โ”‚   โ””โ”€โ”€ __init__.py
โ”œโ”€โ”€ tests/                      # Test files
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿ“ฆ Requirements

  • Python 3.8+
  • API key for your chosen AI provider (NVIDIA, OpenAI, Anthropic, or Google)

Dependencies

langchain-openai
langchain-community
langchain-core
langgraph
duckduckgo-search
python-dotenv

๐Ÿค Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ’ฌ Support

โ˜• Buy Me a Coffee

If you find AI LogMaster helpful and want to support its development, consider buying me a coffee!

buymeacoffee.com/divodude

UPI QR Code

Scan to send โ‚น100 via UPI

Every contribution, no matter how small, is greatly appreciated! ๐Ÿ™

๐Ÿ™ Acknowledgments

Built with:

๐ŸŽฏ Key Improvements in v1.0.1

  • โœ… Class-Based Architecture - Clean, modular, and extensible
  • โœ… Dynamic Documentation - Fetches docs based on actual errors
  • โœ… JSON Configuration - Customize without code changes
  • โœ… 20+ Library Detection - Automatic framework identification
  • โœ… Better Error Analysis - Improved accuracy with context-aware docs
  • โœ… Fallback Support - Graceful degradation if configs missing

Made with โค๏ธ by Divyansh

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

ai_logmaster-1.0.2.tar.gz (32.5 kB view details)

Uploaded Source

Built Distribution

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

ai_logmaster-1.0.2-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

Details for the file ai_logmaster-1.0.2.tar.gz.

File metadata

  • Download URL: ai_logmaster-1.0.2.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for ai_logmaster-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f3f2b1a1d9f4726c7cc39d700dd77d9588282f9d92a3b41495753acb394fa20a
MD5 6c0f107a97c3a3f9aa5c0ea3c7f5d197
BLAKE2b-256 f3ab8d3646e46e47d5c05d703af478c95a137287dafe532f0884f276d69d542a

See more details on using hashes here.

File details

Details for the file ai_logmaster-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ai_logmaster-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for ai_logmaster-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e915ab37f5e46e4f483ba4ab28930a5521bb9f145b010f496aeb1247e1261c43
MD5 7c71fa8bae106ac1e432ea36ba6488b4
BLAKE2b-256 afb740c0462536aab082437e3b5fb8aa4f004b180f23b9db57b2c51354d1b377

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