
    gK                         d Z 	 ddlZddlZddlmZ ddlmZ ddlZddlmZm	Z	m
Z
 ddlZddl ddlmZ ddlmZ dd	lmZ  e       ZdZd
e	fdZej-                  dg dddg      ded
e	de
fd       Zy)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                     | j                   t        | j                        t        | j                        | j
                  t        | j                        dS )N)methodurlheaderscookiesquery_params)r   strr   dictr   r   r   )r   s    i/var/www/openai/venv/lib/python3.12/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                   K   ddl m} |j                  j                  d      xs d}|j	                  dd      }t        j                  |      }|j                  d      }|j                  d      d   }t        |d	j                  |      
       d{   }t        ||      }d}	d}
d}|F|j                  :|j                  j                         D ]  \  }}|dk(  r|}	|dk(  r|}
|dk(  s|} |xs t        j                  dd      xs d}|j!                  d      s|j!                  d      sd|z   }t#        j$                  |       j&                  }|j!                  d      sd|z   }t#        j$                  |      }|j)                  |      }|	xs  t*        j,                  j/                  d      }|
xs  t*        j,                  j/                  d      }dt1        | d| j3                  d            j                  d      z   }t5        | t7        |      d|i      } ||||t9        |j:                               d{   }|S 7 7 	w)z
    Call Langfuse via LiteLLM proxy. Works with Langfuse SDK.

    [Docs](https://docs.litellm.ai/docs/pass_through/langfuse)
    r   )proxy_configAuthorization zBasic zutf-8:   z	Bearer {})r   api_keyN)user_api_key_dictr"   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   )litellm.proxy.proxy_serverr"   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"   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_routerX   )   s     8 oo!!/28bG ooh+G$$W-M&&w/K$Q'G/!3!3G!< 
 	&/l	
  2615+/)!//;)77==?DAq))./+++./+o%()% @ 	 	(99_&BC	('  	""9-1K1KJ1W $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 O@s,   BIIAI/EII	II)__doc__r8   r?   r   typingr   rB   fastapir   r   r   rE   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   rX    r   r   <module>rd      s     	    0 0  " B N 
   5
!>	2  
]]] ]
]r   