parse_result() — langchain Function Reference
Architecture documentation for the parse_result() function in openai_functions.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ee804868_fcfd_5c0c_ba3a_ee6f557d3fb2["parse_result()"] 7d12c2b6_67f8_f990_f1b9_163fb3801063["OutputFunctionsParser"] ee804868_fcfd_5c0c_ba3a_ee6f557d3fb2 -->|defined in| 7d12c2b6_67f8_f990_f1b9_163fb3801063 style ee804868_fcfd_5c0c_ba3a_ee6f557d3fb2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/output_parsers/openai_functions.py lines 29–55
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
Subdomains
Source
Frequently Asked Questions
What does parse_result() do?
parse_result() is a function in the langchain codebase, defined in libs/core/langchain_core/output_parsers/openai_functions.py.
Where is parse_result() defined?
parse_result() is defined in libs/core/langchain_core/output_parsers/openai_functions.py at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free