_create_openai_tools_runnable() — langchain Function Reference
Architecture documentation for the _create_openai_tools_runnable() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 74a2fd31_540f_8c92_debc_5e39815247bf["_create_openai_tools_runnable()"] 22e1446e_2db6_2965_eef8_bf9239c6dbfc["base.py"] 74a2fd31_540f_8c92_debc_5e39815247bf -->|defined in| 22e1446e_2db6_2965_eef8_bf9239c6dbfc f3f63b38_7673_1a74_f67c_06b8e8cfcdf3["create_structured_output_runnable()"] f3f63b38_7673_1a74_f67c_06b8e8cfcdf3 -->|calls| 74a2fd31_540f_8c92_debc_5e39815247bf da705fa3_279a_2153_6004_974d984cb208["_get_openai_tool_output_parser()"] 74a2fd31_540f_8c92_debc_5e39815247bf -->|calls| da705fa3_279a_2153_6004_974d984cb208 style 74a2fd31_540f_8c92_debc_5e39815247bf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/structured_output/base.py lines 450–472
def _create_openai_tools_runnable(
tool: dict[str, Any] | type[BaseModel] | Callable,
llm: Runnable,
*,
prompt: BasePromptTemplate | None,
output_parser: BaseOutputParser | BaseGenerationOutputParser | None,
enforce_tool_usage: bool,
first_tool_only: bool,
) -> Runnable:
oai_tool = convert_to_openai_tool(tool)
llm_kwargs: dict[str, Any] = {"tools": [oai_tool]}
if enforce_tool_usage:
llm_kwargs["tool_choice"] = {
"type": "function",
"function": {"name": oai_tool["function"]["name"]},
}
output_parser = output_parser or _get_openai_tool_output_parser(
tool,
first_tool_only=first_tool_only,
)
if prompt:
return prompt | llm.bind(**llm_kwargs) | output_parser
return llm.bind(**llm_kwargs) | output_parser
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _create_openai_tools_runnable() do?
_create_openai_tools_runnable() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/structured_output/base.py.
Where is _create_openai_tools_runnable() defined?
_create_openai_tools_runnable() is defined in libs/langchain/langchain_classic/chains/structured_output/base.py at line 450.
What does _create_openai_tools_runnable() call?
_create_openai_tools_runnable() calls 1 function(s): _get_openai_tool_output_parser.
What calls _create_openai_tools_runnable()?
_create_openai_tools_runnable() is called by 1 function(s): create_structured_output_runnable.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free