+
    DcìjÝ  ã                   óV   € R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^RIH	t	 Rt
R tRR ltR# )z9Grok Imagine image-editing engine using xAI's Images API.N)Úsettings)Úgarment_on_whitea„  Use <IMAGE_0> as the customer photo and <IMAGE_1> as the garment reference. Edit <IMAGE_0> so the customer is wearing the garment from <IMAGE_1>. Keep the customer's face, identity, skin tone, hair, body shape, pose and background unchanged; change only the clothing. Preserve the garment's color, pattern and details, with realistic folds and fit. Do not add text, logos or extra people.c                 ó&  €  V P                  4       p\        V\        4      '       d¼   VP	                  R 4      p\        V\        4      '       d,   VP	                  R4      ;'       g    VP	                  R4      pM\        V\
        4      '       d   TpMRpT;'       g+    VP	                  R4      ;'       g    VP	                  R4      pV'       d   \        V4      R,          # V P                  ;'       g    RR,          #   \         d    / p Lýi ; i)ÚerrorÚmessageÚdetailN:Ni,  NzUnknown API error)ÚjsonÚ
ValueErrorÚ
isinstanceÚdictÚgetÚstrÚreason)ÚresponseÚbodyr   r   s   &   Útryon\services\engine_grok.pyÚ_error_messager      sÙ   € ðØ�}‰}‹ˆô �$œ×ÒØ—‘˜Ó!ˆÜ�eœT×"Ò"Ø—i‘i 	Ó*×AÐA¨e¯i©i¸Ó.A‰GÜ˜œs×#Ò#Ø‰GàˆGØ×FÐF˜TŸX™X iÓ0×FÐF°D·H±H¸XÓ4FˆßÜ�w“< Õ%Ð%Ø�O‰O×2Ð2Ð2°DÕ9Ð9øô ô ØŠðús   ‚D  Ä DÄDc                ó^  € \         P                  pV'       g   \        R4      h\        P                  ! RV \        P
                  ^_.4      w  rEV'       g   \        R4      h\        V4      w  rgpRR\        P                  ! VP                  4       4      P                  R4      ,           RR/RR	V R
2\        P                  ! V4      P                  R4      ,           RR/.p	\        p
V'       d   V
RVR,          ,           R,           ,          p
\        P                  ! RRRV 2/R\         P                  RV
RV	RRR^/\         P                  R7      pVP                   ^È8w  d%   \        RVP                    R\#        V4       24      h VP%                  4       P'                  R4      ;'       g    . pV'       d   V^ ,          P'                  R4      MRpV'       g   \        R4      h \        P.                  ! VRR7      p\        P4                  ! \6        P8                  ! T\6        P:                  4      \        P<                  4      pTf   \        R 4      hT#   \(        \*        \,        3 d    Rp LŸi ; i  \(        \        P0                  P2                  3 d   p\        R4      ThRp?ii ; i)!zLReturn the edited photo as a BGR image. Raises RuntimeError on API failures.zXAI_API_KEY is not set in .envz.jpgzCould not encode the photo.Úurlzdata:image/jpeg;base64,ÚasciiÚtypeÚ	image_urlzdata:z;base64,z$
Garment description for reference: :Niè  NzZ
Use this only as a visual description; follow the image references and base instructions.z https://api.x.ai/v1/images/editsÚAuthorizationzBearer ÚmodelÚpromptÚimagesÚresponse_formatÚb64_jsonÚn)Úheadersr   ÚtimeoutzxAI answered z: ÚdataNzGrok returned no image.T)Úvalidatez!Grok returned invalid image data.z"Grok returned an unreadable image.)r   ÚXAI_API_KEYÚRuntimeErrorÚcv2ÚimencodeÚIMWRITE_JPEG_QUALITYr   Úbase64Ú	b64encodeÚtobytesÚdecodeÚGROK_PROMPTÚrequestsÚpostÚXAI_IMAGE_MODELÚXAI_TIMEOUTÚstatus_coder   r   r   r	   ÚAttributeErrorÚ
IndexErrorÚ	b64decodeÚbinasciiÚErrorÚimdecodeÚnpÚ
frombufferÚuint8ÚIMREAD_COLOR)Ú
person_bgrÚdressÚgarment_guidanceÚkeyÚokÚbufÚgarment_bytesÚ_Úgarment_typer   r   r   r!   Ú
image_dataÚimage_bytesÚexcÚimages   &&&              r   ÚrenderrI   '   si  € ä
×
Ñ
€CßÜÐ;Ó<Ð<ä�lŠl˜6 :´×0HÑ0HÈ"Ð/MÓN�G€BßÜÐ8Ó9Ð9Ü%5°eÓ%<Ñ"€M�lð Ð,¬v×/?Ò/?ÀÇÁÃÓ/N×/UÑ/UÐV]Ó/^Õ^Ø�Kð	
ð
 �U˜<˜.¨Ð1´F×4DÒ4DÀ]Ó4S×4ZÑ4ZÐ[bÓ4cÕcØ�Kð	
ð	€Fô €FßØØ3Ø˜uÕ%õ&àkõlõ	
ˆô �}Š}Ø*Ø  G¨C¨5 /Ð2à”X×-Ñ-Ø�fØ�fØ˜zØ�ð
ô ×$Ñ$ô€Hð ×Ñ˜sÔ"Ü˜]¨8×+?Ñ+?Ð*@ÀÄ>ÐRZÓC[ÐB\Ð]Ó^Ð^ðØ�}‰}‹×"Ñ" 6Ó*×0Ð0¨bˆß04�T˜!•W—[‘[ Ô,¸$ˆ
÷ ÜÐ4Ó5Ð5ðIÜ×&Ò& z¸DÔAˆô �LŠLœŸš {´B·H±HÓ=¼s×?OÑ?OÓP€EØ‚}ÜÐ?Ó@Ð@Ø€Løô œ¬
Ð3ô ØŠ
ðûô œŸ™×-Ñ-Ð.ô IÜÐ>Ó?ÀSÐHûðIús6   Æ%I Æ.
I Æ9I Ç'I6 ÉI3É2I3É6%J,ÊJ'Ê'J,)Ú )Ú__doc__r(   r%   Únumpyr8   r-   Údjango.confr   Úengine_openair   r,   r   rI   © ó    r   Ú<module>rQ      s.   ðÙ ?Û ã 
Û Û Ý  å +ð.ð ò:ö&;rP   