create_extraction_chain() — langchain Function Reference
Architecture documentation for the create_extraction_chain() function in extraction.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ed29345b_184d_c631_895a_47d9341de245["create_extraction_chain()"] f3ae89de_9c39_fe1b_3ede_79ea9e0ed4fe["extraction.py"] ed29345b_184d_c631_895a_47d9341de245 -->|defined in| f3ae89de_9c39_fe1b_3ede_79ea9e0ed4fe d96ba5e6_9d3c_8107_e3e7_4c1c7394f868["_get_extraction_function()"] ed29345b_184d_c631_895a_47d9341de245 -->|calls| d96ba5e6_9d3c_8107_e3e7_4c1c7394f868 style ed29345b_184d_c631_895a_47d9341de245 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/openai_functions/extraction.py lines 76–107
def create_extraction_chain(
schema: dict,
llm: BaseLanguageModel,
prompt: BasePromptTemplate | None = None,
tags: list[str] | None = None,
verbose: bool = False, # noqa: FBT001,FBT002
) -> Chain:
"""Creates a chain that extracts information from a passage.
Args:
schema: The schema of the entities to extract.
llm: The language model to use.
prompt: The prompt to use for extraction.
tags: Optional list of tags to associate with the chain.
verbose: Whether to run in verbose mode. In verbose mode, some intermediate
logs will be printed to the console.
Returns:
Chain that can be used to extract information from a passage.
"""
function = _get_extraction_function(schema)
extraction_prompt = prompt or ChatPromptTemplate.from_template(_EXTRACTION_TEMPLATE)
output_parser = JsonKeyOutputFunctionsParser(key_name="info")
llm_kwargs = get_llm_kwargs(function)
return LLMChain(
llm=llm,
prompt=extraction_prompt,
llm_kwargs=llm_kwargs,
output_parser=output_parser,
tags=tags,
verbose=verbose,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does create_extraction_chain() do?
create_extraction_chain() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/openai_functions/extraction.py.
Where is create_extraction_chain() defined?
create_extraction_chain() is defined in libs/langchain/langchain_classic/chains/openai_functions/extraction.py at line 76.
What does create_extraction_chain() call?
create_extraction_chain() calls 1 function(s): _get_extraction_function.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free