File size: 2,856 Bytes
2dfc473
 
 
 
 
 
 
 
 
 
 
 
7289c0c
 
 
 
 
 
 
 
2dfc473
 
 
 
 
 
 
 
 
 
 
 
7289c0c
2dfc473
 
7289c0c
2dfc473
 
 
 
7289c0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2dfc473
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Proofreader agent - Quality control specialist."""
from typing import Any, Dict
from base_agent import BaseAgent


class ProofreaderAgent(BaseAgent):
    """Proofreader agent that performs final quality control."""

    def __init__(self):
        """Initialize the Proofreader agent."""
        system_prompt = (
            "You are the Script Proofreader. Check for grammar, formatting, continuity errors, "
            "character name consistency, and style guide violations.\n\n"
            "CRITICAL:\n"
            "1. You will receive 'comedy_sharpened_script' as input. If it's empty, return an error.\n"
            "2. Verify all character names match the character_list provided.\n"
            "3. Return the corrected final script - this MUST NOT be empty.\n"
            "4. The 'final_locked_script' is the primary deliverable and must contain the full script.\n\n"
            "Return the corrected final script and a brief QC report as JSON with keys: "
            "final_locked_script, qc_report, continuity_log_update."
        )
        super().__init__(
            agent_id="proofreader",
            agent_name="Proofreader",
            system_prompt=system_prompt,
        )

    def final_qc(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
        """Perform final quality control on the script.

        Args:
            inputs: Dictionary with keys:
                - comedy_sharpened_script: From Comedy Writer (MUST be non-empty)
                - style_guide: Style reference
                - continuity_log: Continuity tracking
                - character_list: List of valid character names

        Returns:
            Dictionary with final script and QC report
        """
        # Validate input
        comedy_script = inputs.get("comedy_sharpened_script", "")
        if not comedy_script or (isinstance(comedy_script, str) and not comedy_script.strip()):
            return {
                "final_locked_script": "",
                "qc_report": {
                    "issues": ["CRITICAL: Received empty comedy_sharpened_script. Cannot produce final locked script."],
                    "style_alignment": "N/A - no content to check",
                    "character_consistency": "N/A - no content to check",
                    "formatting_notes": "N/A - no content to check",
                    "recommendations": ["Ensure Comedy Writer produces non-empty output before reaching Proofreader."],
                },
                "continuity_log_update": "Failed - no script to update continuity for.",
            }
        
        outputs = self.process(inputs)
        
        # Save state
        self.save_state(
            {
                "inputs": inputs,
                "outputs": outputs,
            },
            filename="final_qc.json",
        )
        
        return outputs