Protokoll #12533

ID12533
Zeitstempel2025-12-24 09:34:02.863008
Clientroot
IP145.224.96.190
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens952 (Input: 35, Output: 917)
Dauer86 ms
Request-Zeit2025-12-24 09:34:02.863008
Response-Zeit2025-12-24 09:34:02.949133

Request

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

Response

{
    "tool_response": {
        "type": "text",
        "file": {
            "filePath": "\/var\/www\/scripts\/pipeline\/generate.py",
            "content": "def generate_content(order_id, model=\"anthropic\", collection=\"documents\", context_limit=5):\n    \"\"\"\n    Main content generation function.\n\n    Args:\n        order_id: Content order ID\n        model: 'anthropic' or 'ollama'\n        collection: Qdrant collection to search\n        context_limit: Number of context chunks\n\n    Returns:\n        dict with version_id, content, sources\n    \"\"\"\n    db.connect()\n\n    try:\n        # Load order\n        order = get_order(order_id)\n        if not order:\n            return {\"error\": f\"Order {order_id} not found\"}\n\n        # Update status\n        update_order_status(order_id, \"generating\")\n\n        # Get RAG context\n        context = get_rag_context(order[\"briefing\"], collection, context_limit)\n\n        # Build profile\/contract\/structure\n        profile = None\n        if order.get(\"profile_config\"):\n            config = (\n                json.loads(order[\"profile_config\"])\n                if isinstance(order[\"profile_config\"], str)\n                else order[\"profile_config\"]\n            )\n            profile = {\"name\": order[\"profile_name\"], \"config\": config}\n\n        contract = None\n        if order.get(\"contract_config\"):\n            config = (\n                json.loads(order[\"contract_config\"])\n                if isinstance(order[\"contract_config\"], str)\n                else order[\"contract_config\"]\n            )\n            contract = {\"name\": order[\"contract_name\"], \"config\": config}\n\n        structure = None\n        output_format = \"markdown\"  # Default\n        if order.get(\"structure_config\"):\n            config = (\n                json.loads(order[\"structure_config\"])\n                if isinstance(order[\"structure_config\"], str)\n                else order[\"structure_config\"]\n            )\n            structure = {\"name\": order[\"structure_name\"], \"config\": config}\n            # Determine output format from structure\n            ausgabe = config.get(\"ausgabe\", {})\n            output_format = ausgabe.get(\"format\", \"markdown\")\n\n        # Build prompt\n        prompt = build_generation_prompt(order[\"briefing\"], context, profile, contract, structure)\n\n        # Generate content\n        content = call_llm(prompt, model, client_name=\"content-studio-generate\")\n\n        # Get current version number\n        cursor = db.execute(\n            \"SELECT MAX(version_number) as max_v FROM content_versions WHERE order_id = %s\", (order_id,)\n        )\n        result = cursor.fetchone()\n        cursor.close()\n        version_number = (result[\"max_v\"] or 0) + 1\n\n        # Save version with correct format\n        version_id = save_version(order_id, content, version_number, output_format)\n\n        # Save sources\n        save_sources(order_id, context)\n\n        # Update status\n        update_order_status(order_id, \"critique\")\n\n        return {\n            \"success\": True,\n            \"order_id\": order_id,\n            \"version_id\": version_id,\n            \"version_number\": version_number,\n            \"content\": content,\n            \"sources\": [{\"source\": c[\"source\"], \"score\": c[\"score\"]} for c in context],\n        }\n\n    except Exception as e:\n        update_order_status(order_id, \"draft\")\n        return {\"error\": str(e)}\n    finally:\n        db.disconnect()\n\n\ndef get_critic(critic_id):\n    \"\"\"Load critic from database.\"\"\"",
            "numLines": 100,
            "startLine": 570,
            "totalLines": 987
        }
    }
}
← Vorheriger Zur Liste Nächster →