Home / Function/ convert_to_secret_str() — langchain Function Reference

convert_to_secret_str() — langchain Function Reference

Architecture documentation for the convert_to_secret_str() function in utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  56d0a220_75eb_9a94_ccfb_7688fe0cef7a["convert_to_secret_str()"]
  b77fd012_b825_e350_c8f5_a8f1b44997d9["utils.py"]
  56d0a220_75eb_9a94_ccfb_7688fe0cef7a -->|defined in| b77fd012_b825_e350_c8f5_a8f1b44997d9
  style 56d0a220_75eb_9a94_ccfb_7688fe0cef7a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/utils/utils.py lines 313–324

def convert_to_secret_str(value: SecretStr | str) -> SecretStr:
    """Convert a string to a `SecretStr` if needed.

    Args:
        value: The value to convert.

    Returns:
        The `SecretStr` value.
    """
    if isinstance(value, SecretStr):
        return value
    return SecretStr(value)

Domain

Subdomains

Frequently Asked Questions

What does convert_to_secret_str() do?
convert_to_secret_str() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/utils.py.
Where is convert_to_secret_str() defined?
convert_to_secret_str() is defined in libs/core/langchain_core/utils/utils.py at line 313.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free