
    i!
                        d dl mZ d dlmZmZmZmZmZ d dlm	Z	 	 d dl
mZ n# e$ r d dZY nw xY wd dZd	Zd
ZdZdZdZed         Zd!dZd"dZd#dZd$dZd%dZdS )&    )annotations)LiteralUnionget_argsOptionalAny)Headers)get_current_appreturnOptional[Any]c                     d S N r       Z/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/fal_client/_headers.pyr
   r
      s    tr   c                 B    t                      x} | j        | j        S dS )z7Get the current request if we are running in a fal app.N)r
   current_request)apps    r   _current_fal_app_requestr      s)       -#2E2Q""4r      zX-Fal-Request-TimeoutzX-Fal-Request-Timeout-TypezX-Fal-Runner-HintzX-Fal-Queue-Priority)normallowtimeoutUnion[int, float]headersdict[str, str]Nonec                    	 t          |           } n # t          $ r t          d|            w xY w| t          k    rt          dt           d          t          |           |t          <   dS )zV
    Validates the timeout and adds the timeout header to the headers dictionary.
    zTimeout must be a number, got zTimeout must be greater than z secondsN)float
ValueErrorMIN_REQUEST_TIMEOUT_SECONDSstrREQUEST_TIMEOUT_HEADER)r   r   s     r   add_timeout_headerr$   "   s    E.. E E EC'CCDDDE ---Q,GQQQ
 
 	
 '*'llG"###s    /hintr"   c                    | |t           <   d S r   )RUNNER_HINT_HEADER)r%   r   s     r   add_hint_headerr(   3   s    "&Gr   priorityPriorityc                v    t          t                    }| |vrt          d| d|  d          | |t          <   dS )a&  
    Validates the priority and adds the priority header to the headers dictionary.

    Args:
        priority: Queue priority, must be "normal" or "low".
        headers: Headers dictionary to add the priority header to.

    Raises:
        ValueError: If priority is not a valid value.
    zPriority must be one of z, got ''N)r   r*   r    QUEUE_PRIORITY_HEADER)r)   r   valid_prioritiess      r   add_priority_headerr/   7   sZ      ))'''K'7KKKKK
 
 	
 &.G!"""r   c                p    t                      x}r#|j                            d          x}r	|| d<   d S d S d S Nzx-fal-cdn-token)r   r   get)r   request	cdn_tokens      r   add_fal_app_context_headersr5   J   sX    *,,,w 3++,=>>>9 	3)2G%&&&3 3	3 	3r   response_headersr	   c                p    t                      x}r#|                     d          x}r||j        d<   d S d S d S r1   )r   r2   r   )r6   r3   r4   s      r   handle_response_headersr8   P   sX    *,,,w ;(,,->???9 	;1:GO-...; ;	; 	;r   N)r   r   )r   r   r   r   r   r   )r%   r"   r   r   r   r   )r)   r*   r   r   r   r   )r   r   r   r   )r6   r	   r   r   )
__future__r   typingr   r   r   r   r   httpxr	   fal.refr
   ImportErrorr   r!   r#   REQUEST_TIMEOUT_TYPE_HEADERr'   r-   r*   r$   r(   r/   r5   r8   r   r   r   <module>r?      sV   " " " " " " : : : : : : : : : : : : : :      '''''''               1 : ( .  ?#3 3 3 3"' ' ' '. . . .&3 3 3 3; ; ; ; ; ;s   # 	//