
    sj?}                     X   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSK	J
r
  SSKJrJr  SSKJrJrJr  SSKJrJrJrJrJrJr  SSKJr  SS	KJr  SSKrSS
KJr  SSKJ r   SSK!J"r"  Sr#\RH                  " \RJ                  SS9  \RL                  " \'5      r( " S S5      r)\)" SS9r* " S S\5      r+ " S S\5      r, " S S\5      r- " S S\5      r.S\/S\04S jr1S\/4S jr2 SJS \/S!\0S"\0S#\3S$\/S%\/S&\0S'\\\\/\4   /S4      S\\-\.4   4S( jjr4\'S):X  Ga  \5" S*5        \5" S+5        \5" S,5        \4" S-S.S/S0S1S2S3S49r6\5" S*5        \5" S55        \5" S65        \7" S7 \6Rp                  Rs                  5        5       5      r:\7" S8 \6Rp                  Rs                  5        5       5      r;\7" S9 \6Rp                  Ry                  5        5       5      r=\5" S:\>" \6Rp                  5       35        \5" S;\: 35        \5" S<\; 35        \5" S=\= S>\: 35        \5" S?\6R~                   35        \5" S@5        \6Rp                  Ry                  5        HM  u  r@rA\@R                  SA5      (       d  M  \C" \ASBS5      rD\D(       a  SCOSDrE\5" SE\E SF\@ SG\D(       a  \DOSH 35        MO     \5" S*5        \5" SI5        \5" S65        gg)Ka  
================================================================================
 Storigo Content Generator - Professional Edition v7.0
 - Synchronous image generation during slide creation
 - Direct image URL assignment (no null values)
 - One slide processed completely before moving to next
 - Professional error handling and logging
 - GUARANTEED: Every slide with is_image=1 gets an image URL or None
================================================================================
    N)ChatGroq)ChatPromptTemplate)StrOutputParserPydanticOutputParser)	BaseModelField	validator)ListOptionalDictUnionCallableAny)deque)Lock)	OllamaLLM
ChatOllama)fetch_image_for_slide8gsk_CEh3itIpUAkEkEKsUDqVWGdyb3FYoTjqmXNTBHOSxJFK3obGTzXZz:%(asctime)s - [%(levelname)s] - (StorigoGen) - %(message)s)levelformatc                   (    \ rS rSrSrSS jrS rSrg)SmartRateLimiter/   z%Intelligent rate limiter for Groq APIc                 h    Xl         [        5       U l        [        5       U l        SU l        SU l        g )Nr   )max_requestsr   request_timesr   locktotal_requeststotal_waits)selfmax_requests_per_minutes     R/var/www/eduai.edurigo.com/storigo/testing/generate_storigo_content_from_prompt.py__init__SmartRateLimiter.__init__1   s+    3"WF	    c                    U R                      [        R                  " 5       nU R                  (       aW  XR                  S   -
  S:  aB  U R                  R                  5         U R                  (       a  XR                  S   -
  S:  a  MB  [	        U R                  5      U R
                  :  a  SXR                  S   -
  -
  S-   n[        R                  SUS S35        U =R                  S-  sl        [        R                  " U5        U R                  (       a  [        R                  " 5       U R                  S   -
  S:  aV  U R                  R                  5         U R                  (       a+  [        R                  " 5       U R                  S   -
  S:  a  MV  U R                  R                  [        R                  " 5       5        U =R                  S-  sl        SSS5        g! , (       d  f       g= f)zWait if approaching rate limitsr   <      u#   ⏳ Rate limit protection: waiting z.1fsN)r   timer   popleftlenr   loggerwarningr!   sleepappendr    )r"   now
sleep_times      r$   wait_if_neededSmartRateLimiter.wait_if_needed8   sq   YY))+C $$/A/A!/D)Dr)I""**, $$/A/A!/D)Dr)I 4%%&$*;*;;3););A)>#>?!C
!DZPSDTTUVW  A% 

:& ((TYY[4;M;Ma;P-PSU-U&&..0 ((TYY[4;M;Ma;P-PSU-U %%diik21$' YYs   A<G&DG&AG&&
G4)r   r   r   r    r!   N)   )__name__
__module____qualname____firstlineno____doc__r%   r5   __static_attributes__ r'   r$   r   r   /   s    /%r'   r   r7   )r#   c                       \ rS rSr% \" S5      r\\S'   \" S5      r\	\   \S'   \" S5      r
\\   \S'   \" S5      r\\S'   \" SS	9r\	\   \S
'   \" S
SSS9S 5       r " S S5      rSrg)SlideContentT   flashtypeN
subheading.
paragraphsvisualization_suggestion)defaultimageT)prealwaysc                 x    Uc  g[        U[        5      (       a!  UR                  5       nU(       a  US:w  a  U$ S$ g)z1Ensure image is either None or a valid string URLNNone)
isinstancestrstrip)clsvstrippeds      r$   validate_image_path SlideContent.validate_image_path[   s;     9awwyH'H,>8HDHr'   c                       \ rS rSrSrSrSrg)SlideContent.Confige   Tr>   N)r8   r9   r:   r;   arbitrary_types_allowedvalidate_assignmentr=   r>   r'   r$   ConfigrV   e   s    "&"r'   rZ   r>   )r8   r9   r:   r;   r   rC   rN   __annotations__rD   r   rE   r
   rF   rH   r	   rS   rZ   r=   r>   r'   r$   r@   r@   T   s{    gD# %dJ+!#JJS	&$)#Jc. .E8C=.wD. /# #r'   r@   c                   ~    \ rS rSr% \" S5      r\\S'   \" SSS9r\\S'   \" SSS9r	\
\   \S	'   \" SS
S9r\\S'   Srg)
MCQContenti   QuestionrC   .zThe multiple-choice question)descriptionquestionzA list of 4 answer optionsoptionszKThe single letter 'a', 'b', 'c', or 'd' corresponding to the correct answercorrect_answerr>   N)r8   r9   r:   r;   r   rC   rN   r[   ra   rb   r
   rc   r=   r>   r'   r$   r]   r]   i   sK    j!D#!#+IJHcJs0LMGT#YM1~NCr'   r]   c                   H    \ rS rSr% \" S5      r\\\4   \	S'   Sr
\\	S'   Srg)StorigoContento   .slidesr   token_countr>   N)r8   r9   r:   r;   r   rg   r   rN   r@   r[   rh   intr=   r>   r'   r$   re   re   o   s$    &+CjFDl"#0Kr'   re   c                   R    \ rS rSr% \" S5      r\\\\	\
4   4   \S'   Sr\\S'   Srg)StorigoContentMCQMids   .rg   r   rh   r>   N)r8   r9   r:   r;   r   rg   r   rN   r   r@   r]   r[   rh   ri   r=   r>   r'   r$   rk   rk   s   s.    9>sFDeL*4556CKr'   rk   textreturnc                 F    [         R                  " SU 5      n[        U5      $ )z(Simple token counter based on word countz\w+)refindallr.   )rm   tokenss     r$   count_tokensrs   z   s    ZZ%Fv;r'   c                    [        U S5      (       a  U R                  nO[        U 5      nUR                  5       nSU;   aJ  [        R
                  " SSU[        R                  S9n[        R
                  " SSU[        R                  S9nUR                  S5      nUR                  S5      nS	nUS	:w  a  US	:w  a  [        X#5      nO[        X#5      nUR                  S
5      nUR                  S5      n[        XV5      S-   nUS	:w  a
  US:w  a  XU n[        R
                  " SSU5      n[        R
                  " SSU5      n[        R
                  " SSU5      n[        R
                  " SSU5      nUR                  5       nU$ )z4Fix common JSON formatting issues from LLM responsescontentz```z^```json?\s* )flagsz```${[}]r*   r   (\"|\]|\})\s*\n\s*(\"|\[|\{)\1,\n\23(\"|null|true|false|\d+|\]|\})\s*(\"[\w\-_]+\"\s*:)z(\"|\]|\})\s+(\"|\[|\{)z\1,\2,\s*([\]\}])\1)hasattrru   rN   rO   rp   sub	MULTILINEfindminmaxrfind)
ai_messagerm   	start_obj	start_arrstartend_objend_arrends           r$   quick_json_fixr      sN   z9%%!!:::<D }vvor4r||Dvvgr4r||< 		#I		#IEB9?I)I)jjoGjjoG
g
!
#C{sax#
 661:tDD 66H*VZ[D 66,h=D 66/5$/D ::<DKr'   prompt
num_slidesnum_mcqsis_imageis_questionquestion_positionGPUprogress_cbc                 p%   [         R                   " 5       n [        R                  S5        [        R                  S5        [        R                  S5        [        R                  S5        [        R                  SU 35        [        R                  SU 35        [        R                  SU 35        [        R                  SU SS	  S
35        [        R                  S5        [        R                  SU 35        [        U5      R	                  5       S:X  a+   SSKJn	  U	" SSSSSSSS	SS9	n
[        R                  S5        O'[        S[        SSS	SS9n
[        R                  S5        U(       a  U" SSS.5        [        R                  S5        [        R                  S5        [        R                  S5        S nU(       a  U" S!S"S#S$.5        [        R                  " U5      nS% S& S'.U-  U
-  [        -  n[        R                  5         [         R                   " 5       nUR!                  XS'.5      n[         R                   " 5       U-
  n ["        R$                  " U5      n['        S0 UD6n[        R                  S([)        UR*                  5       S)US* S+35        [=        [?        UR*                  RA                  5       S= S>95      nURA                  5        H  u  nn[)        URB                  5      S?:  a6  URB                  RE                  S@5        [)        URB                  5      S?:  a  M6  URF                  (       a  URF                  R	                  5       (       d   SAUl#        [        R1                  SBU SC35        U(       d  M  U" SDUURH                  URB                  URF                  U SE3SF.5        M     U(       Ga  [        R                  S5        [        R                  SG5        [        R                  S5        U(       a  U" S!SHSIS$.5        SnSnURK                  5        GH  nUU   n URF                  n[        R                  SJU S
35        [        R                  SKU SL35        [         R                   " 5       n[M        UU5      n[         R                   " 5       U-
  nU(       aG  UUU   l'        USM-  n[        R                  SNU SOUS* SP35        U(       a  U" SQUUU SR3SS.5        M  M  SUU   l'        USM-  n[        R1                  STUS* SP35        U(       a  U" SQUSU SU3SS.5        GM  GM     [        R                  S5        [        R                  SX5        [        R                  SYU SZ[)        U5       35        [        R                  S[U SZ[)        U5       35        [        R                  S5        O6[        R                  S\5        URK                  5        H  nSUU   l'        M     UUl        Sn UR*                  RQ                  5        HH  nURH                   S]S]RS                  URB                  5       S]URF                   3n!U [U        U!5      -  n MJ     U(       Ga  US^;  Ga  [        R                  S5        [        R                  S_U S`35        [        R                  S5        U(       a  U" S!SaSbU Sc3S$.5        [         RV                  " Sd5        / n"UR*                  RA                  5        H^  u  n#n$U$RH                  n%S]RS                  U$RB                  5      n&[)        U&5      Se:  a	  U&SSe S
-   n'OU&n'U"RE                  SfU% SgU' 35        M`     ShRS                  U"5      n(Sin) [        R                  " U)5      n*[        R                  5         [         R                   " 5       n+U*U
-  R!                  U(USj.5      n,[         R                   " 5       U+-
  n-U,RX                  R	                  5       n.[        R                  SkU.SSl  35        [2        RZ                  " SmU.[2        R\                  5      n/U/(       a  U/R_                  S5      n.[        U.5      n. ["        R$                  " U.5      n0[e        U0[<        5      (       aN  SsU0;   a  [e        U0Ss   [f        5      (       a  U0Ss   n2OE[i        St U0RQ                  5        5       S5      n3U3b  U3OU0/n2O[e        U0[f        5      (       a  U0n2OU0/n20 n4[k        U2SU 5       H  u  n5n6 SuU6;  a  SvU6Su'   [m        S0 U6D6U4SwU5SM-    3'   [        R                  SxU5SM-    SyU6Sz   SS{  S
35        U(       aN  U" SaSwU5SM-    3U6Ro                  SzS|5      U6Ro                  S}/ 5      U6Ro                  S~S|5      SU5SM-    S3S.5        M  M     [        R                  S([)        U45       SZU SU-S* S+35        U4RQ                  5        HH  n7U7Rp                   S]S]RS                  U7Rr                  5       S]U7Rt                   3n!U [U        U!5      -  n MJ     0 n8US:X  d  USM:X  Gai  [        R                  S5        [g        UR*                  RK                  5       5      n9[)        U95      n:[)        U45      n;U;U::  ay  [g        U4RK                  5       5      n<[k        U95       H.  u  n=n>UR*                  U>   U8U>'   U=U;:  d  M   U4U<U=      U8U<U=   '   M0     [w        U:U;5       H  n?U4U<U?      U8U<U?   '   M     GO[y        SMU:U;-  5      n@SnA[g        U4RK                  5       5      n<[k        U95       HA  u  n=n>UR*                  U>   U8U>'   WAU;:  d  M   U=SM-   W@-  S:X  d  M.  U4U<WA      U8U<UA   '   UASM-  nAMC     WAU;:  a  U4U<WA      U8U<UA   '   UASM-  nAUAU;:  a  M  Og[        R                  S5        UR*                  RK                  5        H  n#UR*                  U#   U8U#'   M     U4RA                  5        H  u  nBnCUCU8UB'   M     [         R                   " 5       U-
  nD[        R                  S5        [        R                  S5        [        R                  S5        [        R                  S5        [        R                  SUDS* S+35        [        R                  S[)        UR*                  5       35        [        R                  S[)        U45       35        [        R                  S[)        U85       35        [        R                  SU  35        U(       a.  [        R                  SW SZ[)        UR*                  5       35        [        R                  S5        [{        U8U S9$ [         R                   " 5       U-
  nD[        R                  S5        [        R                  S5        [        R                  S5        [        R                  S5        [        R                  SUDS* S+35        [        R                  S[)        UR*                  5       35        [        R                  SU  35        U(       a.  [        R                  SW SZ[)        UR*                  5       35        [        R                  S5        ['        UR*                  U S9$ ! [         a
    SSKJn	   GNf = f! ["        R,                  [.        4 Ga  n[        R1                  S,[        U5       35        [        R                  S-5         Un[        U5      n[2        R4                  " S.S/U5      n[2        R4                  " S0S/U5      n[2        R4                  " S1S2U5      n["        R$                  " U5      n['        S0 UD6n[        R                  S([)        UR*                  5       S335         SnAGN! [.         a  n[        R7                  S4[        U5       35        [        R7                  S5USS6  35         [9        S7S8S9S:9 nUR;                  U5        SSS5        O! , (       d  f       O= f[        R                  S;5        O!    O= f[/        S<[        U5       35      eSnAff = fSnAff = f! [.         aZ  n[        R7                  SV[        U5       35        SUU   l'        USM-  nU(       a  U" SQUSU SW3SS.5         SnAGM   SnAGM  SnAff = f! [.         a  n1[        R7                  SnU1 35        U.R	                  5       Ra                  So5      (       aZ  U.R	                  5       Rc                  Sp5      (       a6   ["        R$                  " SqU.R	                  5        Sr35      n0 Sn1A1GN!   U1e= fU1eSn1A1ff = f! [.         a*  n[        R1                  SU5SM-    SyU 35         SnAGM  SnAff = f! [.         a?  n[        R7                  S[        U5       35        ['        UR*                  U S9s SnA$ SnAff = f! [.         a  n[        R7                  S5        [        R7                  S5        [        R7                  S[        U5       35        [        R7                  S5        SSK>nE[        R7                  UER                  5       5        [/        S[        U5       35      eSnAff = f)a{  
Generate professional slide content with INLINE image generation

PROFESSIONAL APPROACH:
1. Generate slide content
2. For EACH slide, immediately fetch and assign image
3. Process one slide completely before moving to next
4. Return final result with all images assigned

Args:
    prompt: Main topic prompt
    num_slides: Number of slides to generate
    num_mcqs: Number of MCQs
    is_image: Whether to generate images
    is_question: Whether to generate MCQs
    question_position: Position of questions ("end" or "1")
    GPU: Legacy parameter

Returns:
    StorigoContent or StorigoContentMCQMid with images properly assigned
P================================================================================u0   🚀 STORIGO PROFESSIONAL CONTENT GENERATOR v7.0u   📋 Configuration:z   - Slides: z   - MCQs: z   - Images: z   - Prompt: Nr)   z...u$   🔧 Initializing API setup for GPU=1r   r   zhttp://127.0.0.1:11434zllama3.1:8bjsongffffff?i    i      )	base_urlmodelr   temperaturenum_predictnum_ctx
max_tokensrequest_timeoutmax_retriesu"   ✅ Ollama API (llama3.1:8b) readyzllama-3.1-8b-instant)
model_namegroq_api_keyr   r   r   r   u   ✅ Groq API readystatuszInitializing generator...)rC   messageQ
================================================================================u%   📝 STEP 1: Generating Slide Contenta	  
Based on the following prompt, generate professional content for exactly {num_slides} slides.

Each slide MUST include:
- A clear, descriptive subheading
- 2-3 informative paragraphs (very detailed, well-written, and engaging.)
- A "visualization_suggestion" (exactly 6 to 10 words). This MUST describe a real-world photograph of physical people or objects. DO NOT use abstract concepts, slide titles, or text.

CRITICAL for visualization_suggestion:
- Use ONLY concrete, visual, searchable terms with specific details
- Think: "What would I search on a stock photo website with exact scene details?"
- Include specific elements: people (e.g., "diverse team"), objects (e.g., "laptop computer"), actions (e.g., "discussing strategy"), settings (e.g., "modern office")
- Good examples: "diverse business team discussing strategy in modern conference room", "data analyst examining colorful charts on computer screen", "professional kitchen staff preparing fresh ingredients in commercial kitchen"
- Bad examples: "concept of leadership", "abstract representation", "team meeting" (too vague)
- EACH visualization suggestion MUST BE COMPLETELY UNIQUE across all slides - no overlapping concepts, objects, or scenes
- If slides are related, vary all elements significantly: different people, objects, actions, and settings

Prompt: {prompt}

Make content professional with:
- Thought-provoking insights
- Relevant examples or statistics
- Industry trends
- Clear, actionable takeaways

Return ONLY a valid JSON object with this exact structure (no explanations, no markdown, no schema definitions):
{{
  "slides": {{
    "slide_1": {{
      "subheading": "Introduction to Kitchen Safety",
      "paragraphs": [
        "Kitchen safety is paramount in any food service environment.",
        "Proper protocols protect staff and ensure food quality."
      ],
      "visualization_suggestion": "professional kitchen staff wearing safety gear in commercial kitchen",
      "image": null
    }},
    "slide_2": {{
      "subheading": "Food Handling Best Practices",
      "paragraphs": [
        "Proper food handling prevents contamination and foodborne illness.",
        "Key practices include temperature control and cross-contamination prevention."
      ],
      "visualization_suggestion": "chef demonstrating proper food handling techniques with fresh ingredients",
      "image": null
    }}
  }},
  "token_count": 0
}}

Generate exactly {num_slides} slides numbered slide_1 through slide_{num_slides}.
stage
slide_textzGenerating slide text...)rC   r   r   c                     U S   $ )Nr   r>   xs    r$   <lambda>4generate_slide_content_from_prompt.<locals>.<lambda>G  s    AhKr'   c                     U S   $ )Nr   r>   r   s    r$   r   r   H  s    ,r'   )r   r   u   ✅ Generated z slides in z.2fr+   u-   ⚠️ JSON parsing failed on first attempt: u%   🔧 Attempting deep clean of JSON...r}   r~   r   r   r   z slides after deep cleanu/   ❌ JSON parsing failed even after deep clean: z!Raw response (first 1000 chars): i  zfailed_layout.jsonwzutf-8)encodingu;   📂 Saved failed JSON to failed_layout.json for inspectionz$Failed to parse slide content JSON: c                 B    [        U S   R                  S5      S   5      $ )Nr   _r*   )ri   splitr   s    r$   r   r   ~  s    #aPQdjjY\o^_N`Jar'   )key   z&Additional information for this slide.zprofessional business conceptu   ⚠️ z$: Empty visualization, using defaultslidez	 prepared)rC   	slide_keyrD   rE   rF   r   u4   🎨 STEP 2: Generating Images (INLINE - One by One)imageszGenerating images...u   
📸 Processing z   Visualization: ''r*   u      ✅ Image assigned: z (zs)rH   z image ready)rC   r   rH   r   u      ⚠️ No image found (z image not foundu      ❌ Error: z image erroru   🎨 Image Generation Summary:z   - Success: /z   - Failed: u0   
📷 Image generation disabled (is_image=False) )0falseFalseu   ❓ STEP 4: Generating z MCQs (Batch Mode)mcqzGenerating z MCQs...g      ?i,  z**z**
z

a  
You are an expert educational content creator. Generate exactly {num_mcqs} high-quality MCQs.

**Requirements:**
1. Test comprehension of key concepts
2. Distribute across different topics
3. Each question has exactly 4 options
4. Only one clearly correct answer
5. Avoid trivial questions
6. CRITICAL: For `correct_answer`, you MUST ONLY output "a", "b", "c", or "d".
   (a = first option, b = second option, c = third option, d = fourth option).
   NEVER output 'T', 'F', '1', '2', '3', '4'. NEVER output the full text of the option. ONLY the single letter!

**Content:**
{context}

**Output Format:**
Return ONLY a valid JSON object with a single key "mcqs" containing an array. DO NOT return a raw array. It must be identical to this example:

{{
  "mcqs": [
      {{
          "type": "Question",
          "question": "What is the capital of France?",
          "options": ["Paris", "London", "Berlin", "Madrid"],
          "correct_answer": "a"
      }},
      {{
          "type": "Question",
          "question": "What is 2 + 2?",
          "options": ["3", "4", "5", "6"],
          "correct_answer": "b"
      }}
  ]
}}

Generate exactly {num_mcqs} questions now:
)contextr   u   🔍 Raw LLM Output: i   z(\{.*\}|\[.*\])z"Failed to decode MCQ JSON syntax: rx   r{   ry   r|   mcqsc              3   T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7fN)rM   list).0rQ   s     r$   	<genexpr>5generate_slide_content_from_prompt.<locals>.<genexpr>I  s      *f6NR\]^`dRe116N   (	(rC   r_   mcq_u   ✅ MCQ : ra   2   rv   rb   rc   zMCQ z ready)rC   mcq_keyra   rb   rc   r   u   ⚠️ Failed to parse MCQ z	 MCQs in u(   📍 Distributing MCQs throughout slidesu   📍 Placing all MCQs at endu   🎉 GENERATION COMPLETEu   📊 Final Statistics:z   - Total time: z   - Total items: z   - Token count: z   - Images assigned: )rg   rh   u   ❌ MCQ generation failed: u   ❌ FATAL ERRORzError: zContent generation failed: r>   )@r,   r/   inforN   rO   langchain_community.chat_modelsr   ImportErrorlangchain_ollamar   GROQ_API_KEYr   from_templater   rate_limiterr5   invoker   loadsre   r.   rg   JSONDecodeError	Exceptionr0   rp   r   erroropenwritedictsorteditemsrE   r2   rF   rD   keysr   rH   valuesjoinrs   r1   ru   searchDOTALLgroup
startswithendswithrM   r   next	enumerater]   getra   rb   rc   ranger   rk   	traceback
format_exc)Fr   r   r   r   r   r   r   r   generation_startr   llmslide_content_templateslide_promptslide_chainslide_gen_start
raw_resultslide_gen_timeresult_dataresultedeep_cleaneddeep_efordered_slidesr   slide_contentsuccess_countfailed_count
viz_promptimage_start	image_url
image_timerh   rm   all_contextr   r   title
paras_textsummaryfull_contextmcq_template
mcq_prompt	mcq_start
mcq_resultmcq_timeru   
json_matchmcq_data_parsed
syntax_errmcq_list
found_listr   idxmcq_datar   final_content
slide_keysnum_snum_mmcq_keysis_keyjintervalmcq_counterr   mcq_contentgeneration_timer   sF                                                                         r$   "generate_slide_content_from_promptr#     s   > yy{r@HFGH)+mJ<01k(,-mH:./mF3BK=45H 	:3%@As8>>s"8F 1#  "
C KK<=1) "C KK,-6QRS
 	O$;<H3"j <Lfgh)778NO 07 	
   	 	##%))+ ''6(TU
6$	Q**Z0K#2k2FKK.V]]);(<KWZG[[\]^F fV]]%8%8%:@abc )7(<(<(>$I}m../!3((//0XY m../!3 !99AgAgAmAmAoAo9X63WXY{#!*"/":":"/":":0=0V0V"+I6  )?. KK(KKNOKK!WxLbcdML+002	 .y 9E!.!G!GJKK"4YKs CDKK"5j\ CD #'))+K 5i LI!%{!:J :Cy17%*&=i[:VYJZZ\$]^&'y[dt}s~  K  rL  )M  N ' ;?y17$))CJsCSSU'VW&'y[_oxny  zJ  mK  )L  M '3 3F KK(KK8:KK.q^9L8MNOKK-~Qs>7J6KLMKK! KKKL+002	26y)/ 3 '
 #]]113M#../q-:R:R1S0TTUVcV|V|U}~D<--K 4 ;.EEKK(KK1(;MNOKK!Wu;W_V``hIijkJJsO K$mm113
U(( XXe&6&67
z?S((#.6G(G""Rwd7)#<= 4 ";;{3L%LNQU/==lK
++- IIK	(3.66+ (8 
  99;2 %,,2243GDSM?CD  YY'97BIIN
(..q1G )1)&*jj&9O ot440ZPV@WY]5^5^#26#:%)*fo6L6L6N*fhl%m
1;1G:oM^66.H /0H%.x	/B%CMCU!1/9HV,1;1Gh1GtC!G9-.hsQwir(::NsPR:S9TTW$XY&'(--1#'+;,4LLR,H+3<<	2+F2:,,?OQS2T-1#'&+A)  ' &D& nSYKq
)HUX>YZ[\  ;;=C!ll^1SXXckk-B,C1SEWEWDXYD<#55K )
 !#$+/@A/EKK JK!%fmm&8&8&:!;J
OEIE ~ $(		#4(1*(=HAu39==3GM%0 5y=A(1+=Nhqk : )> "'ue!4A9=hqk9JM(1+6 "5 $'q%5.#9&'#'		#4(1*(=HAu39==3GM%0*U2A7IQ7NGKHU`LaGbh{.C D +q 0	 )> *E1CGQ\H]C^M(;*?@'1,K *E1
 KK >?%}}113-3]]3-?c*  4 15

,1<g. 1= #'))+0@"@O,67H%46//DAFGmC,>+?@Ak#d)560]1C0DEF0>?KK"8qV]]I[H\ ]^H%+=kZZ #iik,<<OKK(KK23KK!KK02KK+OC+@BCKK-FMM(:';<=KK,[M:;4]O1SEWDXYZKK!!KPPs  8778j $$i0 	QNNJ3q6(ST KK?@Q  *  .l;  "vv&EzS_`!vv&\^hjvw!vvoulK"jj6'6+6nS-?,@@XYZZ 
QNsSY{m\]@ETAR@STU2C'Ja
+ KJJKK ]^"Fs1vh OPP
Q+	QF ! ELL>#a&!:;6:N9-3 A%L"#W9W[ktju  vB  iC  %D  E  E #	Er ! 	)LL#Ej\!RS}}11#667==?;S;STW;X;X-.2jj1W]]_<MQ9O.PO-",,((	)R % U)DS1WIRPQs'STTUV  U:3q6(CD%V]]TTU,  @X(ws1vh'(XY))+,5c!fX>??@s  DAH z!  D/AH Az8 !BAH 2AAH B+AH 7CAA48AH <A AA4<IAH C,AF< /AC BAF< BAF1D.AF< #BAF< -
AF< ;6AF< 3GAF< :D&AH !z51AH 4z55AH 8AA16AA,
B"~2,AH 2
AA)<<AA$9AA@A@@	AA@
A@-@)AAAAA$AAA
AAA$A$AA)A)AA,A,AA1A1AH A4
ACA>AACCAH CACCAH C
AFC%A AE=E(AE4E.AF< E4AE8E8AE=E=AFFAF< F
AF9FAF4F-AF< F4AF9F9AF< F<
AHG4AH G:AHG;AH H AHHAH H
AJ5HBAJ0J0AJ5__main__r   u+   🧪 TESTING STORIGO CONTENT GENERATOR v7.0zQ================================================================================
z/Kitchen safety and food handling best practicesr   r   Tr   r   r*   )r   r   r   r   r   r   r   u   📋 TEST RESULTSr   c              #   T   #    U  H  oR                  S 5      (       d  M  Sv   M      g7f)slide_r*   Nr   r   ks     r$   r   r     s     U!:All8>Taa!:r   c              #   T   #    U  H  oR                  S 5      (       d  M  Sv   M      g7f)r   r*   Nr'  r(  s     r$   r   r     s     Q8!LL<PAA8r   c              #      #    U  HG  u  pUR                  S 5      (       d  M  [        US5      (       d  M0  UR                  (       d  MC  Sv   MI     g7f)r&  rH   r*   N)r   r   rH   )r   r)  rQ   s      r$   r   r     sE      Y(B\\(3 8?78K PQPWPW !(Bs   AAA	AzTotal items: z  - Slides: z
  - MCQs: z  - Images assigned: r   zToken count: u   
📸 Image URLs:r&  rH   u   ✅u   ⚠️z  r   r   rL   u    ✅ Test completed successfully!r   )Fr<   osr,   randomrp   r   requestslangchain_groqr   langchain_core.promptsr   langchain_core.output_parsersr   r   pydanticr   r   r	   typingr
   r   r   r   r   r   collectionsr   	threadingr   loggingr   r   r   storigo_image_generatorr   r   basicConfigINFO	getLoggerr8   r/   r   r   r@   r]   re   rk   rN   ri   rs   r   boolr#  printtest_resultsumrg   r   slide_count	mcq_countr   images_with_urlr.   rh   r   ru   r   getattrimgr   r>   r'   r$   <module>rD     s5  	 
   	   # 5 O 0 0 = =    & ' :
 J   
,,G 
		8	$
% %@  ;
#9 #*@ @Y 9 s s 
2# 2~ ?CS@S@S@ S@ 	S@
 S@ S@ 
S@ (DcN#3T#9:;S@ >//0S@r z	/	
78	/4@K 
/	
	(OU!3!3!8!8!:UUKQ{11668QQI Y(:(:(@(@(B Y YO 
M#k0012
34	L
&'	Jyk
"#	!/!2!K=
AB	M+112
34	
#**002W>>(##'7D1C!UxFBvhauBcsv&>?@	 3 
/	
,-	(OO r'   