Repository navigation
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
Conversation
… 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>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).Changes
submit_document(outline_structure=): "flat" (the default, $1 per 1,000 pages) or "hierarchical" ($2). With it,wait=Truealso waits for the outline and raises if it could not be built; without it,wait=Truewaits for the pages only, as before. Withmode="flash", and in local mode, it raises.build_outline(doc_id, outline_structure=None, wait=True, timeout=1800.0)isbuild_outline_index()under a name that pairs withget_outline(). Withoutline_structureit 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 indexcompleted. A document uploaded withmode="flash"has no outline, so the one named replaces its tree, on a build or when its file is uploaded again withoutline_structure; the docstrings say so.build_outline_index()still works, with a DeprecationWarning that names no removal version. Renamed as the warning says, a positionalbuild_outline_index(doc_id, False)becomesbuild_outline(doc_id, False): anyoutline_structuregiven is sent, so it raises the server's 422 rather than waiting.get_outline(doc_id)returns the server's answer: the headings underresult,outline_structurebeside it. A document with no outline raises, asget_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.Not in this PR
PageSearchClientandPageExtractClientuploads take nooutline_structure.Verification
pytest testslocally: 1285 passed, 7 skipped. The 2 failures are the LiteLLM version tests, which fail with the local LiteLLM 1.105.3, below the floor.outline_structure="flat"charged 0.3 credit and one with"hierarchical"0.6, andwait=Truereturned 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"withoutline_structureraised.outline_structure="hierarchical"returned with a hierarchical outline whose headings carry alevel, andbuild_outline(doc_id, "hierarchical")on it charged 0.