Error when using a custom Pydantic class for structured output with Langchain

I’m trying to build a chain which will chunk a long PDF document (currently loaded in as markdown). I have the following Pydantic classes created.

from langchain.pydantic_v1 import BaseModel, Field
from typing import List

class HeaderSection(BaseModel):
    """Class to save a section header and text from the section"""

    header: str = Field(description="Header of a section from the document.")
    text: str = Field(description="Text under the associated header.")


class AllSections(BaseModel):   

    sections: List[HeaderSection]

I then have this code chunk setting the structured output.

from langchain_anthropic import ChatAnthropic

# llm = ChatOpenAI(temperature=0, model_name="gpt-4o")
llm = ChatAnthropic(model="claude-3-5-sonnet-20240620")
structured_json_output = llm.with_structured_output(AllSections)

system = """You are tasked with splitting up a document into sections. These sections all have headers, which is how you will determine where to split all of the data.
Return the header in the "header" field of the HeaderSection class. The text that comes below the header, return the text as part of the "text" field of the HeaderSection class. 
You will be given the input text, and the headers.
Here's an example on how a chunk of data will be stored.

EXAMPLE TEXT:
# Bill of Lading and Driver Signature

Item 6

The signature of a Carrier Freight Driver/Sales Representative on any Bill of Lading other than a Carrier’s Bill of Lading will act only to acknowledge the receipt of freight as described on the document. This signature will not acknowledge agreement to any terms and conditions of carriage and/or liability conditions that may also appear on the document. Unless there is a written agreement, separate from the Bill of Lading, signed by shipper and Carrier, then the Carrier Freight Bill of Lading Terms and Conditions will apply.

EXAMPLE OUTPUT:
HeaderSection(header="Bill of Lading and Driver Signature Item 6", text="The signature of a Carrier Freight Driver/Sales Representative on any Bill of Lading other than a Carrier’s Bill of Lading will act only to acknowledge the receipt of freight as described on the document. This signature will not acknowledge agreement to any terms and conditions of carriage and/or liability conditions that may also appear on the document. Unless there is a written agreement, separate from the Bill of Lading, signed by shipper and Carrier, then the Carrier Freight Bill of Lading Terms and Conditions will apply.")

NOTE: The item number may not always be present.
"""

prompt = ChatPromptTemplate.from_messages(
    [
        ("system", system),
        ("human", "Headers: {headers}nnText: {text}")
    ]
)

chunking_chain = prompt | structured_json_output
output = chunking_chain.invoke({"headers": llama_parse_headers_and_items, "text": llama_data_md[0].text})

And receive this error

ValidationError: 1 validation error for AllSections
sections
  field required (type=value_error.missing)

When I set the HeaderSection class as the structured output class, it works and returns one section, but I need it to return all of the sections, which is why I’m trying to use AllSections class, which is suppose to have a list of HeaderSection. Any idea what this error means in this context, and how I can get this to run?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật