ReasoningJsonOutputParser Class — langchain Architecture
Architecture documentation for the ReasoningJsonOutputParser class in output_parsers.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 617f1d3c_0a13_7080_d8ee_1f0a677a61a0["ReasoningJsonOutputParser"] fb39b415_e8a2_9079_f7d1_646151c6e72c["JsonOutputParser"] 617f1d3c_0a13_7080_d8ee_1f0a677a61a0 -->|extends| fb39b415_e8a2_9079_f7d1_646151c6e72c 1be78f27_fe4d_35ef_90f6_0cba68eb107b["output_parsers.py"] 617f1d3c_0a13_7080_d8ee_1f0a677a61a0 -->|defined in| 1be78f27_fe4d_35ef_90f6_0cba68eb107b 226e3323_bb76_2676_e692_4e21f7ba7236["parse_result()"] 617f1d3c_0a13_7080_d8ee_1f0a677a61a0 -->|method| 226e3323_bb76_2676_e692_4e21f7ba7236
Relationship Graph
Source Code
libs/partners/perplexity/langchain_perplexity/output_parsers.py lines 38–64
class ReasoningJsonOutputParser(JsonOutputParser):
"""A JSON 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 JsonOutputParser for JSON parsing.
"""
def parse_result(self, result: list[Generation], *, partial: bool = False) -> Any:
"""Parse the result of an LLM call to a JSON 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.
Returns:
The parsed JSON object.
Raises:
OutputParserException: If the output is not valid JSON.
"""
text = result[0].text
text = strip_think_tags(text)
return super().parse_result([Generation(text=text)], partial=partial)
Extends
Source
Frequently Asked Questions
What is the ReasoningJsonOutputParser class?
ReasoningJsonOutputParser is a class in the langchain codebase, defined in libs/partners/perplexity/langchain_perplexity/output_parsers.py.
Where is ReasoningJsonOutputParser defined?
ReasoningJsonOutputParser is defined in libs/partners/perplexity/langchain_perplexity/output_parsers.py at line 38.
What does ReasoningJsonOutputParser extend?
ReasoningJsonOutputParser extends JsonOutputParser.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free