
    ^h<                        S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
Jr  SSKJr  SSKJrJrJrJrJr  SSKJr  SSKJr  \" 5       r\R3                  S	S
/\" \5      /S9\\" \5      \" SSS94S\S\
S\S\S\\   4
S jj5       5       r\R3                  SS
/\" \5      /S9\\" \5      4S\
S\S\4S jj5       5       r\R;                  S	S
/\" \5      /S9\\" \5      4S\
S\S\4S jj5       5       rg)zc
Endpoints to control callbacks per team

Use this when each team should control its own callbacks
    N)Optional)	APIRouterDependsHeaderHTTPExceptionRequeststatus)verbose_proxy_logger)AddTeamCallbackProxyErrorTypesProxyExceptionTeamCallbackMetadataUserAPIKeyAuth)user_api_key_auth)management_endpoint_wrapperz/team/{team_id:path}/callbackzteam management)tagsdependencieszThe litellm-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability)descriptiondatahttp_requestteam_iduser_api_key_dictlitellm_changed_byc                 	  #     SSK Jn  Uc  [        SSS0S9eUR                  USS	S
9I Sh  vN nUc  [        SSSU S30S9eUR                  nUR                  S0 5      n[        S&0 UD6n	U R                  S:X  a  U	R                  c  / U	l        U R                  U	R                  ;   aE  [        SU R                   SU SU	R                   3[        R                  [        R                  SS9eU	R                  R                  U R                  5        GOU R                  S:X  a  U	R                   c  / U	l        U R                  U	R                   ;   aE  [        SU R                   SU SU	R                    3[        R                  [        R                  SS9eU	R                   R                  U R                  5        GOAU R                  S:X  Ga0  U	R                  c  / U	l        U	R                   c  / U	l        U R                  U	R                  ;   aE  [        SU R                   SU SU	R                   3[        R                  [        R                  SS9eU R                  U	R                   ;   aE  [        SU R                   SU SU	R                    3[        R                  [        R                  SS9eU	R                  R                  U R                  5        U	R                   R                  U R                  5        U R"                  R%                  5        H'  u  pU	R"                  c  0 U	l        XR"                  U
'   M)     U	R'                  5       nXS'   [(        R*                  " U5      nUR,                  R.                  R1                  SU0SU0S9I Sh  vN nSUS.$  GNz N! [2         Ga1  n[4        R6                  " SR9                  [;        U5      5      5        [4        R<                  " [>        R@                  " 5       5        [C        U[        5      (       a`  [        [E        USS[;        U5       S 35      [        RF                  RH                  [E        US!S"5      [E        US#[        RJ                  5      S$9e[C        U[        5      (       a  Ue[        S%[;        U5      -   [        RF                  RH                  [E        US!S"5      [        RJ                  S$9eSnAff = f7f)'a  
Add a success/failure callback to a team

Use this if if you want different teams to have different success/failure callbacks

Parameters:
- callback_name (Literal["langfuse", "langsmith", "gcs"], required): The name of the callback to add
- callback_type (Literal["success", "failure", "success_and_failure"], required): The type of callback to add. One of:
    - "success": Callback for successful LLM calls
    - "failure": Callback for failed LLM calls
    - "success_and_failure": Callback for both successful and failed LLM calls
- callback_vars (StandardCallbackDynamicParams, required): A dictionary of variables to pass to the callback
    - langfuse_public_key: The public key for the Langfuse callback
    - langfuse_secret_key: The secret key for the Langfuse callback
    - langfuse_secret: The secret for the Langfuse callback
    - langfuse_host: The host for the Langfuse callback
    - gcs_bucket_name: The name of the GCS bucket
    - gcs_path_service_account: The path to the GCS service account
    - langsmith_api_key: The API key for the Langsmith callback
    - langsmith_project: The project for the Langsmith callback
    - langsmith_base_url: The base URL for the Langsmith callback

Example curl:
```
curl -X POST 'http:/localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/callback'         -H 'Content-Type: application/json'         -H 'Authorization: Bearer sk-1234'         -d '{
    "callback_name": "langfuse",
    "callback_type": "success",
    "callback_vars": {"langfuse_public_key": "pk-lf-xxxx1", "langfuse_secret_key": "sk-xxxxx"}
    
}'
```

This means for the team where team_id = dbe2f686-a686-4896-864a-4c3924458709, all LLM calls will be logged to langfuse using the public key pk-lf-xxxx1 and the secret key sk-xxxxx

r   prisma_clientN  errorNo db connectedstatus_codedetailteamfind_uniquer   
table_name
query_typei  
Team id = z0 does not exist. Please use a different team id.callback_settingssuccesszcallback_name = z3 already exists in failure_callback, for team_id = z . 
 Existing failure_callback = callback_name)messagecodetypeparamfailuresuccess_and_failurez3 already exists in success_callback, for team_id = z . 
 Existing success_callback = r   metadatawherer   r	   r   zGlitellm.proxy.proxy_server.add_team_callbacks(): Exception occured - {}r"   Internal Server Error()r/   Noner!   r,   r.   r/   r-   Internal Server Error,  )&litellm.proxy.proxy_serverr   r   get_datar2   getr   callback_typesuccess_callbackr+   r   r	   HTTP_400_BAD_REQUESTr   bad_request_errorappendfailure_callbackcallback_varsitems
model_dumpjsondumpsdblitellm_teamtableupdate	Exceptionr
   r   formatstrdebug	traceback
format_exc
isinstancegetattrinternal_server_errorvalueHTTP_500_INTERNAL_SERVER_ERROR)r   r   r   r   r   r   _existing_teamteam_metadatateam_callback_settingsteam_callback_settings_objvarrV   team_callback_settings_obj_dictteam_metadata_jsonnew_team_rowes                   t/home/james-whalen/.local/lib/python3.13/site-packages/litellm/proxy/management_endpoints/team_callback_endpoints.pyadd_team_callbacksrb      s.    lo
< CBS8TUU  -55=  6  
 
 !z'2bc  '//!.!2!23F!K%9%S<R%S"*)::B>@*;!!%?%P%PP$.t/A/A.BBuv}u~  `  a{  aL  aL  `M  N44(::)	  '77>>t?Q?QR9,)::B>@*;!!%?%P%PP$.t/A/A.BBuv}u~  `  a{  aL  aL  `M  N44(::)	  '77>>t?Q?QR#88)::B>@*;)::B>@*;!!%?%P%PP$.t/A/A.BBuv}u~  `  a{  aL  aL  `M  N44(::)	  !!%?%P%PP$.t/A/A.BBuv}u~  `  a{  aL  aL  `M  N44(::)	  '77>>t?Q?QR&77>>t?Q?QR,,224JC)77?;=*8<A44S9 5
 +E*O*O*Q'-L)*!ZZ6*--??FFg&j:L-M G 
 

   
 	
]
T
  
""U\\A	

 	""9#7#7#9:a'' 8/Ec!fXQ-OP$::@@a&1Qv/T/TU	  >**G-A6 66<<!Wf-66	
 	
!
sL   S+)N, N'M/N, N*N, &S+'N, *N, ,S(7D,S##S((S+z/team/{team_id}/disable_loggingc                 p  #     SSK Jn  Uc  [        SSS0S9eUR                  USS	S
9I Sh  vN nUc  [        SSSU S30S9eUR                  nUR                  S0 5      n[        S 0 UD6n/ Ul        / Ul        UR                  5       US'   [        R                  " U5      nUR                  R                  R                  SU0SU0S9I Sh  vN n	U	c  [        SSSU S30S9eSSU 3U	R                  / / S.S.$  N N0! [          Ga%  n
["        R$                  " S['        U
5       35        ["        R(                  " [*        R,                  " 5       5        [/        U
[        5      (       a`  [1        [3        U
SS['        U
5       S35      [4        R6                  R8                  [3        U
SS5      [3        U
S[:        R<                  5      S9e[/        U
[0        5      (       a  U
e[1        S['        U
5      -   [4        R6                  R8                  [3        U
SS5      [:        R<                  S9eSn
A
ff = f7f)!a  
Disable all logging callbacks for a team

Parameters:
- team_id (str, required): The unique identifier for the team

Example curl:
```
curl -X POST 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/disable_logging'         -H 'Authorization: Bearer sk-1234'
```


r   r   Nr   r   r   r    r#   r$   r%     r(    does not exist.r)   r   r2   r3   z, does not exist. Error updating team loggingr*   zLogging disabled for team )r   success_callbacksfailure_callbacks)r	   r,   r   zHlitellm.proxy.proxy_server.disable_team_logging(): Exception occurred - r"   r6   r7   r/   r8   r!   r9   r:   r;   )r<   r   r   r=   r2   r>   r   r@   rD   rG   rH   rI   rJ   rK   rL   r   rM   r
   r   rO   rP   rQ   rR   rS   r   rT   r   rU   rV   r	   rW   )r   r   r   r   rX   rY   rZ   r[   r^   updated_teamr`   s              ra   disable_team_loggingri      sw    2G
< CBS8TUU  -55=  6  
 
 !:gY6F!GH  '//!.!2!23F!K%9%S<R%S" 79"368"3 .H-R-R-T)*!ZZ6 +--??FFg&j:L-M G 
 
 z'2^_   3G9='//%'%'
 	
G
.
,  
""VWZ[\W]V^_	
 	""9#7#7#9:a'' 8/Ec!fXQ-OP$::@@a&1Qv/T/TU	  >**G-A6 66<<!Wf-66	
 	

sL   H6)D C?B"D D-D >H6?D D H3D H..H33H6c                   #     SSK Jn  Uc  [        SSS0S9eUR                  USS	S
9I Sh  vN nUc  [        SSSU S30S9eUR                  nUR                  S0 5      n[        S0 UD6nSUUR                  UR                  UR                  S.S.$  Nh! [         Ga1  n[        R                  " SR                  [        U5      5      5        [        R                  " [         R"                  " 5       5        [%        U[        5      (       a`  ['        [)        USS[        U5       S35      [*        R,                  R.                  [)        USS5      [)        US[0        R2                  5      S9e[%        U[&        5      (       a  Ue['        S[        U5      -   [*        R,                  R.                  [)        USS5      [0        R2                  S9eSnAff = f7f)a  
Get the success/failure callbacks and variables for a team

Parameters:
- team_id (str, required): The unique identifier for the team

Example curl:
```
curl -X GET 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/callback'         -H 'Authorization: Bearer sk-1234'
```

This will return the callback settings for the team with id dbe2f686-a686-4896-864a-4c3924458709

Returns {
        "status": "success",
        "data": {
            "team_id": team_id,
            "success_callbacks": team_callback_settings_obj.success_callback,
            "failure_callbacks": team_callback_settings_obj.failure_callback,
            "callback_vars": team_callback_settings_obj.callback_vars,
        },
    }
r   r   Nr   r   r   r    r#   r$   r%   rd   r(   re   r)   r*   )r   rf   rg   rE   r5   zHlitellm.proxy.proxy_server.get_team_callbacks(): Exception occurred - {}r"   r6   r7   r/   r8   r!   r9   r:   r;   )r<   r   r   r=   r2   r>   r   r@   rD   rE   rM   r
   r   rN   rO   rP   rQ   rR   rS   r   rT   r   rU   rV   r	   rW   )	r   r   r   r   rX   rY   rZ   r[   r`   s	            ra   get_team_callbacksrk   &  s    F6
< CBS8TUU  -55=  6  
 
 !:gY6F!GH  '//!.!2!23F!K &:%S<R%S"  "%?%P%P%?%P%P!;!I!I	
 	
!
4  
""V]]A	

 	""9#7#7#9:a'' 8/Ec!fXQ-OP$::@@a&1Qv/T/TU	  >**G-A6 66<<!Wf-66	
 	
!
s:   G)B BA'B GB G#D,GGG)__doc__rH   rQ   typingr   fastapir   r   r   r   r   r	   litellm._loggingr
   litellm.proxy._typesr   r   r   r   r   $litellm.proxy.auth.user_api_key_authr   &litellm.proxy.management_helpers.utilsr   routerpostrO   rb   ri   r>   rk   r;       ra   <module>rv      s      N N 1  C N	 #
	+,-  
 
 )00A(B(. t)_

_
_
 _
 &	_

 !_
 _
D %
	+,-  
  )00A(BZ
Z
Z
 &Z
 Z
z #
	+,-  
  )00A(BS
S
S
 &S
 S
ru   