Home / Function/ format() — langchain Function Reference

format() — langchain Function Reference

Architecture documentation for the format() function in chat.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  08b4874f_15ee_e20e_22dd_dc40f35fb150["format()"]
  93017235_36b7_3b85_820e_aa7d145183e5["BaseChatPromptTemplate"]
  08b4874f_15ee_e20e_22dd_dc40f35fb150 -->|defined in| 93017235_36b7_3b85_820e_aa7d145183e5
  e9411289_e300_3889_9890_8b2d1e616969["format_prompt()"]
  08b4874f_15ee_e20e_22dd_dc40f35fb150 -->|calls| e9411289_e300_3889_9890_8b2d1e616969
  4d5e2501_6d84_a2a3_49d1_fa84af2fe2d1["format()"]
  08b4874f_15ee_e20e_22dd_dc40f35fb150 -->|calls| 4d5e2501_6d84_a2a3_49d1_fa84af2fe2d1
  style 08b4874f_15ee_e20e_22dd_dc40f35fb150 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/prompts/chat.py lines 698–708

    def format(self, **kwargs: Any) -> str:
        """Format the chat template into a string.

        Args:
            **kwargs: Keyword arguments to use for filling in template variables in all
                the template messages in this chat template.

        Returns:
            Formatted string.
        """
        return self.format_prompt(**kwargs).to_string()

Subdomains

Frequently Asked Questions

What does format() do?
format() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/chat.py.
Where is format() defined?
format() is defined in libs/core/langchain_core/prompts/chat.py at line 698.
What does format() call?
format() calls 2 function(s): format, format_prompt.

Analyze Your Own Codebase

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

Try Supermodel Free