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

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.0.tar.gz (18.3 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.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai_logmaster-1.0.0.tar.gz
  • Upload date:
  • Size: 18.3 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.0.tar.gz
Algorithm Hash digest
SHA256 5426c1123edcac4fd96d6851937cf4dd52e6f1b47938d8868bea498611573e78
MD5 40a8e696030bb95bc58916a69b996fbe
BLAKE2b-256 1a53b46dffb03e0f4a2269007e73b476a73b86df2ce891533789749c2094ff1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ai_logmaster-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4acd08b3210a83c2716dcd60633a669d0b4bc1f4018d215c5ae7022409d0f7af
MD5 254bf5f869415ba0317f6988dac67f43
BLAKE2b-256 7250c5becd4f76f88366a2f0a14bf3c47c09725ec8df68e1f43eab8942446c03

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