Skip to content

Latest commit

 

History

History
1 lines (1 loc) · 5.85 KB

File metadata and controls

1 lines (1 loc) · 5.85 KB

"API Documentation\n\nComplete API reference for model-fallback-skill scripts.\n\n## Table of Contents\n\n- health-check.py\n- fallback-trigger.py\n\n---\n\n## health-check.py\n\nProactive health monitoring for model providers.\n\n### Usage\n\nbash\npython3 scripts/health-check.py <command> [options]\n\n\n### Commands\n\n#### start\n\nStart the health check monitor in the background.\n\nbash\npython3 scripts/health-check.py start\n\n\nOptions:\n- --interval SECONDS - Check interval in seconds (default: 300)\n- --log-file PATH - Log file path (default: ~/.nanobot/logs/model-health.log)\n\nExample:\nbash\npython3 scripts/health-check.py start --interval 600\n\n\n#### stop\n\nStop the health check monitor.\n\nbash\npython3 scripts/health-check.py stop\n\n\n#### status\n\nShow the current status of the health check monitor.\n\nbash\npython3 scripts/health-check.py status\n\n\nOutput:\n\nHealth Check Status:\n- Running: Yes\n- PID: 12345\n- Started: 2025-02-12 18:00:00\n- Last Check: 2025-02-12 18:05:00\n- Current Model: minimax/m2.5\n- Fallback Models: 3 available\n\n\n#### check\n\nRun a single health check immediately.\n\nbash\npython3 scripts/health-check.py check\n\n\nOptions:\n- --verbose - Show detailed output\n\nOutput:\n\nHealth Check Results:\n- Model: minimax/m2.5\n- Status: HEALTHY\n- Response Time: 1.2s\n- Error Rate: 0%\n- Timeout Rate: 0%\n- Last Check: 2025-02-12 18:05:00\n\n\n#### test\n\nTest health check with a mock model call.\n\nbash\npython3 scripts/health-check.py test\n\n\n#### diagnose\n\nRun diagnostics on the health check system.\n\nbash\npython3 scripts/health-check.py diagnose\n\n\nOutput:\n\nDiagnostics:\n- Python: 3.12.0\n- Config: Found\n- Current Model: minimax/m2.5\n- Fallback Models: 3\n- Log File: ~/.nanobot/logs/model-health.log\n- PID File: /tmp/health-check.pid\n- Status: Running\n\n\n### Configuration Parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| CHECK_INTERVAL | 300 | Time between health checks (seconds) |\n| MAX_RESPONSE_TIME | 30 | Maximum acceptable response time (seconds) |\n| MAX_TIMEOUT_RATE | 0.2 | Maximum timeout rate (0.0-1.0) |\n| MAX_ERROR_RATE | 0.1 | Maximum error rate (0.0-1.0) |\n| SAMPLE_SIZE | 10 | Number of requests to sample for rate calculation |\n\n### Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| 0 | Success |\n| 1 | General error |\n| 2 | Config not found |\n| 3 | No fallback models configured |\n| 4 | Health check already running |\n| 5 | Health check not running |\n\n---\n\n## fallback-trigger.py\n\nReactive fallback triggering and management.\n\n### Usage\n\nbash\npython3 scripts/fallback-trigger.py <command> [options]\n\n\n### Commands\n\n#### trigger\n\nTrigger a fallback to the next model.\n\nbash\npython3 scripts/fallback-trigger.py trigger\n\n\nOptions:\n- --reason TEXT - Reason for fallback (default: "Manual trigger")\n- --force - Force fallback even if current model is healthy\n\nExample:\nbash\npython3 scripts/fallback-trigger.py trigger --reason \"High error rate\" --force\n\n\n#### status\n\nShow current fallback status.\n\nbash\npython3 scripts/fallback-trigger.py status\n\n\nOutput:\n\nFallback Status:\n- Current Model: minimax/m2.5\n- Fallback Chain:\n 1. openrouter/anthropic/claude-3.5-sonnet\n 2. openrouter/glm-4.7\n 3. openrouter/google/gemini-2.0-flash-exp:free\n- Last Fallback: Never\n- Total Fallbacks: 0\n\n\n#### list\n\nList all configured fallback models.\n\nbash\npython3 scripts/fallback-trigger.py list\n\n\nOutput:\n\nFallback Models:\n1. openrouter/anthropic/claude-3.5-sonnet\n2. openrouter/glm-4.7\n3. openrouter/google/gemini-2.0-flash-exp:free\n\n\n#### test\n\nTest fallback without actually switching.\n\nbash\npython3 scripts/fallback-trigger.py test\n\n\nOutput:\n\nFallback Test:\n- Current Model: minimax/m2.5\n- Next Model: openrouter/anthropic/claude-3.5-sonnet\n- Would Switch: Yes\n- Config Valid: Yes\n\n\n#### reset\n\nReset fallback counter and logs.\n\nbash\npython3 scripts/fallback-trigger.py reset\n\n\nOptions:\n- --clear-logs - Also clear fallback logs\n\n#### history\n\nShow fallback history.\n\nbash\npython3 scripts/fallback-trigger.py history\n\n\nOptions:\n- --limit N - Show last N entries (default: 10)\n\nOutput:\n\nFallback History:\n2025-02-12 18:00:00 - minimax/m2.5 -> openrouter/claude-3.5-sonnet (High error rate)\n2025-02-12 17:30:00 - openrouter/glm-4.7 -> minimax/m2.5 (Manual test)\n\n\n### Configuration Parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| CONFIG_PATH | ~/.nanobot/config.json | Path to nanobot config |\n| LOG_PATH | ~/.nanobot/logs/model-fallback.log | Path to fallback log |\n| HISTORY_PATH | ~/.nanobot/logs/fallback-history.json | Path to fallback history |\n| TRIGGER_FILE | /tmp/nanobot-restart | Path to restart trigger file |\n\n### Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| 0 | Success |\n| 1 | General error |\n| 2 | Config not found |\n| 3 | No fallback models available |\n| 4 | No more fallback models in chain |\n| 5 | Config invalid |\n\n---\n\n## Examples\n\n### Start health check with custom interval\n\nbash\npython3 scripts/health-check.py start --interval 600\n\n\n### Trigger fallback with reason\n\nbash\npython3 scripts/fallback-trigger.py trigger --reason \"API timeout exceeded\"\n\n\n### Check health with verbose output\n\nbash\npython3 scripts/health-check.py check --verbose\n\n\n### View fallback history\n\nbash\npython3 scripts/fallback-trigger.py history --limit 20\n\n\n### Run diagnostics\n\nbash\npython3 scripts/health-check.py diagnose\npython3 scripts/fallback-trigger.py status\n]"]