Home / Function/ print_text() — langchain Function Reference

print_text() — langchain Function Reference

Architecture documentation for the print_text() function in input.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2c7e4f6a_c4aa_aa10_b22c_c3c2b035744f["print_text()"]
  221c6bb5_2ec7_fbe8_1fae_cef08a34f645["input.py"]
  2c7e4f6a_c4aa_aa10_b22c_c3c2b035744f -->|defined in| 221c6bb5_2ec7_fbe8_1fae_cef08a34f645
  8ef29dab_0521_d1d7_4d72_cab5880a0309["get_colored_text()"]
  2c7e4f6a_c4aa_aa10_b22c_c3c2b035744f -->|calls| 8ef29dab_0521_d1d7_4d72_cab5880a0309
  style 2c7e4f6a_c4aa_aa10_b22c_c3c2b035744f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/utils/input.py lines 64–82

def print_text(
    text: str, color: str | None = None, end: str = "", file: TextIO | None = None
) -> None:
    """Print text with highlighting and no end characters.

    If a color is provided, the text will be printed in that color.

    If a file is provided, the text will be written to that file.

    Args:
        text: The text to print.
        color: The color to use.
        end: The end character to use.
        file: The file to write to.
    """
    text_to_print = get_colored_text(text, color) if color else text
    print(text_to_print, end=end, file=file)
    if file:
        file.flush()  # ensure all printed content are written to file

Domain

Subdomains

Frequently Asked Questions

What does print_text() do?
print_text() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/input.py.
Where is print_text() defined?
print_text() is defined in libs/core/langchain_core/utils/input.py at line 64.
What does print_text() call?
print_text() calls 1 function(s): get_colored_text.

Analyze Your Own Codebase

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

Try Supermodel Free