Ë
    òÏj
  ã                  ó¼   — d Z ddlmZ ddlZddlmZ ddlZerddlmZ ddl	m
Z
mZmZ  eddh«      Z ej                  e«      Z	 	 	 	 	 	 dd	„Z	 	 	 	 	 	 dd
„Zdd„Zy)zARetry decision requests without images when the API rejects them.é    )ÚannotationsN)ÚTYPE_CHECKING)ÚSequence)ÚDecisionRequestÚDecisionResponseÚOpenAIDecisionsi�  i�  c                óº   — |dd D ]  }	 | j                  |«      c S  | j                  |d   «      S # t        j                  $ r}t        |«       Y d}~ŒOd}~ww xY w)a-  Try each request in order, falling back when one with images is rejected.

    Args:
        decisions: Decision model used to answer the requests.
        requests: Requests to try, ending with one that contains no images.

    Returns:
        The response to the first request the API accepts.
    Néÿÿÿÿ)ÚinvokeÚopenaiÚAPIStatusErrorÚ_raise_unless_retryable©Ú	decisionsÚrequestsÚrequestÚes       úb/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langchain_openai/middleware/_fallback.pyÚdecide_with_text_fallbackr      sd   € ð ˜C˜R“=ˆð	'Ø×#Ñ# GÓ,Ò,ð !ð
 ×Ñ˜H R™LÓ)Ð)øô ×$Ñ$ò 	'Ü# A×&Ñ&ûð	'ús   Š2²AÁAÁAc              ƒ  óê   K  — |dd D ]  }	 | j                  |«      ƒ d{  –—† c S  | j                  |d   «      ƒ d{  –—† S 7 Œ## t        j                  $ r}t        |«       Y d}~Œad}~ww xY w7 Œ1­w)a3  Asynchronously try each request, falling back when one with images is rejected.

    Args:
        decisions: Decision model used to answer the requests.
        requests: Requests to try, ending with one that contains no images.

    Returns:
        The response to the first request the API accepts.
    Nr
   )Úainvoker   r   r   r   s       r   Úadecide_with_text_fallbackr   ,   st   è ø€ ð ˜C˜R“=ˆð	'Ø"×*Ñ*¨7Ó3×3Ò3ð !ð
 ×"Ñ" 8¨B¡<Ó0×0Ð0ð 4ùÜ×$Ñ$ò 	'Ü# A×&Ñ&ûð	'úà0úsH   ‚	A3ŒA A¡A¤A3¿A1Á A3ÁAÁA.ÁA)Á$A3Á)A.Á.A3c                ól   — | j                   t        vr| ‚t        j                  d| j                   «       y )NzMDecision request with images was rejected (HTTP %s); retrying without images.)Ústatus_codeÚ_RETRY_STATUS_CODESÚloggerÚwarning)Úerrors    r   r   r   @   s.   € Ø×ÑÔ 3Ñ3ØˆÜ
‡N�NØWØ×Ñõó    )r   r   r   zSequence[DecisionRequest]Úreturnr   )r   zopenai.APIStatusErrorr    ÚNone)Ú__doc__Ú
__future__r   ÚloggingÚtypingr   r   Úcollections.abcr   Úlangchain_openai.decisionsr   r   r   Ú	frozensetr   Ú	getLoggerÚ__name__r   r   r   r   © r   r   Ú<module>r,      s†   ðÙ Gå "ã Ý  ã áÝ(÷ñ ñ    c 
Ó+Ð à	ˆ×	Ñ	˜8Ó	$€ð*Øð*Ø*Cð*àó*ð(1Øð1Ø*Cð1àó1ô(r   