},
                "required": ["info"],
            },
        }
    ]
def _get_tagging_functions(schema: dict) -> List[dict]:
    return [
        {
            "name": EXTRACTION_NAME,
            "description": "Extracts the relevant information from the passage.",
            "parameters": _convert_schema(schema),
        }
    ]
_EXTRACTION_TEMPLATE = """Extract and save the relevant entities mentioned\
 in the following passage together with their properties.
Passage:
{input}
"""
[docs]def create_extraction_chain(schema: dict, llm: BaseLanguageModel) -> Chain:
    functions = _get_extraction_functions(schema)
    prompt = ChatPromptTemplate.from_template(_EXTRACTION_TEMPLATE)
    chain = OpenAIFunctionsChain(
        llm=llm, prompt=prompt, functions=functions, kwargs=EXTRACTION_KWARGS
    )
    parsing_chain = TransformChain(
        transform=_parse_entities,
        input_variables=["input"],
        output_variables=["output"],
    )
    return SimpleSequentialChain(chains=[chain, parsing_chain])
[docs]def create_extraction_chain_pydantic(
    pydantic_schema: Any, llm: BaseLanguageModel
) -> Chain:
    class PydanticSchema(BaseModel):
        info: List[pydantic_schema]  # type: ignore
    openai_schema = PydanticSchema.schema()
    openai_schema = _resolve_schema_references(
        openai_schema, openai_schema["definitions"]
    )
    functions = _get_extraction_functions(openai_schema)
    prompt = ChatPromptTemplate.from_template(_EXTRACTION_TEMPLATE)
    chain = OpenAIFunctionsChain(
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/chains/openai_functions.html