Protokoll #30943

ID30943
Zeitstempel2025-12-31 00:23:12.504384
Clientroot
IP145.224.72.245
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens1,016 (Input: 38, Output: 978)
Dauer142 ms
Request-Zeit2025-12-31 00:23:12.504384
Response-Zeit2025-12-31 00:23:12.646048

Request

{
    "event": "PreToolUse",
    "tool_name": "Read",
    "tool_input": {
        "file_path": "\/var\/www\/scripts\/pipeline\/generators\/critic.py",
        "offset": 100,
        "limit": 100
    }
}

Response

{
    "tool_response": {
        "type": "text",
        "file": {
            "filePath": "\/var\/www\/scripts\/pipeline\/generators\/critic.py",
            "content": "                try:\n                    feedback = json.loads(repaired)\n                    feedback[\"critic_name\"] = critic[\"name\"]\n                    return feedback\n                except json.JSONDecodeError:\n                    pass\n\n        return {\n            \"critic_name\": critic[\"name\"],\n            \"rating\": 5,\n            \"passed\": False,\n            \"issues\": [\"Konnte Feedback nicht parsen\"],\n            \"suggestions\": [],\n            \"summary\": response[:500],\n        }\n\n    except Exception as e:\n        return {\"error\": str(e)}\n    finally:\n        db.disconnect()\n\n\ndef run_critique_round(version_id: int, model: str = \"anthropic\") -> dict:\n    \"\"\"\n    Run all active critics on a content version.\n\n    Returns:\n        dict with all critique results\n    \"\"\"\n    db.connect()\n\n    try:\n        # Get version content and order settings (including selected_critics)\n        cursor = db.execute(\n            \"\"\"SELECT cv.*, co.id as order_id, co.current_critique_round,\n                      co.selected_critics, co.quality_check\n               FROM content_versions cv\n               JOIN content_orders co ON cv.order_id = co.id\n               WHERE cv.id = %s\"\"\",\n            (version_id,),\n        )\n        version = cursor.fetchone()\n        cursor.close()\n\n        if not version:\n            return {\"error\": \"Version not found\"}\n\n        # Check if quality_check is enabled\n        if not version.get(\"quality_check\", False):\n            return {\"success\": True, \"skipped\": True, \"message\": \"Qualitätsprüfung deaktiviert\"}\n\n        content_data = json.loads(version[\"content\"]) if isinstance(version[\"content\"], str) else version[\"content\"]\n        content_text = content_data.get(\"text\", \"\")\n\n        # Parse selected_critics from order (JSON array of IDs)\n        selected_critics_raw = version.get(\"selected_critics\")\n        if selected_critics_raw:\n            if isinstance(selected_critics_raw, str):\n                selected_critic_ids = json.loads(selected_critics_raw)\n            else:\n                selected_critic_ids = selected_critics_raw\n        else:\n            selected_critic_ids = []\n\n        # Get critics - filter by selected_critics if specified\n        if selected_critic_ids:\n            # Only use selected critics\n            placeholders = \", \".join([\"%s\"] * len(selected_critic_ids))\n            sql = (\n                \"SELECT id, name FROM content_config \"\n                f\"WHERE type = 'critic' AND status = 'active' AND id IN ({placeholders}) \"\n                \"ORDER BY sort_order\"\n            )\n            cursor = db.execute(sql, tuple(selected_critic_ids))\n        else:\n            # Fallback: use all active critics if none selected\n            sql = (\n                \"SELECT id, name FROM content_config \"\n                \"WHERE type = 'critic' AND status = 'active' ORDER BY sort_order\"\n            )\n            cursor = db.execute(sql)\n        critics = cursor.fetchall()\n        cursor.close()\n\n        # Increment critique round\n        new_round = (version[\"current_critique_round\"] or 0) + 1\n        cursor = db.execute(\n            \"UPDATE content_orders SET current_critique_round = %s WHERE id = %s\", (new_round, version[\"order_id\"])\n        )\n        db.commit()\n        cursor.close()\n\n        # Run each critic\n        results = []\n        all_passed = True\n\n        for critic in critics:\n            db.disconnect()  # Disconnect before calling run_critic\n            feedback = run_critic(content_text, critic[\"id\"], model)\n            db.connect()  # Reconnect",
            "numLines": 100,
            "startLine": 100,
            "totalLines": 353
        }
    }
}
← Vorheriger Zur Liste Nächster →