
    ^h                         S r  SSKrSSKrSSKJr  SSKJr  SSKrSSKJrJ	r	J
r
  SSKrSSK7  SSKJr  SSKJr  SS	KJr  \" 5       rSrS
\	4S jr\R-                  S/ SQSS/S9S\S
\	S\
4S j5       rg)z0
What is this? 

Logging Pass-Through Endpoints
    N)	b64encode)Optional)	APIRouterRequestResponse)*)user_api_key_auth)_get_dynamic_logging_metadata)create_pass_through_routerequestc                     U R                   [        U R                  5      [        U R                  5      U R
                  [        U R                  5      S.$ )N)methodurlheaderscookiesquery_params)r   strr   dictr   r   r   )r   s    n/home/james-whalen/.local/lib/python3.13/site-packages/litellm/proxy/vertex_ai_endpoints/langfuse_endpoints.pycreate_request_copyr      s@    ..7;;(??W112     z/langfuse/{endpoint:path})GETPOSTPUTDELETEPATCHzLangfuse Pass-throughzpass-through)methodstagsendpointfastapi_responsec                   #    UR                   R                  S5      =(       d    SnUR                  SS5      n[        R                  " U5      nUR                  S5      nUR                  S5      S   n[        USR                  U5      S9I S	h  vN n[        US
9nS	nS	n	S	n
UbN  UR                  bA  UR                  R                  5        H#  u  pUS:X  a  UnM  US:X  a  Un	M  US:X  d  M!  Un
M%     U
=(       d     [        R                  " SS5      =(       d    SnUR                  S5      (       d  UR                  S5      (       d  SU-   n[        R                   " U 5      R"                  nUR                  S5      (       d  SU-   n[        R                   " U5      nUR%                  US9nU=(       d    [&        R(                  R+                  SS9nU	=(       d    [&        R(                  R+                  SS9nS[-        U SU 3R/                  S5      5      R                  S5      -   n[1        U [3        U5      SU0S9nU" UUU[5        UR6                  5      S9I S	h  vN nU$  GN N	7f)zw
Call Langfuse via LiteLLM proxy. Works with Langfuse SDK.

[Docs](https://docs.litellm.ai/docs/pass_through/langfuse)
Authorization zBasic zutf-8:   z	Bearer {})r   api_keyN)user_api_key_dictlangfuse_public_keylangfuse_secret_keylangfuse_hostLANGFUSE_HOSTzhttps://cloud.langfuse.comzhttp://zhttps:///)pathLANGFUSE_PUBLIC_KEY)secret_nameLANGFUSE_SECRET_KEYascii)r   targetcustom_headers)r   )r   getreplacebase64	b64decodedecodesplitr	   formatr
   callback_varsitemsosgetenv
startswithhttpxURLr-   	copy_withlitellmutils
get_secretr   encoder   r   r   r   )r   r   r    r&   decoded_bytesdecoded_strr'   callback_settings_objdynamic_langfuse_public_keydynamic_langfuse_secret_keydynamic_langfuse_hostkvbase_target_urlencoded_endpointbase_urlupdated_urlr(   r)   langfuse_combined_keyendpoint_funcreceived_values                         r   langfuse_proxy_routerV   )   s      oo!!/28bG ooh+G$$W-M&&w/K$Q'G/!3!3G!< 
 	&8IJ  2615+/)!//;)77==?DA))./+++./+o%()% @ 	 	(99_&BC	('  	""9--1K1KJ1W1W $o5yy*// &&s++!11 yy)H$$*:$;K 6 9Q9Q) :R : 6 9Q9Q) :R : %y
q!4 56==gF(fWo
 .;')>?M
 )'../	 N K|s,   BI-I(AI-/E2I-!I+"I-+I-)__doc__r6   r=   r   typingr   r@   fastapir   r   r   rC   litellm.proxy._types$litellm.proxy.auth.user_api_key_authr	   $litellm.proxy.litellm_pre_call_utilsr
   ;litellm.proxy.pass_through_endpoints.pass_through_endpointsr   routerdefault_vertex_configr   	api_router   rV    r   r   <module>rb      s     	    0 0  " B N 
   5
!>	2  
YYY Y
Yr   