person's favorite food")# If we pass in a model explicitly, we need to make sure it supports the OpenAI function-calling API.llm = ChatOpenAI(model="gpt-4", temperature=0)prompt = ChatPromptTemplate.from_messages(    [        ("system", "You are a world class algorithm for extracting information in structured formats."),        ("human", "Use the given format to extract information from the following input: {input}"),        ("human", "Tip: Make sure to answer in the correct format"),    ])chain = create_structured_output_chain(Person, llm, prompt, verbose=True)chain.run("Sally is 13")            > Entering new LLMChain chain...    Prompt after formatting:    System: You are a world class algorithm for extracting information in structured formats.    Human: Use the given format to extract information from the following input: Sally is 13    Human: Tip: Make sure to answer in the correct format        > Finished chain.    Person(name='Sally', age=13, fav_food='Unknown')To extract arbitrarily many structured outputs of a given format, we can just create a wrapper Pydantic class  that takes a sequence of the original class.from typing import Sequenceclass People(BaseModel):    """Identifying information about all people in a text."""    people: Sequence[Person] = Field(..., description="The people in the text")chain = create_structured_output_chain(People, llm, prompt, verbose=True)chain.run(    "Sally is 13, Joey just turned 12 and loves spinach. Caroline is 10 years older than Sally.")            > Entering new LLMChain chain...    Prompt after formatting:    System: You are a world class algorithm for extracting information in structured formats.    Human: Use the given format to extract information from the following input: Sally is 13, Joey just turned 12 and loves spinach. Caroline is 10 years older than Sally.    Human: Tip: Make sure to answer in the correct format        > Finished chain.    People(people=[Person(name='Sally', age=13, fav_food=''),
This walkthrough demonstrates how to incorporate OpenAI function-calling API's in a chain. We'll go over:
This walkthrough demonstrates how to incorporate OpenAI function-calling API's in a chain. We'll go over: ->: person's favorite food")# If we pass in a model explicitly, we need to make sure it supports the OpenAI function-calling API.llm = ChatOpenAI(model="gpt-4", temperature=0)prompt = ChatPromptTemplate.from_messages(    [        ("system", "You are a world class algorithm for extracting information in structured formats."),        ("human", "Use the given format to extract information from the following input: {input}"),        ("human", "Tip: Make sure to answer in the correct format"),    ])chain = create_structured_output_chain(Person, llm, prompt, verbose=True)chain.run("Sally is 13")            > Entering new LLMChain chain...    Prompt after formatting:    System: You are a world class algorithm for extracting information in structured formats.    Human: Use the given format to extract information from the following input: Sally is 13    Human: Tip: Make sure to answer in the correct format        > Finished chain.    Person(name='Sally', age=13, fav_food='Unknown')To extract arbitrarily many structured outputs of a given format, we can just create a wrapper Pydantic class  that takes a sequence of the original class.from typing import Sequenceclass People(BaseModel):    """Identifying information about all people in a text."""    people: Sequence[Person] = Field(..., description="The people in the text")chain = create_structured_output_chain(People, llm, prompt, verbose=True)chain.run(    "Sally is 13, Joey just turned 12 and loves spinach. Caroline is 10 years older than Sally.")            > Entering new LLMChain chain...    Prompt after formatting:    System: You are a world class algorithm for extracting information in structured formats.    Human: Use the given format to extract information from the following input: Sally is 13, Joey just turned 12 and loves spinach. Caroline is 10 years older than Sally.    Human: Tip: Make sure to answer in the correct format        > Finished chain.    People(people=[Person(name='Sally', age=13, fav_food=''),