ReasoningStructuredOutputParser Class — langchain Architecture
Architecture documentation for the ReasoningStructuredOutputParser class in output_parsers.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c9e9354f_7b48_d8bc_644d_55a2eb9990f7["ReasoningStructuredOutputParser"] 1be78f27_fe4d_35ef_90f6_0cba68eb107b["output_parsers.py"] c9e9354f_7b48_d8bc_644d_55a2eb9990f7 -->|defined in| 1be78f27_fe4d_35ef_90f6_0cba68eb107b 9a2ae530_422d_2fd8_fa7d_2515e0623c7c["parse_result()"] c9e9354f_7b48_d8bc_644d_55a2eb9990f7 -->|method| 9a2ae530_422d_2fd8_fa7d_2515e0623c7c
Relationship Graph
Source Code
libs/partners/perplexity/langchain_perplexity/output_parsers.py lines 67–88
class ReasoningStructuredOutputParser(
PydanticOutputParser[TBaseModel], Generic[TBaseModel]
):
"""A structured output parser that strips reasoning tags before parsing.
This parser removes any content enclosed in <think> tags from the input text
before delegating to the parent PydanticOutputParser for structured parsing.
"""
def parse_result(self, result: list[Generation], *, partial: bool = False) -> Any:
"""Parse the result of an LLM call to a Pydantic object.
Args:
result: The result of the LLM call.
partial: Whether to parse partial JSON objects.
If `True`, the output will be a JSON object containing
all the keys that have been returned so far.
If `False`, the output will be the full JSON object.
"""
text = result[0].text
text = strip_think_tags(text)
return super().parse_result([Generation(text=text)], partial=partial)
Source
Frequently Asked Questions
What is the ReasoningStructuredOutputParser class?
ReasoningStructuredOutputParser is a class in the langchain codebase, defined in libs/partners/perplexity/langchain_perplexity/output_parsers.py.
Where is ReasoningStructuredOutputParser defined?
ReasoningStructuredOutputParser is defined in libs/partners/perplexity/langchain_perplexity/output_parsers.py at line 67.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free