
    g
                         d Z ddlmZmZmZmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZ  e       Zdee   defd	Zej)                  d
dg ee      ge      d        Zy)z
CRUD ENDPOINTS FOR GUARDRAILS
    )DictListOptionalcast)	APIRouterDependsHTTPExceptionstatus)CommonProxyErrors)user_api_key_auth)GuardrailInfoResponseListGuardrailsResponseguardrails_configreturnc           	          g }| D ]<  }|j                  t        |j                  d      |j                  d                   > t        |      S )z=
    Helper function to get the guardrails list response
    guardrail_nameguardrail_info)r   r   )
guardrails)appendr   getr   )r   guardrail_configs	guardrails      a/var/www/openai/venv/lib/python3.12/site-packages/litellm/proxy/guardrails/guardrail_endpoints.py_get_guardrails_list_responser      sR     68&	  !(}}-=>(}}-=>	
 ' "->??    z/guardrails/list
Guardrails)tagsdependenciesresponse_modelc                  N  K   ddl m} m} | s5t        t        j
                  dt        j                  j                  i      |j                  }t        t        t        t              |j                  d            }|t        t        j                  ddi      t!        |      S w)u  
    ✨ Enterprise Feature
    List the guardrails that are available on the proxy server

    👉 [Guardrail docs](https://docs.litellm.ai/docs/proxy/guardrails/quick_start)

    Example Request:
    ```bash
    curl -X GET "http://localhost:4000/guardrails/list" -H "Authorization: Bearer <your_api_key>"
    ```

    Example Response:
    ```json
    {
        "guardrails": [
            {
            "guardrail_name": "bedrock-pre-guard",
            "guardrail_info": {
                "params": [
                {
                    "name": "toxicity_score",
                    "type": "float",
                    "description": "Score between 0-1 indicating content toxicity level"
                },
                {
                    "name": "pii_detection",
                    "type": "boolean"
                }
                ]
            }
            }
        ]
    }
    ```
    r   )premium_userproxy_configerror)status_codedetailr   zNo guardrails found in config)litellm.proxy.proxy_serverr!   r"   r	   r
   HTTP_403_FORBIDDENr   not_premium_uservalueconfigr   r   listdictr   HTTP_404_NOT_FOUNDr   )r!   r"   r*   _guardrails_configs       r   list_guardrailsr/   #   s     T F11*;;AA
 	
   FhtDz2FJJ|4LM!11<=
 	

 ));<<s   B#B%N)__doc__typingr   r   r   r   fastapir   r   r	   r
   litellm.proxy._typesr   $litellm.proxy.auth.user_api_key_authr   litellm.types.guardrailsr   r   routerr   r   r/    r   r   <module>r8      s    . - = = 2 B R 
@Dz@@" 
+,-)	  8=8=r   