Ë
    I»jg  ã                   óx   — d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZmZ ddlmZ ddlmZmZ  G d„ d	«      Zy
)z(Interview preview & regenerate question.é    )Úuuid4)Ú	JobStatus)ÚInterviewPreviewRequestÚInterviewPreviewResponseÚRegenerateQuestionRequestÚRegenerateQuestionResponse)ÚGeneratedQuestionÚQuestionType)Úgenerate_json)Ú_local_questionsÚ_parse_questionsc                   ó,   — e Zd Zdedefd„Zdedefd„Zy)ÚInterviewPreviewServiceÚpayloadÚreturnc              ƒ   óò  ‡‡
K  — d}d‰j                   › d‰j                  › d‰j                  j                  › d‰j                  › d‰j
                  D �cg c]  }|j                  ‘Œ c}› d‰j                  › d‰j                  › �}‰j
                  r‰j
                  d	   nt        j                  Š
d
t        fˆˆ
fd„}t        |||¬«      ƒ d {  –—† \  }}}t        |j                  dg «      ‰
‰j                  «      }	t        ‰j                   t#        t%        «       «      ‰j                   ‰j                  t&        j(                  |d|› �|	t+        |j                  d«      xs g «      d¬«
      S c c}w 7 Œ¥­w)NzuBuild a full interview preview pack. Return JSON: {"questions":[...],"follow_up_logic":[{"question_id","if","then"}]}úRole: ú
JD:
ú

Persona: z
Count: z
Types: z
Mandatory: z	
Custom: r   r   c                  ó0  •— t        ‰j                  ‰‰j                  ‰j                  ¬«      } t	        ‰j
                  «      D ];  \  }}| j                  d|dz   › �d‰j                  j                  |g d dddidœ«       Œ= | r| d	   d
   dddœgng }| |dœS )N©ÚcountÚqtypeÚ
difficultyÚtopiczcustom-é   Úshort_answerzCustom company questionÚ	mandatoryT)ÚidÚquestion_typer   ÚstemÚoptionsÚanswerÚexplanationÚmetadatar   r   Úanswer_shallowÚask_follow_up_for_evidence)Úquestion_idÚifÚthen)Ú	questionsÚfollow_up_logic)r   r   r   Ú
role_titleÚ	enumerateÚcustom_questionsÚappendÚvalue)ÚqsÚiÚcustomÚlogicr   Úprimarys       €€ú8/var/www/html/TJ-AI/tj/app/services/interview_preview.pyÚlocalz/InterviewPreviewService.generate.<locals>.local   sÃ   ø€ Ü!Ø—m‘mØØ"×-Ñ-Ø×(Ñ(ô	ˆBô ' w×'?Ñ'?Ö@‘	��6Ø—	‘	à '¨¨A© wÐ/Ø)7Ø&-×&8Ñ&8×&>Ñ&>Ø &Ø#%Ø"&Ø'@Ø%0°$Ð$7ñ	õð Añ& ð	 $& a¡5¨¡;Ø*Ø8ññð ð ð "$¸Ñ>Ð>ó    ©ÚsystemÚuserÚlocal_factoryr+   zInterview preview via r,   F)
Úcorrelation_idÚ
preview_idr-   ÚpersonaÚstatusÚstubÚmessager+   r,   Úlocked)r-   Újob_descriptionr@   r1   r   Úquestion_typesÚmandatory_topicsr/   r
   ÚSHORT_ANSWERÚdictr   r   Úgetr   r   r>   Ústrr   r   Ú	SUCCEEDEDÚlist)Úselfr   r;   Útr<   r8   ÚdatarB   Úproviderr+   r6   s    `        @r7   Úgeneratez InterviewPreviewService.generate   s‚  ùè ø€ ð\ð 	ð
 �W×'Ñ'Ð(¨°×0GÑ0GÐ/Hð IØŸ™×-Ñ-Ð.¨i¸¿¹°ð GØ(/×(>Ò(>Ó?Ñ(> 1�q—w“wÐ(>Ñ?Ð@ð AØ!×2Ñ2Ð3°:¸g×>VÑ>VÐ=WðYð 	ð 07×/EÒ/E�'×(Ñ(¨Ò+Ì<×KdÑKdˆð	?”tö 	?ô: &3Ø °Eô&
÷  
Ñˆˆd�Hô %Ø�H‰H�[ "Ó% w°×0BÑ0Bó
ˆ	ô (Ø"×1Ñ1Üœ5›7“|Ø×)Ñ)Ø—O‘OÜ×&Ñ&ØØ,¨X¨JÐ7ØÜ  §¡Ð*;Ó!<Ò!BÀÓCØô
ð 	
ùòQ @ðD 
ús    „AE7ÁE0Á'A(E7ÃE5ÃB&E7c              ƒ   óþ  ‡K  — d}d‰j                   › d‰j                  › d‰j                  j                  › d‰j                  › d‰j
                  j                  › d‰j                  › �}dt        fˆfd	„}t        |||¬
«      ƒ d {  –—† \  }}}|j                  d«      xs i }t        |g‰j
                  ‰j                  «      }	|	r|	d   nd }
t        ‰j                  t        j                  |d|› �|
¬«      S 7 Œs­w)NzBRegenerate one interview question. Return JSON: {"question":{...}}r   r   r   z
Previous: z
Type: z
Instructions: r   c                  ó¨   •— t        d‰j                  ‰j                  ‰j                  ¬«      } ‰j                  r‰j                  | d   d<   d| d   iS )Nr   r   r   r   Úquestion)r   r    r   r-   r(   )Úitemsr   s    €r7   r8   z:InterviewPreviewService.regenerate_question.<locals>.local[   sX   ø€ Ü$ØØ×+Ñ+Ø"×-Ñ-Ø×(Ñ(ô	ˆEð ×"Ò"Ø!(×!4Ñ!4��a‘˜‘Ø  a¡Ð)Ð)r9   r:   rU   r   zQuestion regenerated via )r>   rA   rB   rC   rU   )r-   rE   r@   r1   Úprevious_stemr    ÚinstructionsrI   r   rJ   r   r   r   r>   r   rL   )rN   r   r;   r<   r8   rP   rB   rQ   ÚrawÚparsedrU   s    `         r7   Úregenerate_questionz+InterviewPreviewService.regenerate_questionO   s   øè ø€ ð Sð 	ð �W×'Ñ'Ð(¨°×0GÑ0GÐ/Hð IØŸ™×-Ñ-Ð.¨l¸7×;PÑ;PÐ:Qð RØ×*Ñ*×0Ñ0Ð1Ð1AÀ'×BVÑBVÐAWðYð 	ð		*”tõ 		*ô &3Ø °Eô&
÷  
Ñˆˆd�Hð �h‰h�zÓ"Ò( bˆÜ! 3 %¨×)>Ñ)>À×@RÑ@RÓSˆÙ &�6˜!’9¨DˆÜ)Ø"×1Ñ1Ü×&Ñ&ØØ/°¨zÐ:Øô
ð 	
ð 
ús   ƒBC=ÂC;ÂA4C=N)	Ú__name__Ú
__module__Ú__qualname__r   r   rR   r   r   r[   © r9   r7   r   r      s-   „ ð;
Ð&=ð ;
ÐBZó ;
ðz#
Ø0ð#
à	#ô#
r9   r   N)Ú__doc__Úuuidr   Úapp.schemas.commonr   Úapp.schemas.interview_previewr   r   r   r   Úapp.schemas.questionsr	   r
   Úapp.services.ai_generater   Úapp.services.questionsr   r   r   r_   r9   r7   Ú<module>rg      s0   ðÙ .å å (÷ó ÷ BÝ 2ß E÷a
ò a
r9   