Ë
    uPêj(  ã                   ó†   — d dl mZ d dlmZmZmZmZ ddlmZ erd dl	m
Z
mZmZ d dlmZ d dlmZ ddlmZ  G d	„ d
e«      Zy)é    )Úabstractmethod)ÚTYPE_CHECKINGÚFinalÚOptionalÚUnioné   )ÚBaseLLMModelInfo)ÚURLÚHeadersÚResponse)ÚLogging)ÚCostResponseTypes©ÚBaseLLMExceptionc                   óf  — e Zd Zedededefd„«       Zdedededz  ddfd	„Zed
edz  dedz  dedededz  dede	def   fd„«       Z
	 d"dedededz  d
ededz  de	eedz  f   fd„Zdededeedf   ddfd„Zdededddedddeded   fd„Zdee   dddedededed   fd„Zd ee   dee   fd!„Zy)#ÚBasePassthroughConfigÚendpointÚrequest_dataÚreturnc                  ó   — y)z=
        Check if the request is a streaming request
        N© )Úselfr   r   s      úu/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/base_llm/passthrough/transformation.pyÚis_streaming_requestz*BasePassthroughConfig.is_streaming_request   ó   � ó    Úbase_target_urlÚrequest_query_paramsNr
   c                 óà   — ddl m} ddl}|j                  d«      }|j	                  d«      }|› d|› �}|j                  |«      }|r'|j                   ||«      j                  d«      ¬«      }|S )aa  
        Helper function to add query params to the url
        Args:
            endpoint: str - the endpoint to add to the url
            base_target_url: str - the base url to add the endpoint to
            request_query_params: Optional[dict] - the query params to add to the url
        Returns:
            httpx.URL - the formatted url
        r   )Ú	urlencodeNú/Úascii)Úquery)Úurllib.parser    ÚhttpxÚrstripÚlstripr
   Ú	copy_withÚencode)	r   r   r   r   r    r%   ÚbaseÚfull_urlÚurls	            r   Ú
format_urlz BasePassthroughConfig.format_url   so   € õ 	+ãà%×,Ñ,¨SÓ1ˆØ—?‘? 3Ó'ˆØ!˜F ! H :Ð.ˆà�i‰i˜Ó!ˆáØ—-‘-¡iÐ0DÓ&E×&LÑ&LÈWÓ&U�-ÓVˆCàˆ
r   Úapi_baseÚapi_keyÚmodelÚlitellm_paramsc                  ó   — y)zí
        Get the complete url for the request
        Returns:
            - complete_url: URL - the complete url for the request
            - base_target_url: str - the base url to add the endpoint to. Useful for auth headers.
        Nr   )r   r.   r/   r0   r   r   r1   s          r   Úget_complete_urlz&BasePassthroughConfig.get_complete_url4   r   r   Úheadersc                 ó
   — |dfS )a0  
        Some providers like Bedrock require signing the request. The sign request funtion needs access to `request_data` and `complete_url`
        Args:
            headers: dict
            optional_params: dict
            request_data: dict - the request body being sent in http request
            api_base: str - the complete url being sent in http request
        Returns:
            dict - the signed headers

        Update the headers with the signed headers in this function. The return values will be sent as headers in the http request.
        Nr   )r   r4   r1   r   r.   r0   s         r   Úsign_requestz"BasePassthroughConfig.sign_requestE   s   € ð( ˜ˆ}Ðr   Úerror_messageÚstatus_coder   r   c                 ó$   — ddl m}  ||||¬«      S )Nr   r   )r8   Úmessager4   )Ú)litellm.llms.base_llm.chat.transformationr   )r   r7   r8   r4   r   s        r   Úget_error_classz%BasePassthroughConfig.get_error_class[   s   € õ 	Oá¨KÀÐX_Ô`Ð`r   Úcustom_llm_providerÚhttpx_responser   Úlogging_objÚLiteLLMLoggingObjr   c                  ó   — y ©Nr   )r   r0   r=   r>   r   r?   r   s          r   Úlogging_non_streaming_responsez4BasePassthroughConfig.logging_non_streaming_responseb   s   € ð 	r   Ú
all_chunksÚlitellm_logging_objc                  ó   — y rB   r   )r   rD   rE   r0   r=   r   s         r   Úhandle_logging_collected_chunksz5BasePassthroughConfig.handle_logging_collected_chunksm   s   € ð r   Ú	raw_bytesc                 óÊ   — dj                  |«      j                  d«      }|j                  d«      D �cg c]#  }|j                  «       sŒ|j                  «       ‘Œ% }}|S c c}w )a  
        Converts a list of raw bytes into a list of string lines, similar to aiter_lines()

        Args:
            raw_bytes: List of bytes chunks from aiter.bytes()

        Returns:
            List of string lines, with each line being a complete data: {} chunk
        r   zutf-8ú
)ÚjoinÚdecodeÚsplitÚstrip)r   rH   Úcombined_strÚlineÚliness        r   Ú_convert_raw_bytes_to_str_linesz5BasePassthroughConfig._convert_raw_bytes_to_str_linesw   sV   € ð "Ÿh™h yÓ1×8Ñ8¸ÓAˆð 2>×1CÑ1CÀDÓ1IÖZ¨ÈTÏZÉZÍ\˜Ÿ
™
�ÐZˆÐZàˆùò [s   ´A Á
A rB   )Ú__name__Ú
__module__Ú__qualname__r   ÚstrÚdictÚboolr   r-   Útupler3   Úbytesr6   Úintr   r<   r   rC   ÚlistrG   rR   r   r   r   r   r      s  „ Øð¨Sð Àð Èò ó ðð
àðð ðð # T™kð	ð
 
óð< ðà˜‘*ðð �t‘ðð ð	ð
 ðð # T™kðð ðð 
ˆu�cˆzÑ	òó ðð, !ñàðð ðð ˜T‘kð	ð
 ðð �T‰zðð 
ˆt�U˜T‘\Ð!Ñ	"óð,aØ ðaØ/2ðaØ=BÀ4ÈÀ?Ñ=Sðaà	óað	àð	ð !ð	ð #ð		ð
 ð	ð )ð	ð ð	ð 
Ð%Ñ	&ó	ðà˜‘Iðð 1ðð ð	ð
 !ðð ðð 
Ð%Ñ	&óð¸¸e¹ð ÈÈcÉô r   r   N)Úabcr   Útypingr   r   r   r   Ú
base_utilsr	   r%   r
   r   r   Ú*litellm.litellm_core_utils.litellm_loggingr   r@   Úlitellm.types.utilsr   Úchat.transformationr   r   r   r   r   ú<module>rc      s2   ðÝ ß 8Ó 8å )áß,Ñ,åWÝ5å6ôxÐ,õ xr   