create_extraction_chain_pydantic() — langchain Function Reference
Architecture documentation for the create_extraction_chain_pydantic() function in extraction.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 0622a926_0311_09ad_7d31_76d9fefd00c8["create_extraction_chain_pydantic()"] 27fd0e59_ecb6_fb2c_cb48_5edb780dc106["extraction.py"] 0622a926_0311_09ad_7d31_76d9fefd00c8 -->|defined in| 27fd0e59_ecb6_fb2c_cb48_5edb780dc106 style 0622a926_0311_09ad_7d31_76d9fefd00c8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/openai_tools/extraction.py lines 53–79
def create_extraction_chain_pydantic(
pydantic_schemas: list[type[BaseModel]] | type[BaseModel],
llm: BaseLanguageModel,
system_message: str = _EXTRACTION_TEMPLATE,
) -> Runnable:
"""Creates a chain that extracts information from a passage.
Args:
pydantic_schemas: The schema of the entities to extract.
llm: The language model to use.
system_message: The system message to use for extraction.
Returns:
A runnable that extracts information from a passage.
"""
if not isinstance(pydantic_schemas, list):
pydantic_schemas = [pydantic_schemas]
prompt = ChatPromptTemplate.from_messages(
[
("system", system_message),
("user", "{input}"),
],
)
functions = [convert_pydantic_to_openai_function(p) for p in pydantic_schemas]
tools = [{"type": "function", "function": d} for d in functions]
model = llm.bind(tools=tools)
return prompt | model | PydanticToolsParser(tools=pydantic_schemas)
Domain
Subdomains
Source
Frequently Asked Questions
What does create_extraction_chain_pydantic() do?
create_extraction_chain_pydantic() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/openai_tools/extraction.py.
Where is create_extraction_chain_pydantic() defined?
create_extraction_chain_pydantic() is defined in libs/langchain/langchain_classic/chains/openai_tools/extraction.py at line 53.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free