feat: ✨ Add AI Export integration for log analysis#469
Open
whallysson wants to merge 1 commit intoopcodesio:mainfrom
Open
feat: ✨ Add AI Export integration for log analysis#469whallysson wants to merge 1 commit intoopcodesio:mainfrom
whallysson wants to merge 1 commit intoopcodesio:mainfrom
Conversation
- Add Ask AI button to export logs to ChatGPT and Claude - Add Copy as Markdown functionality for log entries - Create AiExportService with provider abstraction - Implement ChatGPT and Claude providers with URL generation - Add configuration options for enabling/disabling the feature - Add rate limiting to prevent abuse (10 requests per minute) - Add comprehensive test coverage for all new functionality - Update frontend with Vue component for AI interactions
Author
|
Hi @arukompas ! This PR adds AI Export functionality to help developers quickly analyze errors using AI assistants. The feature is fully configurable and can be disabled if not needed. It includes comprehensive tests and follows the existing code patterns. I'd love to hear your feedback and I'm happy to make any adjustments needed! Thanks for creating this amazing tool! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR adds AI Export functionality to Log Viewer, allowing users to quickly send error logs to AI assistants (ChatGPT and Claude) for analysis and debugging assistance.
✨ Features
🔧 Configuration
📸 Screenshots
Ask AI Button in Log Entry
The new "Ask AI" button appears on each log entry
AI Provider Dropdown
Users can choose between ChatGPT, Claude, or copy as markdown
prompt pre-populated with the log formatted in ChatGPT.
Visual feedback when markdown is copied to clipboard
How it Works
✅ Testing
• Added comprehensive test coverage for all new functionality
• Feature tests for API endpoints with rate limiting
• Unit tests for services and providers
• All tests passing
✓ AI Export Providers Endpoint → returns list of available providers✓ AI Export Providers Endpoint → returns 403 when feature is disabled✓ AI Export Endpoint → validates required fields✓ AI Export Endpoint → rejects invalid provider✓ AI Export Endpoint → enforces rate limiting✓ AI Export Endpoint → returns 404 when log not found✓ AI Export Endpoint → returns 403 when feature is disabled✓ AI Export Endpoint → returns correct response structure when successful✓ Copy as Markdown Endpoint → validates required fields✓ Copy as Markdown Endpoint → returns 404 when log not found✓ Copy as Markdown Endpoint → returns markdown when successful✓ Copy as Markdown Endpoint → returns 403 when feature is disabled📝 Implementation Details
Backend
• New Controller: AiExportController with three endpoints
• GET /api/ai/providers - Lists available AI providers
• POST /api/ai/export - Exports log to selected AI provider
• POST /api/ai/copy-markdown - Returns formatted markdown
• Service Layer: AiExportService handles formatting and sanitization
• Provider Interface: Extensible design for adding new AI providers
• Security: Automatic sanitization of sensitive patterns including:
• Passwords and API keys
• JWT tokens
• Database credentials
• Email addresses (optionally)
Frontend
• Vue Component: AskAiButton.vue with dropdown UI
• Pinia Store: State management for AI providers
• Integration: Seamlessly integrated into BaseLogTable.vue
• User Feedback: Toast notifications for success/error states
🚀 How to Use
LOG_VIEWER_AI_EXPORT_ENABLED=true🔍 Code Quality
• ✅ Laravel Pint formatting applied
• ✅ Follows existing code patterns and conventions
• ✅ No breaking changes
• ✅ Backward compatible
• ✅ Feature can be completely disabled if not needed
🎨 UI/UX Considerations
• Non-intrusive button placement
• Clear visual feedback
• Responsive design
• Keyboard accessible
• Follows existing Log Viewer design patterns
📊 Performance Impact
• Minimal - feature is lazy loaded
• No impact when disabled
• Efficient markdown generation
• Rate limiting prevents abuse
🔐 Privacy & Security
• All processing happens client-side
• No data is sent to any servers (only formatted for AI providers)
• Sensitive data is sanitized before export
• Users maintain full control over what gets sent to AI
📚 Documentation
The feature is self-documenting through:
• Clear configuration options in config/log-viewer.php
• Inline code comments
• Comprehensive test suite showing usage patterns
This feature enhances the debugging experience by leveraging AI assistants to help developers quickly understand and resolve errors in their Laravel applications.