Skip to content

feat(client): build_outline(doc_id, outline_structure) builds a cloud document's flat or hierarchical outline, get_outline() reads it, and submit_document() names its outline with outline_structure - #708

Merged
rejojer merged 4 commits into
mainfrom
feat/outline-structure
Nov 28, 2026

Conversation

@rejojer

@rejojer rejojer commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

The SDK can now ask for a hierarchical outline, on an upload or for a document already stored, and read an outline back. Until now it built the flat one only. This brings #702 back, reworked to what was settled in #702 (comment).

It sends outline_structure, which Prod reads from pageindex-compute v0.31.1 (VectifyAI/pageindex-compute#1006).

doc = client.submit_document("a.pdf", outline_structure="hierarchical", wait=True)
client.get_outline(doc["doc_id"])["result"]["outline"]
# [{'title': '1 Intro', 'level': 1, 'page': 3}, ...]

client.build_outline(doc_id, outline_structure="hierarchical")  # a stored document

Changes

  • submit_document(outline_structure=): "flat" (the default, $1 per 1,000 pages) or "hierarchical" ($2). With it, wait=True also waits for the outline and raises if it could not be built; without it, wait=True waits for the pages only, as before. With mode="flash", and in local mode, it raises.
  • build_outline(doc_id, outline_structure=None, wait=True, timeout=1800.0) is build_outline_index() under a name that pairs with get_outline(). With outline_structure it makes the document's outline the one named ($1 from flat to hierarchical; an outline the document has is free). After a build it reads the outline and raises unless it is the one asked for, since a failed build keeps the previous outline and leaves the index completed. A document uploaded with mode="flash" has no outline, so the one named replaces its tree, on a build or when its file is uploaded again with outline_structure; the docstrings say so.
  • build_outline_index() still works, with a DeprecationWarning that names no removal version. Renamed as the warning says, a positional build_outline_index(doc_id, False) becomes build_outline(doc_id, False): any outline_structure given is sent, so it raises the server's 422 rather than waiting.
  • get_outline(doc_id) returns the server's answer: the headings under result, outline_structure beside it. A document with no outline raises, as get_tree() does.
  • outline(doc_id, structure) from feat(client): outline(doc_id, structure) returns a cloud document's flat or hierarchical outline, building it when missing #702 is not restored: one function builds and one reads, as in the JS SDK.
  • The first commit reverts revert(client): outline(doc_id, structure) leaves main until its open questions are settled (#702) #705, which restores feat(client): outline(doc_id, structure) returns a cloud document's flat or hierarchical outline, building it when missing #702's code as it was; the second makes the changes above.
  • The Page Search, Page Extract and Page Classify clients' docstrings say "no outline" where they said "no outline index". No behavior changes there.

Not in this PR

  • PageSearchClient and PageExtractClient uploads take no outline_structure.
  • A 409 while another outline is being built is raised as it is, not waited out.

Verification

  • pytest tests locally: 1285 passed, 7 skipped. The 2 failures are the LiteLLM version tests, which fail with the local LiteLLM 1.105.3, below the floor.
  • A live run on Dev through this branch, on 3-page PDFs, 18 checks, all passing: an upload with outline_structure="flat" charged 0.3 credit and one with "hierarchical" 0.6, and wait=True returned with the outline built; the flat file uploaded again with "hierarchical" came back as the same document with a hierarchical outline for 0.3; build_outline(doc_id, "hierarchical") on a flat document charged 0.3, and asking for an outline the document has charged 0; build_outline_index() warned and worked; mode="flash" with outline_structure raised.
  • After pageindex-compute v0.31.1 reached Prod, this branch against Prod: an upload with outline_structure="hierarchical" returned with a hierarchical outline whose headings carry a level, and build_outline(doc_id, "hierarchical") on it charged 0.

rejojer and others added 2 commits November 28, 2026 18:48
…its open questions are settled (#702) (#705)"

This reverts commit d6e9df0.
… document's flat or hierarchical outline, get_outline() reads it, and submit_document() names its outline with outline_structure

A cloud document's outline is flat (headings at one level, $1 per 1,000
pages) or hierarchical (headings nested, each with its level, $2). The SDK
could only build the flat one. Now:

- submit_document(outline_structure="hierarchical") builds the hierarchical
  outline with the upload, once. With it, wait=True also waits for the
  outline and raises if it could not be built; without it, wait=True waits
  for the pages only, as before. mode="flash" with it raises, and so does
  local mode.
- build_outline(doc_id, outline_structure=None) is build_outline_index()
  under a name that pairs with get_outline(). With outline_structure it makes
  the document's outline the one named. After a build it reads the outline
  and raises unless it is the one asked for: a failed build keeps the
  previous outline and leaves the index completed.
- build_outline_index() still works, with a DeprecationWarning.
- get_outline(doc_id) returns the server's answer, the headings under
  result and outline_structure beside it.

outline(doc_id, structure), which #702 added and #705 took back out, is not
restored: build_outline() builds and get_outline() reads, as the JS SDK
splits it. The argument is outline_structure everywhere, as the API now names
it: structure alone does not say outline, and get_document_structure() uses
the word for the tree.

Co-authored-by: Bukely_ <bukely0119@foxmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T14:28:43.583673Z b95a573 New commits
🔒 Security Review ✅ Completed 2026-11-28T14:29:48.119602Z b95a573 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

… say "no outline", as build_outline() and get_outline() name it

Their docstrings said "no outline index", the wording of build_outline_index().
…ild_outline(doc_id, False) raises instead of waiting; its docstrings say a Flash tree is replaced

The deprecation warning sends build_outline_index() callers to
build_outline(), where the second argument is outline_structure, not wait.
build_outline(doc_id, False) then dropped the False as no outline_structure
and waited up to 30 minutes, where build_outline_index(doc_id, False)
returned at once. The body is now sent whenever outline_structure is not
None, as the upload already does, and the server's 422 raises.

A document uploaded with mode="flash" has no outline, so building one, or
uploading its file again with outline_structure, replaces its Flash tree.
build_outline() and submit_document() now say so.
@rejojer
rejojer merged commit 75c7fa2 into main Nov 28, 2026
10 checks passed
rejojer added a commit that referenced this pull request Nov 28, 2026
…_structure (#709)

pyproject.toml carries the version the next tag publishes (#706): 0.8.1, for build_outline(), get_outline() and outline_structure (#708). Tagging v0.8.1 on this commit publishes it to PyPI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant