'blonde'},     {'person_name': 'Claudia',      'person_height': 6,      'person_hair_color': 'brunette'},     {'dog_name': 'Willow',      'dog_breed': 'German Shepherd',      'dog_extra_info': 'likes to play with other dogs'},     {'dog_name': 'Milo',      'dog_breed': 'border collie',      'dog_extra_info': 'lives close by'}]This gives us additional information about the dogs.Pydantic‚ÄãPydantic is a data validation and settings management library for Python. It allows you to create data classes with attributes that are automatically validated when you instantiate an object.Lets define a class with attributes annotated with types.from typing import Optionalfrom langchain.pydantic_v1 import BaseModelfrom langchain.chains import create_extraction_chain_pydantic# Pydantic data classclass Properties(BaseModel):    person_name: str    person_height: int    person_hair_color: str    dog_breed: Optional[str]    dog_name: Optional[str]        # Extractionchain = create_extraction_chain_pydantic(pydantic_schema=Properties, llm=llm)# Run inp = """Alex is 5 feet tall. Claudia is 1 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde."""chain.run(inp)    [Properties(person_name='Alex', person_height=5, person_hair_color='blonde', dog_breed=None, dog_name=None),     Properties(person_name='Claudia', person_height=6, person_hair_color='brunette', dog_breed=None, dog_name=None)]As we can see from the trace, we use the function information_extraction, as above, with the Pydantic schema. Option 2: Parsing‚ÄãOutput parsers are classes that help structure language model responses. As shown above, they are used to parse the output of the OpenAI function calls in create_extraction_chain.But, they can be used independent of functions.Pydantic‚ÄãJust as a above, let's parse a generation based on a Pydantic data class.from typing import Sequence, Optionalfrom langchain.prompts import (    PromptTemplate,    ChatPromptTemplate,
Open In Collab
Open In Collab ->: 'blonde'},     {'person_name': 'Claudia',      'person_height': 6,      'person_hair_color': 'brunette'},     {'dog_name': 'Willow',      'dog_breed': 'German Shepherd',      'dog_extra_info': 'likes to play with other dogs'},     {'dog_name': 'Milo',      'dog_breed': 'border collie',      'dog_extra_info': 'lives close by'}]This gives us additional information about the dogs.Pydantic‚ÄãPydantic is a data validation and settings management library for Python. It allows you to create data classes with attributes that are automatically validated when you instantiate an object.Lets define a class with attributes annotated with types.from typing import Optionalfrom langchain.pydantic_v1 import BaseModelfrom langchain.chains import create_extraction_chain_pydantic# Pydantic data classclass Properties(BaseModel):    person_name: str    person_height: int    person_hair_color: str    dog_breed: Optional[str]    dog_name: Optional[str]        # Extractionchain = create_extraction_chain_pydantic(pydantic_schema=Properties, llm=llm)# Run inp = """Alex is 5 feet tall. Claudia is 1 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde."""chain.run(inp)    [Properties(person_name='Alex', person_height=5, person_hair_color='blonde', dog_breed=None, dog_name=None),     Properties(person_name='Claudia', person_height=6, person_hair_color='brunette', dog_breed=None, dog_name=None)]As we can see from the trace, we use the function information_extraction, as above, with the Pydantic schema. Option 2: Parsing‚ÄãOutput parsers are classes that help structure language model responses. As shown above, they are used to parse the output of the OpenAI function calls in create_extraction_chain.But, they can be used independent of functions.Pydantic‚ÄãJust as a above, let's parse a generation based on a Pydantic data class.from typing import Sequence, Optionalfrom langchain.prompts import (    PromptTemplate,    ChatPromptTemplate,