"""
chain = create_extraction_chain(schema, llm)
As we can see, we extracted the required entities and their properties in the required format:
chain.run(inp)
[{'person_name': 'Alex',
  'person_height': 5,
  'person_hair_color': 'blonde',
  'dog_name': 'Frosty',
  'dog_breed': 'labrador'},
 {'person_name': 'Claudia',
  'person_height': 9,
  'person_hair_color': 'brunette',
  'dog_name': '',
  'dog_breed': ''}]
Pydantic example#
We can also use a Pydantic schema to choose the required properties and types and we will set as ‘Optional’ those that are not strictly required.
By using the create_extraction_chain_pydantic function, we can send a Pydantic schema as input and the output will be an instantiated object that respects our desired schema.
In this way, we can specify our schema in the same manner that we would a new class or function in Python - with purely Pythonic types.
from typing import Optional, List
from pydantic import BaseModel, Field
class Properties(BaseModel):
    person_name: str
    person_height: int
    person_hair_color: str
    dog_breed: Optional[str]
    dog_name: Optional[str]
chain = create_extraction_chain_pydantic(pydantic_schema=Properties, llm=llm)
inp = """
Alex is 5 feet tall. Claudia is 4 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde.
Alex's dog Frosty is a labrador and likes to play hide and seek.
        """
chain.run(inp)
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/extraction.html