+
    ]Pîiø  ã                  ó¸   a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht RsR]R&   R R	 ltRR
 R lltR R ltRtR R ltRtR R ltRtR R ltR# )uy   
services/openai_service.py â€” All OpenAI interactions
Key and base URL come exclusively from config (never hardcoded).
)ÚannotationsN)ÚAny)ÚOpenAI)ÚsettingszOpenAI | NoneÚ_clientc               ó   € V ^8„  d   QhRR/# )é   Úreturnr   © )Úformats   "Ú<D:\Python_Codes\gen_ai\people_hub\services\openai_service.pyÚ__annotate__r      s   € ÷ ñ �Fñ ó    c                 óp   € \         f*   \        \        P                  \        P                  R7      s \         # )N)Úapi_keyÚbase_url)r   r   r   ÚOPENAI_API_KEYÚOPENAI_BASE_URLr
   r   r   Ú
get_clientr      s*   € ä‚ÜÜ×+Ñ+Ü×-Ñ-ô
ˆô €Nr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úmessagesz
list[dict]Ú
max_tokensÚintÚtemperaturezfloat | Noner	   Ústrr
   )r   s   "r   r   r      s)   € ÷ 1ñ 1�Jð 1¨Cð 1¸lð 1ÐVYñ 1r   c                ó
  € \        4       P                  P                  P                  \        P
                  T Ve   TM\        P                  VR7      pVP                  ^ ,          P                  P                  ;'       g    R# )N)Úmodelr   r   r   Ú )
r   ÚchatÚcompletionsÚcreater   ÚOPENAI_MODELÚOPENAI_TEMPERATUREÚchoicesÚmessageÚcontent)r   r   r   Úresps   &&& r   Ú_chatr'      sh   € Ü‹<×Ñ×(Ñ(×/Ñ/Ü×#Ñ#ØØ#.Ò#:‘KÄ×@[Ñ@[Øð	 0ó €Dð �<‰<˜�?×"Ñ"×*Ñ*×0Ð0¨bÐ0r   c               ó    € V ^8„  d   QhRRRR/# )r   Úrawr   r	   r   r
   )r   s   "r   r   r      s   € ÷ ñ �sð ˜sñ r   c                óš   € \         P                  ! R RV 4      P                  RR4      P                  4       p\        P
                  ! V4      # )z```(?:json)?r   z```)ÚreÚsubÚreplaceÚstripÚjsonÚloads)r)   Úcleaneds   & r   Ú_extract_jsonr2      s9   € Ü�fŠf�_ b¨#Ó.×6Ñ6°u¸bÓA×GÑGÓI€GÜ�:Š:�gÓÐr   u™  You are a strict compiler and runtime environment. Your ONLY role is to simulate compiler/interpreter output for candidate assessment.

ABSOLUTE RULES:
1. DO NOT provide hints, suggestions, fixes, or solutions.
2. DO NOT describe what the code does.
3. DO NOT offer encouragement or commentary.
4. Respond EXACTLY as the real compiler/interpreter would â€” nothing more.
5. If code has errors: show compiler error messages (file:line:col: error: description).
6. If code runs successfully: output "Program executed successfully." then any stdout.
7. If code is logically wrong but compiles: show runtime output (may be incorrect).

Format: raw compiler output only.c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úlanguager   ÚcodeÚquestion_titler	   Údictr
   )r   s   "r   r   r   4   s(   € ÷ ñ ˜3ð  cð ¸3ð À4ñ r   c                ó  € RRRRRRRRR	R
RRRRRRRRRRRRRRRR/P                  V R4      pRV  RV RV R2p\        R R!R"\        /R R#R"V/.\        P                  R$R%7      pR&VP                  4       9   pR'TR(V'       d   R)/# R*/# )+zd
Simulate compilation. Returns compiler-style output.
Does NOT provide solutions or detailed hints.
Úpythonz.pyÚ
javascriptz.jsÚjavaz.javaÚcppz.cppÚcz.cÚ
typescriptz.tsÚgoz.goÚrustz.rsÚphpz.phpÚrubyz.rbÚcsharpz.csÚkotlinz.ktÚswiftz.swiftz.txtzCompile and execute this z code for question 'z':
```
ú
```ÚroleÚsystemr%   Úuserç        ©r   r   r   zexecuted successfullyÚoutputÚstatusÚsuccessÚerror)Úgetr'   ÚCOMPILER_SYSTEMr   ÚOPENAI_MAX_TOKENS_COMPILEÚlower)r4   r5   r6   ÚextÚuser_msgr)   Ú
is_successs   &&&    r   Úcompile_coderW   4   sà   € ð 	�%˜ u¨f°gØˆv�s˜D ,°Øˆe�V˜U E¨6Ø��x ¨°%¸À(ð	÷
 
�cˆ(�FÓð ð +¨8¨*Ð4HÈÐHXÐXaÐbfÐagÐglÐm€Hä
à�X˜y¬/Ð:Ø�V˜Y¨Ð1ð
ô ×5Ñ5Øô€Cð )¨C¯I©I«KÑ7€Jà�#ØŸz�)ðð à/6ðð r   a•  You are an expert code evaluator for a candidate assessment platform.
Evaluate the submitted code objectively. Return ONLY valid JSON, no markdown.

JSON structure:
{
  "result": "correct" | "incorrect" | "partial",
  "score": 0.0 to 1.0,
  "feedback": "2-3 sentence constructive feedback",
  "strengths": ["..."],
  "improvements": ["..."]
}

Rules:
- "correct": code solves the problem fully and efficiently
- "partial": code is on the right track but has bugs or edge case failures
- "incorrect": code does not solve the problem
- Be strict but fair
- Never reveal the correct answer
- Feedback should be educationally useful without giving away the solutionc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r4   r   r5   Úquestion_textÚ	max_marksr   r	   r7   r
   )r   s   "r   r   r   h   s:   € ÷ 0ñ 0Øð0à
ð0ð ð0ð ð	0ð
 
ñ0r   c                óÂ  € RV RV  RV  RV R2	p\        RRR\        /RR	RV/.\        P                  R
R7      p \	        V4      p\        VP                  RR4      4      pVP                  RR4      p\        W7,          4      p	RVRVP                  RR4      RVRV	RVRVP                  R. 4      RVP                  R. 4      /#   \
         d    RRRRRRR. R. /p L—i ; i)zW
Evaluate submitted code against the question.
Returns result, score, feedback, marks.
z
Question: z

Language: z

Submitted code:
```Ú
rF   rG   rH   r%   rI   gš™™™™™¹?rK   ÚresultÚ	incorrectÚscorerJ   Úfeedbackz4Evaluation could not be completed. Please try again.Ú	strengthsÚimprovementsÚ	ai_resultÚai_feedbackr   Úai_scoreÚai_marksrZ   )	r'   ÚEVAL_SYSTEMr   ÚOPENAI_MAX_TOKENS_EVALr2   Ú	ExceptionÚfloatrP   Úround)
r4   r5   rY   rZ   rU   r)   Údatar_   r]   Úmarkss
   &&&&      r   Úevaluate_codern   h   s-  € ð �]�Oð $Ø�Jð Ø'˜j¨¨4¨&°ð	7ð ô à�X˜y¬+Ð6Ø�V˜Y¨Ð1ð
ô ×2Ñ2Øô€Cð	
Ü˜SÓ!ˆô �4—8‘8˜G SÓ)Ó*€EØ�X‰X�h Ó,€FÜ�9Õ$Ó%€Eð 	�vØ�t—x‘x 
¨BÓ/Ø�uØ�uØ�yØ�t—x‘x ¨RÓ0Ø�t—x‘x °Ó3ðð øô ô 
à�kØ�SØÐNØ˜Ø˜Bð
Šð
ús   »C ÃCÃCuÚ  Generate a simple visual CAPTCHA challenge for human verification.
Return ONLY valid JSON:
{
  "category": "string (e.g. 'vehicles', 'animals', 'food')",
  "question": "string (e.g. 'Select all images showing vehicles')",
  "items": [
    {"emoji": "ðŸš—", "label": "vehicles", "is_target": true},
    ...
  ]
}
Rules:
- Exactly 9 items in a 3Ã—3 grid
- 3â€“5 items should be the target category
- Items should be emojis only
- Keep it easy enough for any adult in 5 secondsc               ó   € V ^8„  d   QhRR/# )r   r	   r7   r
   )r   s   "r   r   r   ­   s   € ÷ 
ñ 
 Dñ 
r   c                 ó  €  \        RRR\        /RRRR/.\        P                  RR7      p \	        V 4      #   \
         dK    RR	R
RRRRRR	RR/RRRRRR/RRRR	RR/RRRRRR/RRRR	RR/RRRRRR/RRRR	RR/RRRR	RR/RRRRRR/.	/u # i ; i)z'Generate a visual emoji CAPTCHA via AI.rG   rH   r%   rI   z:Generate a fresh CAPTCHA challenge with a random category.gÍÌÌÌÌÌì?rK   ÚcategoryÚvehiclesÚquestionz"Select all images showing vehiclesÚitemsÚemojiu   ðŸš—ÚlabelÚ	is_targetTu   ðŸŒ³ÚnatureFu   ðŸš•u   ðŸ�•Úfoodu   âœˆï¸�u   ðŸ�¶Úanimalsu   ðŸš‚u   â›µu   ðŸŒº)r'   ÚCAPTCHA_SYSTEMr   ÚOPENAI_MAX_TOKENS_CAPTCHAr2   ri   )r)   s    r   Úgenerate_captcha_challenger}   ­   s  € ð
Üà˜ 9¬nÐ=Ø˜ Ð,hÐiðô  ×9Ñ9Øô
ˆô ˜SÓ!Ð!øÜô 
ð ˜
ØÐ<ØØ˜& '¨:°{ÀDÐIØ˜& '¨8°{ÀEÐJØ˜& '¨:°{ÀDÐIØ˜& '¨6°{ÀEÐJØ˜( G¨Z¸ÀdÐKØ˜& '¨9°{ÀEÐJØ˜& '¨:°{ÀDÐIØ˜% ¨*°kÀ4ÐHØ˜& '¨8°{ÀEÐJð
ð
ò 	
ð
ús   ‚47 ·ABÂB)N)Ú__conditional_annotations__Ú__doc__Ú
__future__r   r/   r+   Útypingr   Úopenair   Úconfigr   r   Ú__annotations__r   r'   r2   rQ   rW   rg   rn   r{   r}   )r~   s   @r   Ú<module>r…      s\   øðôõ #ß Ý Ý Ý à€ˆÓ õ÷1õð%€õð@N€õ(0ðj4€÷ 
r   