get_openai_output_parser() — langchain Function Reference
Architecture documentation for the get_openai_output_parser() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9d952f43_b82e_ed01_a6db_5be428bc4ed2["get_openai_output_parser()"] 22e1446e_2db6_2965_eef8_bf9239c6dbfc["base.py"] 9d952f43_b82e_ed01_a6db_5be428bc4ed2 -->|defined in| 22e1446e_2db6_2965_eef8_bf9239c6dbfc e8355b27_2273_5b96_4b84_f25ab554e0b3["create_openai_fn_runnable()"] e8355b27_2273_5b96_4b84_f25ab554e0b3 -->|calls| 9d952f43_b82e_ed01_a6db_5be428bc4ed2 style 9d952f43_b82e_ed01_a6db_5be428bc4ed2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/structured_output/base.py lines 493–521
def get_openai_output_parser(
functions: Sequence[dict[str, Any] | type[BaseModel] | Callable],
) -> BaseOutputParser | BaseGenerationOutputParser:
"""Get the appropriate function output parser given the user functions.
Args:
functions: Sequence where element is a dictionary, a pydantic.BaseModel class,
or a Python function. If a dictionary is passed in, it is assumed to
already be a valid OpenAI function.
Returns:
A PydanticOutputFunctionsParser if functions are Pydantic classes, otherwise
a JsonOutputFunctionsParser. If there's only one function and it is
not a Pydantic class, then the output parser will automatically extract
only the function arguments and not the function name.
"""
if isinstance(functions[0], type) and is_basemodel_subclass(functions[0]):
if len(functions) > 1:
pydantic_schema: dict | type[BaseModel] = {
convert_to_openai_function(fn)["name"]: fn for fn in functions
}
else:
pydantic_schema = functions[0]
output_parser: BaseOutputParser | BaseGenerationOutputParser = (
PydanticOutputFunctionsParser(pydantic_schema=pydantic_schema)
)
else:
output_parser = JsonOutputFunctionsParser(args_only=len(functions) <= 1)
return output_parser
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does get_openai_output_parser() do?
get_openai_output_parser() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/structured_output/base.py.
Where is get_openai_output_parser() defined?
get_openai_output_parser() is defined in libs/langchain/langchain_classic/chains/structured_output/base.py at line 493.
What calls get_openai_output_parser()?
get_openai_output_parser() is called by 1 function(s): create_openai_fn_runnable.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free