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.
โจ 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:
- โ Execute your command
- โ Capture output in real-time
- โ Detect errors automatically
- โ Analyze with AI and dynamic documentation
- โ 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:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ฌ Support
- ๐ง Email: ry604492@gmail.com
- ๐ Issues: https://github.com/Divodude/ai-logmaster/issues
- ๐ Docs: https://github.com/Divodude/ai-logmaster
โ Buy Me a Coffee
If you find AI LogMaster helpful and want to support its development, consider buying me a coffee!
Scan to send โน100 via UPI
Every contribution, no matter how small, is greatly appreciated! ๐
๐ Acknowledgments
Built with:
- LangChain - LLM framework
- LangGraph - Agent orchestration
- DuckDuckGo Search - Documentation retrieval
๐ฏ 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3f2b1a1d9f4726c7cc39d700dd77d9588282f9d92a3b41495753acb394fa20a
|
|
| MD5 |
6c0f107a97c3a3f9aa5c0ea3c7f5d197
|
|
| BLAKE2b-256 |
f3ab8d3646e46e47d5c05d703af478c95a137287dafe532f0884f276d69d542a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e915ab37f5e46e4f483ba4ab28930a5521bb9f145b010f496aeb1247e1261c43
|
|
| MD5 |
7c71fa8bae106ac1e432ea36ba6488b4
|
|
| BLAKE2b-256 |
afb740c0462536aab082437e3b5fb8aa4f004b180f23b9db57b2c51354d1b377
|