o
    GY)j                     @  sl   d Z ddlmZ ddlmZmZmZmZ eh dZ	dZ
dZdZdZdddZdddddZd ddZdS )!zVPer-BID call summary prompt configuration (opt-in; default preserves legacy behavior).    )annotations)AnyDictOptionalTuple>   customdefaultdiscovery_recapz"<5-6 sentence summary of the call>i@  ug  Write overall_summary in 4-6 sentences total:
1) One sentence: call purpose, overall tone, and outcome.
2) Remaining sentences: for each APPLICABLE quality parameter above, briefly state what the agent asked or did and what the customer answered (use transcript facts only — team size, CRM/tools, budget, timeline, etc. when relevant to that parameter).
Use phrasing like "Agent inquired about …; customer said …" or "not covered on this call" when the topic was not discussed.
Do not list parameter names, scores, or bullet points. Do not invent facts not supported by the transcript or parameter evaluation.u  Write overall_summary in 4-6 sentences total:
1) One sentence: call purpose, overall tone, and outcome.
2) Remaining sentences: key topics from the transcript (e.g. team size, CRM/tools, budget, timeline, needs) — what the agent asked and what the customer answered, or note if not discussed.
Use phrasing like "Agent inquired about …; customer said …". Use transcript facts only. No bullet lists.modeOptional[str]returnstrc                 C  s    | pd   }|tv r|S dS )Nr   )striplowerSUMMARY_MODES)r
   value r   9/home/aiteam/pcaa-dev/dashboard-backend/summary_config.pynormalize_summary_mode   s   r   T)has_quality_parameterspipeline_configOptional[Dict[str, Any]]r   boolTuple[str, str]c                C  s   | pi }t |d}|dkrdtfS |dkr$|rtnt}|r!dnd}n|dp*d }|s3dtfS |dt }d	}d
| }||fS )ao  
    Return (optional_summary_config_block, overall_summary_json_hint).

    When mode is 'default', returns ("", DEFAULT_OVERALL_SUMMARY_HINT) so the
    analysis prompt is byte-for-byte equivalent to the legacy template.

    has_quality_parameters=False uses transcript-based discovery wording (short
    calls and fallback analysis without a parameter list).
    summary_moder    r	   zw<4-6 sentences per SUMMARY CONFIG: general call context plus what was asked/answered per applicable quality parameters>zb<4-6 sentences per SUMMARY CONFIG: general context plus key ask/answer topics from the transcript>summary_instructionsNz1<follow SUMMARY CONFIG above for overall_summary>uY   SUMMARY CONFIG (overall_summary field only — scoring and other JSON fields unchanged):
)r   getDEFAULT_OVERALL_SUMMARY_HINTDISCOVERY_RECAP_INSTRUCTIONS"DISCOVERY_RECAP_BASIC_INSTRUCTIONSr   MAX_SUMMARY_INSTRUCTIONS_LEN)r   r   cfgr
   instructionshintr   blockr   r   r   resolve_summary_prompt_parts   s.   r&   
db_handlerr   bidc                 C  s*   z
|    | |W S  ty   Y d S w )N)%ensure_business_pipeline_config_tableget_pipeline_config	Exception)r'   r(   r   r   r   load_summary_pipeline_configI   s   r,   N)r
   r   r   r   )r   r   r   r   r   r   )r'   r   r(   r   r   r   )__doc__
__future__r   typingr   r   r   r   	frozensetr   r   r!   r   r    r   r&   r,   r   r   r   r   <module>   s    
-