Files
miku-discord/readmes/ERROR_HANDLING_QUICK_REF.md

1.8 KiB

Error Handling Quick Reference

What Changed

When Miku encounters an error (like "Error 502" from llama-swap), she now says:

"Someone tell Koko-nii there is a problem with my AI."

And sends you a webhook notification with full error details.

Webhook Details

Webhook URL: https://discord.com/api/webhooks/1462216811293708522/... Mentions: @Koko-nii (User ID: 344584170839236608)

Error Notification Format

🚨 Miku Bot Error
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Error Message:
  Error: 502

User: username#1234
Channel: #general
Server: Guild ID: 123456789
User Prompt:
  Hi Miku! How are you?

Exception Type: HTTPError
Traceback:
  [Full Python traceback]

Files Changed

  1. NEW: bot/utils/error_handler.py

    • Main error handling logic
    • Webhook notifications
    • Error detection
  2. MODIFIED: bot/utils/llm.py

    • Added error handling to query_llama()
    • Prevents errors in conversation history
    • Catches all exceptions and HTTP errors
  3. NEW: bot/test_error_handler.py

    • Test suite for error detection
    • 26 test cases
  4. NEW: ERROR_HANDLING_SYSTEM.md

    • Full documentation

Testing

cd /home/koko210Serve/docker/miku-discord/bot
python test_error_handler.py

Expected: ✓ All 26 tests passed!

Coverage

Works with both llama-swap (NVIDIA) and llama-swap-rocm (AMD) Handles all message types (DMs, server messages, autonomous) Catches connection errors, timeouts, HTTP errors Prevents errors from polluting conversation history

No Changes Required

No configuration changes needed. The system is automatically active for:

  • All direct messages to Miku
  • All server messages mentioning Miku
  • All autonomous messages
  • All LLM queries via query_llama()