Skip to main content

Smart error analysis tool with AI-powered solutions

Project description

AI LogMaster

Smart error analysis tool with AI-powered solutions

Wrap any command and get instant, intelligent debugging help powered by AI and documentation retrieval.

License: MIT Python 3.8+

Features

  • ๐Ÿค– AI-Powered Analysis - Uses LangChain and LLMs for intelligent error diagnosis
  • ๐Ÿ“š Smart Documentation Retrieval - Automatically fetches relevant docs when needed
  • ๐Ÿ’ฐ 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
  • ๐ŸŽฏ Pattern-Based Caching - Common errors use cached solutions (no API calls)

Installation

pip install ai-logmaster

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
  5. โœ… Show solutions with documentation references

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] Fetching documentation from web...
[AGENT] โœ“ Fetched 989 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                    โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ ๐Ÿ“š DOCUMENTATION SOURCES                                 โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ โ€ข https://docs.python.org/3/library/exceptions.html     โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

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}"

Google

ai:
  provider: "google"
  model: "gemini-pro"
  api_key: "${GOOGLE_API_KEY}"

Agent Optimization

Control when AI is used to minimize API costs:

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%

How It Works

Smart Agent Flow

Error Detected
    โ†“
Classify Error (Pattern Matching - FREE)
    โ†“
    โ”œโ”€โ†’ Common Error? โ†’ Use Cached Solution (0 API calls)
    โ”‚
    โ””โ”€โ†’ Complex/Unknown? โ†’ Fetch Docs (FREE) โ†’ AI Analysis (1 API call)

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

Advanced Features

RAG Support (Optional)

Install with RAG capabilities for enhanced documentation retrieval:

pip install ai-logmaster[rag]

Enable in config:

rag:
  enabled: true
  vector_store: "faiss"
  chunk_size: 1000
  top_k: 3

Development

Install from Source

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

Run Tests

python run_agent_tests.py

Requirements

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

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please open an issue or PR.

Support

โ˜• Buy Me a Coffee

If you find AI LogMaster helpful and want to support its development, consider buying me a coffee! Your support helps keep this project alive and continuously improving.

UPI QR Code

Scan to send โ‚น100 via UPI

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

Acknowledgments

Built with:


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.1.tar.gz (18.8 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.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai_logmaster-1.0.1.tar.gz
  • Upload date:
  • Size: 18.8 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.1.tar.gz
Algorithm Hash digest
SHA256 3a8539790f7ee41913de90a74830c7c0114e802f669bf02fd9fbf9e38b2c646e
MD5 d0693ea84c49b55d16da2bf0ab47c636
BLAKE2b-256 cb1ef678cca33d8aa6413ec7b852049107c32a5ed9021459f40197f36b2b2870

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ai_logmaster-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d350c716974e29b0e4fe901754272aec492314c5d8027ac832fdb34db762641b
MD5 bf8e0ca1718fe906acbc8aca097be18b
BLAKE2b-256 f59cc6cb4bc518c8604fc9be7fcbc7adfcdf4d3ffb860bb738454bdf336d4e5c

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