
    ۑi              	           d Z ddlZddlmZ g dZddededee   defd	Zd
edefdZddededee   defdZ	ddedefdZ
y)a%  
Prompt loader with versioning and channel support.

Usage:
    from prompts import get_prompt
    prompt_template = get_prompt("layer4a_concept", version="v1")

    # Fill in the template
    filled_prompt = prompt_template.format(
        channel_name="...",
        channel_description="...",
        ...
    )

    # For v4 (Director + Evaluator architecture):
    from prompts import get_prompt, get_revision_template
    director_prompt = get_prompt("layer4_director", version="v4")
    evaluator_prompt = get_prompt("layer4_evaluator", version="v4")
    revision_section = get_revision_template("v4")  # For revision passes

    # For v4 with channel-specific prompts:
    from prompts import get_channel_director_prompt
    prompt = get_channel_director_prompt("why_you_do_that", **template_vars)
    N)Optional)why_you_do_thathow_it_actually_workssixty_second_rabbit_holedesigned_to_trick_youthe_money_thingwhat_happens_nextone_minute_historyprompt_nameversionchannelreturnc                    | dk(  rE|dk(  r@|t         v r8d| }	 t        j                  |      }t        |d      rd| S |j                  S d| d|  }t        j                  |      }|j                  S # t
        $ r Y 4w xY w)a  
    Load a prompt template by name and version.

    Args:
        prompt_name: One of:
            - v1/v2/v3: "layer4a_concept", "layer4b_script", "layer4c_visual",
                        "layer4b_production_spec", "layer4c_asset_specs"
            - v4: "layer4_director", "layer4_evaluator"
        version: Prompt version (default "v1")
        channel: For v4 director, optionally specify channel for channel-specific prompt

    Returns:
        The prompt template string with {placeholder} variables
    layer4_directorv4"prompts.prompt_v4.layer4_director_
get_promptz__CHANNEL_SPECIFIC__:prompts.prompt_.)CHANNEL_SPECIFIC_DIRECTORS	importlibimport_modulehasattrPROMPTImportErrorr   r   r   module_namemodules        :/home/sietch6/trending-topics-pipeline/prompts/__init__.pyr   r   *   s      ''GtOKe@e:7)D		,,[9Fv|,.wi88== 
 $G9Ak];K$$[1F==  		s   %A4 A4 4	B ?B 
channel_idc                     |j                  dd       | t        vrt        d|  dt               d|  }t        j                  |      }t        |d      r |j                  d	i |S t        d| d      )
ag  
    Get a fully formatted channel-specific director prompt.

    This is the primary interface for v4 channel-specific prompts.
    It loads the channel's prompt module and calls get_prompt() with
    all the template variables.

    Args:
        channel_id: One of the CHANNEL_SPECIFIC_DIRECTORS
        **kwargs: Template variables (premise, research_report_content, etc.)
                  Note: channel_id in kwargs will be ignored (use positional arg)

    Returns:
        Fully formatted prompt string ready to send to Claude

    Raises:
        ImportError: If channel doesn't have a specific prompt
    r    Nz No channel-specific prompt for 'z'. Valid channels: r   r   zModule z missing get_prompt() function )popr   
ValueErrorr   r   r   r   AttributeError)r    kwargsr   r   s       r   get_channel_director_promptr'   L   s    ( JJ|T"33;J< H++E*FH I 	I 7zlCK$$[1Fv|$ v  *6**w{m3QRSS    c                     | dk(  r9|dk(  r4|t         v r,d| }	 t        j                  |      }t        |d|| |d      S d| d|  }t        j                  |      }t        |d|| d      S # t        $ r Y 8w xY w)	a7  
    Get metadata about a prompt (for tracking in output).

    Args:
        prompt_name: Prompt name (see get_prompt for options)
        version: Prompt version (default "v1")
        channel: For v4 director, optionally specify channel

    Returns:
        Dict with version, layer, model, description
    r   r   r   METADATA)r   namer   r   r   )r   r+   )r   r   r   getattrr   r   s        r   get_prompt_metadatar-   o   s     ''GtOKe@e:7)D	,,[9F6:7Kdk/lmm $G9Ak];K$$[1F6:7K'PQQ  		s   %A, ,	A87A8c                     d|  d}	 t        j                  |      }t        |dd      S # t        $ r+ d|  d}t        j                  |      }t        |dd      cY S w xY w)a[  
    Get the revision section template for v4+ Director prompts.

    This template is inserted into the Director prompt when revision
    instructions are provided from the Evaluator.

    Args:
        version: Prompt version (default "v4")

    Returns:
        The revision section template string with {revision_instructions} placeholder
    r   z.layer4_director_baseREVISION_SECTION_TEMPLATE z.layer4_director)r   r   r,   r   )r   r   r   s      r   get_revision_templater1      sy     $G9,ABK@((5v:B?? @'y0@A((5v:B??	@s   !* 1AA)v1N)r   )__doc__r   typingr   r   strr   r'   dictr-   r1   r"   r(   r   <module>r7      s   2   C # x} X[ D TC  Tc  TFRS R3 RQT Rae R4@3 @# @r(   