OutputFunctionsParser Class — langchain Architecture
Architecture documentation for the OutputFunctionsParser class in openai_functions.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7b7af3a3_20c2_a402_1324_527ad8324dcb["OutputFunctionsParser"] fb3554e0_291b_93d2_d325_51461432ed8a["ChatGeneration"] 7b7af3a3_20c2_a402_1324_527ad8324dcb -->|extends| fb3554e0_291b_93d2_d325_51461432ed8a d083bb96_f642_0585_b68e_6b3fea430962["openai_functions.py"] 7b7af3a3_20c2_a402_1324_527ad8324dcb -->|defined in| d083bb96_f642_0585_b68e_6b3fea430962 61614a47_035d_f46f_176f_fbad82ad5f60["parse_result()"] 7b7af3a3_20c2_a402_1324_527ad8324dcb -->|method| 61614a47_035d_f46f_176f_fbad82ad5f60
Relationship Graph
Source Code
libs/core/langchain_core/output_parsers/openai_functions.py lines 22–55
class OutputFunctionsParser(BaseGenerationOutputParser[Any]):
"""Parse an output that is one of sets of values."""
args_only: bool = True
"""Whether to only return the arguments to the function call."""
@override
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.
Returns:
The parsed JSON object.
Raises:
OutputParserException: If the output is not valid JSON.
"""
generation = result[0]
if not isinstance(generation, ChatGeneration):
msg = "This output parser can only be used with a chat generation."
raise OutputParserException(msg)
message = generation.message
try:
func_call = copy.deepcopy(message.additional_kwargs["function_call"])
except KeyError as exc:
msg = f"Could not parse function call: {exc}"
raise OutputParserException(msg) from exc
if self.args_only:
return func_call["arguments"]
return func_call
Domain
Extends
Source
Frequently Asked Questions
What is the OutputFunctionsParser class?
OutputFunctionsParser is a class in the langchain codebase, defined in libs/core/langchain_core/output_parsers/openai_functions.py.
Where is OutputFunctionsParser defined?
OutputFunctionsParser is defined in libs/core/langchain_core/output_parsers/openai_functions.py at line 22.
What does OutputFunctionsParser extend?
OutputFunctionsParser extends ChatGeneration.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free