langchain-section-anything
A LangChain document loader for Section Anything:
it finds the sections of a PDF (every heading, its level, its pages and its exact text) and
returns one Document per section, with the heading path in the metadata. The default mode
runs locally with rules only, calls no model and costs nothing.
Install
pip install langchain-section-anything
# latest from GitHub:
pip install "git+https://github.com/Omniwot/section-anything#subdirectory=packages/langchain-section-anything"
Python 3.11+. Depends on section-anything and langchain-core only.
Example
from langchain_section_anything import SectionAnythingLoader
loader = SectionAnythingLoader("paper.pdf") # mode="free": rules only, no model, $0
docs = loader.load() # or loader.lazy_load(), await loader.aload()
doc = docs[2]
print(doc.page_content[:59]) # '### 1.1 Scope\n\nSectioning splits a long document into parts'
print(doc.metadata["heading_path"]) # ['1 Introduction', '1.1 Scope']
print(doc.metadata["page_start"], doc.metadata["page_end"]) # 1 1
Sections vary in length; to cap chunk size, split the Documents further (for example with
RecursiveCharacterTextSplitter.split_documents), which keeps the metadata on every chunk.
Options
SectionAnythingLoader(file_path, mode="free", *, include_heading=True, **opts)
file_path: a path, or a list of paths.mode:free(bookmarks, table of contents and typography rules; nothing leaves the machine),quick(a small model reviews candidate heading lines, about $0.07 per 1,000 pages),standard(a model reads every line) orlocal:<ollama model>. Over the per-document cost cap (default $0.50) a run is downgraded (standard → quick → free) or refused.include_heading: start each Document with its heading as a Markdown line (## 1 Introduction). WithFalse, sections with no text of their own (a heading directly followed by a subheading) are skipped.**optsgo tosection_anything.section:api_key,base_url,model,max_usd,prices,over_budget,max_pages,extract_timeout,progress,settings. Anything not given falls back to theSECTIONANY_*environment variables; see the library README. Keys are never logged or put in metadata.
Text and metadata
A Document's text is the section's own text, from its heading to the next heading, reflowed into
paragraphs with running headers and footers removed (the same text as section-anything --body).
Text before the first heading is a Document of its own (flag front_matter).
| Key | Meaning |
|---|---|
source |
the PDF path |
section_index |
position in the document's section list (0-based) |
title, number, level |
heading text, numbering as printed ("3.1" or ""), 1 = top level |
heading_path |
list of headings from the outermost section down to this one |
page_start, page_end |
1-based pages |
start, end |
character range in the library's extracted text |
flags |
for example doc_title, front_matter, generated_title |
document_title |
the document's title, if found |
mode, model, document_cost_usd |
how the document was sectioned (after any downgrade) and what the whole document cost |
heading_path and flags are lists. For a vector store that accepts only scalar metadata, join
them (" > ".join(...)) or drop them with filter_complex_metadata from
langchain_community.vectorstores.utils before indexing.
Licence
Apache-2.0. See LICENSE and NOTICE.
Metadata
Release files for langchain-section-anything 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_section_anything-0.1.0.tar.gz | 13.6 kB | With provenance | Details for langchain_section_anything-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_section_anything-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_section_anything-0.1.0-py3-none-any.whl |
Total release size: 25.5 kB
Release files / langchain_section_anything-0.1.0.tar.gz
| Download URL | langchain_section_anything-0.1.0.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
652dc93595f18d949962f510c2e3f797defd1e03f27d659c241fe766716d0dcf
|
|
BLAKE2b-256 checksum How to use checksums |
1fa1da45459110a4cd802fe56105410c63457c5560d31ef2ed2e67123e417aa1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / langchain_section_anything-0.1.0-py3-none-any.whl
| Download URL | langchain_section_anything-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
043df80699c832fe100a8175a09e80c06130162f10e260825d698446a6c22144
|
|
BLAKE2b-256 checksum How to use checksums |
4e6a045d52c6ab98dbf88bb90b491aa93cfa5f45409d090b8b514ecd302b29b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logSecurity for langchain-section-anything 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for langchain_section_anything-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.