Home / Function/ format() — langchain Function Reference

format() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  2d4bc191_fb27_aca3_7fa8_c474bd7b9f71["format()"]
  21bd3731_3333_8ace_7023_5dd43ed308cf["PromptTemplate"]
  2d4bc191_fb27_aca3_7fa8_c474bd7b9f71 -->|defined in| 21bd3731_3333_8ace_7023_5dd43ed308cf
  style 2d4bc191_fb27_aca3_7fa8_c474bd7b9f71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/prompts/prompt.py lines 191–201

    def format(self, **kwargs: Any) -> str:
        """Format the prompt with the inputs.

        Args:
            **kwargs: Any arguments to be passed to the prompt template.

        Returns:
            A formatted string.
        """
        kwargs = self._merge_partial_and_user_variables(**kwargs)
        return DEFAULT_FORMATTER_MAPPING[self.template_format](self.template, **kwargs)

Subdomains

Frequently Asked Questions

What does format() do?
format() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/prompt.py.
Where is format() defined?
format() is defined in libs/core/langchain_core/prompts/prompt.py at line 191.

Analyze Your Own Codebase

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

Try Supermodel Free