
    dh              
       n    S SK JrJr  S\\\\\4   4   S\\\\\\\4   4   4   4S jrS\S\S\4S jrg)	    )DictUnioninputreturnc                      SSK n[        U [        5      (       a.  UR	                  U /5      nUR
                  S   UR                  S.$ [        U [        5      (       ar  [        5       nU  H  nUR                  X   5        M     UR	                  U5      nUR
                  nSn[        5       nU  H  nXg   X'   US-  nM     UUR                  S.$ [        S[        U 5       35      e! [         a    [        S5      ef = f)a  
Sanitize input string or dict of strings by replacing sensitive data with
placeholders.

It returns the sanitized input string or dict of strings and the secure
context as a dict following the format:
{
    "sanitized_input": <sanitized input string or dict of strings>,
    "secure_context": <secure context>
}

The secure context is a bytes object that is needed to de-sanitize the response
from the LLM.

Args:
    input: Input string or dict of strings.

Returns:
    Sanitized input string or dict of strings and the secure context
    as a dict following the format:
    {
        "sanitized_input": <sanitized input string or dict of strings>,
        "secure_context": <secure context>
    }

    The `secure_context` needs to be passed to the `desanitize` function.

Raises:
    ValueError: If the input is not a string or dict of strings.
    ImportError: If the `opaqueprompts` Python package is not installed.
r   NhCould not import the `opaqueprompts` Python package, please install it with `pip install opaqueprompts`.)sanitized_inputsecure_context   zUnexpected input type )opaquepromptsImportError
isinstancestrsanitizesanitized_textsr
   dictlistappend
ValueErrortype)	r   opsanitize_responsevalueskeysanitize_values_responsesanitized_input_valuesidxr	   s	            c/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/utilities/opaqueprompts.pyr   r      s   D
" %13eW1E0@@C/>>
 	

 % CMM%*%  9;F8K  ":!I!I&C#9#>O 1HC 
  /6EE
 	

 -d5k];
<<M  
B
 	

s   C' 'C=sanitized_textr
   c                 x     SSK nUR                  X5      nUR                  $ ! [         a    [        S5      ef = f)z
Restore the original sensitive data from the sanitized text.

Args:
    sanitized_text: Sanitized text.
    secure_context: Secure context returned by the `sanitize` function.

Returns:
    De-sanitized text.
r   Nr   )r   r   
desanitizedesanitized_text)r   r
   r   desanitize_responses       r   r!   r!   Q   sP    
" 242 ///  
B
 	

s   # 9N)typingr   r   r   r   bytesr!        r   <module>r(      si    J=d38n$%J=	#uS$sCx.()
)*J=Z0s 0E 0c 0r'   