NumberedListOutputParser Class — langchain Architecture
Architecture documentation for the NumberedListOutputParser class in list.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b8940fcc_465e_32f4_d9e6_c01e04edca69["NumberedListOutputParser"] 137024f5_2b01_9c8f_64f4_357c533282c7["ListOutputParser"] b8940fcc_465e_32f4_d9e6_c01e04edca69 -->|extends| 137024f5_2b01_9c8f_64f4_357c533282c7 39460b97_96ad_60ff_34e4_145e3ec6b305["list.py"] b8940fcc_465e_32f4_d9e6_c01e04edca69 -->|defined in| 39460b97_96ad_60ff_34e4_145e3ec6b305 9f87fa85_5293_af74_ea1b_1e6e9e4cf423["get_format_instructions()"] b8940fcc_465e_32f4_d9e6_c01e04edca69 -->|method| 9f87fa85_5293_af74_ea1b_1e6e9e4cf423 9d18cade_0cbf_cb62_89a9_adf6b090d483["parse()"] b8940fcc_465e_32f4_d9e6_c01e04edca69 -->|method| 9d18cade_0cbf_cb62_89a9_adf6b090d483 7ca90d0f_a7b9_6724_8d59_6dcc04ef152a["parse_iter()"] b8940fcc_465e_32f4_d9e6_c01e04edca69 -->|method| 7ca90d0f_a7b9_6724_8d59_6dcc04ef152a 7e118702_1e5a_322e_f3eb_07ba9fef3ef1["_type()"] b8940fcc_465e_32f4_d9e6_c01e04edca69 -->|method| 7e118702_1e5a_322e_f3eb_07ba9fef3ef1
Relationship Graph
Source Code
libs/core/langchain_core/output_parsers/list.py lines 188–218
class NumberedListOutputParser(ListOutputParser):
"""Parse a numbered list."""
pattern: str = r"\d+\.\s([^\n]+)"
"""The pattern to match a numbered list item."""
@override
def get_format_instructions(self) -> str:
return (
"Your response should be a numbered list with each item on a new line. "
"For example: \n\n1. foo\n\n2. bar\n\n3. baz"
)
def parse(self, text: str) -> list[str]:
"""Parse the output of an LLM call.
Args:
text: The output of an LLM call.
Returns:
A list of strings.
"""
return re.findall(self.pattern, text)
@override
def parse_iter(self, text: str) -> Iterator[re.Match]:
return re.finditer(self.pattern, text)
@property
def _type(self) -> str:
return "numbered-list"
Extends
Source
Frequently Asked Questions
What is the NumberedListOutputParser class?
NumberedListOutputParser is a class in the langchain codebase, defined in libs/core/langchain_core/output_parsers/list.py.
Where is NumberedListOutputParser defined?
NumberedListOutputParser is defined in libs/core/langchain_core/output_parsers/list.py at line 188.
What does NumberedListOutputParser extend?
NumberedListOutputParser extends ListOutputParser.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free