format() — langchain Function Reference
Architecture documentation for the format() function in few_shot.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d81a55c1_61d8_17d8_17fd_bded4d38cb51["format()"] bc8a83aa_4b35_16c3_4580_cce73bba5daf["FewShotChatMessagePromptTemplate"] d81a55c1_61d8_17d8_17fd_bded4d38cb51 -->|defined in| bc8a83aa_4b35_16c3_4580_cce73bba5daf aecf2087_50d0_5554_4bc1_b32b629d98fe["format()"] aecf2087_50d0_5554_4bc1_b32b629d98fe -->|calls| d81a55c1_61d8_17d8_17fd_bded4d38cb51 2b1856e6_dc07_d7b0_467f_b61481c0d07a["format_messages()"] d81a55c1_61d8_17d8_17fd_bded4d38cb51 -->|calls| 2b1856e6_dc07_d7b0_467f_b61481c0d07a aecf2087_50d0_5554_4bc1_b32b629d98fe["format()"] d81a55c1_61d8_17d8_17fd_bded4d38cb51 -->|calls| aecf2087_50d0_5554_4bc1_b32b629d98fe style d81a55c1_61d8_17d8_17fd_bded4d38cb51 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/few_shot.py lines 432–447
def format(self, **kwargs: Any) -> str:
"""Format the prompt with inputs generating a string.
Use this method to generate a string representation of a prompt consisting of
chat messages.
Useful for feeding into a string-based completion language model or debugging.
Args:
**kwargs: Keyword arguments to use for formatting.
Returns:
A string representation of the prompt
"""
messages = self.format_messages(**kwargs)
return get_buffer_string(messages)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does format() do?
format() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/few_shot.py.
Where is format() defined?
format() is defined in libs/core/langchain_core/prompts/few_shot.py at line 432.
What does format() call?
format() calls 2 function(s): format, format_messages.
What calls format()?
format() is called by 1 function(s): format.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free