Skip to content

Commit c60456e

Browse files
author
stlc-bot
committed
feat(parse): mark PDF page numbers inline in Markdown with includeNumberedPages (#2110)
Stainless-Generated-From: c6f2cab97c087cf0c5313bcd4fe40c47acccc2d9
1 parent de365f8 commit c60456e

12 files changed

Lines changed: 146 additions & 5 deletions

File tree

‎lib/context_dev/models/batch_submit_params.rb‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,15 @@ class Pdf < ContextDev::Internal::Type::BaseModel
13511351
# @return [Integer, nil]
13521352
optional :end_page, Integer, api_name: :endPage
13531353

1354+
# @!attribute include_numbered_pages
1355+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
1356+
# 1-based page number; these responses are never served from cache.
1357+
#
1358+
# @return [Boolean, nil]
1359+
optional :include_numbered_pages,
1360+
ContextDev::Internal::Type::Boolean,
1361+
api_name: :includeNumberedPages
1362+
13541363
# @!attribute ocr
13551364
# Set `auto` to read scanned pages with OCR.
13561365
#
@@ -1364,11 +1373,17 @@ class Pdf < ContextDev::Internal::Type::BaseModel
13641373
# @return [Integer, nil]
13651374
optional :start_page, Integer, api_name: :startPage
13661375

1367-
# @!method initialize(end_page: nil, ocr: nil, start_page: nil)
1376+
# @!method initialize(end_page: nil, include_numbered_pages: nil, ocr: nil, start_page: nil)
1377+
# Some parameter documentations has been truncated, see
1378+
# {ContextDev::Models::BatchSubmitParams::Input::Scrape::Data::SharedParams::Parsers::Pdf}
1379+
# for more details.
1380+
#
13681381
# PDF page range and OCR.
13691382
#
13701383
# @param end_page [Integer] Last page to parse. Must be at least `startPage`.
13711384
#
1385+
# @param include_numbered_pages [Boolean] Start each page in the Markdown with a `<!-- page N -->` line using its original
1386+
#
13721387
# @param ocr [Symbol, ContextDev::Models::BatchSubmitParams::Input::Scrape::Data::SharedParams::Parsers::Pdf::Ocr] Set `auto` to read scanned pages with OCR.
13731388
#
13741389
# @param start_page [Integer] First page to parse, starting at 1.
@@ -3120,6 +3135,15 @@ class Pdf < ContextDev::Internal::Type::BaseModel
31203135
# @return [Integer, nil]
31213136
optional :end_page, Integer, api_name: :endPage
31223137

3138+
# @!attribute include_numbered_pages
3139+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
3140+
# 1-based page number; these responses are never served from cache.
3141+
#
3142+
# @return [Boolean, nil]
3143+
optional :include_numbered_pages,
3144+
ContextDev::Internal::Type::Boolean,
3145+
api_name: :includeNumberedPages
3146+
31233147
# @!attribute ocr
31243148
# Set `auto` to read scanned pages with OCR.
31253149
#
@@ -3133,11 +3157,17 @@ class Pdf < ContextDev::Internal::Type::BaseModel
31333157
# @return [Integer, nil]
31343158
optional :start_page, Integer, api_name: :startPage
31353159

3136-
# @!method initialize(end_page: nil, ocr: nil, start_page: nil)
3160+
# @!method initialize(end_page: nil, include_numbered_pages: nil, ocr: nil, start_page: nil)
3161+
# Some parameter documentations has been truncated, see
3162+
# {ContextDev::Models::BatchSubmitParams::Input::Crawl::Data::SharedParams::Parsers::Pdf}
3163+
# for more details.
3164+
#
31373165
# PDF page range and OCR.
31383166
#
31393167
# @param end_page [Integer] Last page to parse. Must be at least `startPage`.
31403168
#
3169+
# @param include_numbered_pages [Boolean] Start each page in the Markdown with a `<!-- page N -->` line using its original
3170+
#
31413171
# @param ocr [Symbol, ContextDev::Models::BatchSubmitParams::Input::Crawl::Data::SharedParams::Parsers::Pdf::Ocr] Set `auto` to read scanned pages with OCR.
31423172
#
31433173
# @param start_page [Integer] First page to parse, starting at 1.

‎lib/context_dev/models/parse_handle_params.rb‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ class ParseHandleParams < ContextDev::Internal::Type::BaseModel
3737
# @return [Boolean, nil]
3838
optional :include_links, ContextDev::Internal::Type::Boolean
3939

40+
# @!attribute include_numbered_pages
41+
# Start each PDF page in the Markdown with a `<!-- page N -->` line, where N is
42+
# the original 1-based page number.
43+
#
44+
# @return [Boolean, nil]
45+
optional :include_numbered_pages, ContextDev::Internal::Type::Boolean
46+
4047
# @!attribute ocr
4148
# Read text from images and scanned PDF pages. PDF page ranges still apply.
4249
#
@@ -74,7 +81,7 @@ class ParseHandleParams < ContextDev::Internal::Type::BaseModel
7481
# @return [Symbol, ContextDev::Models::ParseHandleParams::Zdr, nil]
7582
optional :zdr, enum: -> { ContextDev::ParseHandleParams::Zdr }
7683

77-
# @!method initialize(body:, client: nil, extension: nil, include_images: nil, include_links: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, tags: nil, use_main_content_only: nil, zdr: nil, request_options: {})
84+
# @!method initialize(body:, client: nil, extension: nil, include_images: nil, include_links: nil, include_numbered_pages: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, tags: nil, use_main_content_only: nil, zdr: nil, request_options: {})
7885
# Some parameter documentations has been truncated, see
7986
# {ContextDev::Models::ParseHandleParams} for more details.
8087
#
@@ -88,6 +95,8 @@ class ParseHandleParams < ContextDev::Internal::Type::BaseModel
8895
#
8996
# @param include_links [Boolean] Preserve hyperlinks in Markdown output
9097
#
98+
# @param include_numbered_pages [Boolean] Start each PDF page in the Markdown with a `<!-- page N -->` line, where N is th
99+
#
91100
# @param ocr [Boolean] Read text from images and scanned PDF pages. PDF page ranges still apply.
92101
#
93102
# @param pdf [ContextDev::Models::ParseHandleParams::Pdf] PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5}.

‎lib/context_dev/models/web_scrape_params.rb‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,15 @@ class Pdf < ContextDev::Internal::Type::BaseModel
11831183
# @return [Integer, nil]
11841184
optional :end_page, Integer, api_name: :endPage
11851185

1186+
# @!attribute include_numbered_pages
1187+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
1188+
# 1-based page number; these responses are never served from cache.
1189+
#
1190+
# @return [Boolean, nil]
1191+
optional :include_numbered_pages,
1192+
ContextDev::Internal::Type::Boolean,
1193+
api_name: :includeNumberedPages
1194+
11861195
# @!attribute ocr
11871196
# Set `auto` to read scanned pages with OCR.
11881197
#
@@ -1195,11 +1204,17 @@ class Pdf < ContextDev::Internal::Type::BaseModel
11951204
# @return [Integer, nil]
11961205
optional :start_page, Integer, api_name: :startPage
11971206

1198-
# @!method initialize(end_page: nil, ocr: nil, start_page: nil)
1207+
# @!method initialize(end_page: nil, include_numbered_pages: nil, ocr: nil, start_page: nil)
1208+
# Some parameter documentations has been truncated, see
1209+
# {ContextDev::Models::WebScrapeParams::SharedParams::Parsers::Pdf} for more
1210+
# details.
1211+
#
11991212
# PDF page range and OCR.
12001213
#
12011214
# @param end_page [Integer] Last page to parse. Must be at least `startPage`.
12021215
#
1216+
# @param include_numbered_pages [Boolean] Start each page in the Markdown with a `<!-- page N -->` line using its original
1217+
#
12031218
# @param ocr [Symbol, ContextDev::Models::WebScrapeParams::SharedParams::Parsers::Pdf::Ocr] Set `auto` to read scanned pages with OCR.
12041219
#
12051220
# @param start_page [Integer] First page to parse, starting at 1.

‎lib/context_dev/resources/parse.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Parse
88
#
99
# Convert uploaded file bytes into Markdown and optional HTML.
1010
#
11-
# @overload handle(body:, client: nil, extension: nil, include_images: nil, include_links: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, tags: nil, use_main_content_only: nil, zdr: nil, request_options: {})
11+
# @overload handle(body:, client: nil, extension: nil, include_images: nil, include_links: nil, include_numbered_pages: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, tags: nil, use_main_content_only: nil, zdr: nil, request_options: {})
1212
#
1313
# @param body [Pathname, StringIO, IO, String, ContextDev::FilePart] Body param
1414
#
@@ -20,6 +20,8 @@ class Parse
2020
#
2121
# @param include_links [Boolean] Query param: Preserve hyperlinks in Markdown output
2222
#
23+
# @param include_numbered_pages [Boolean] Query param: Start each PDF page in the Markdown with a `<!-- page N -->` line,
24+
#
2325
# @param ocr [Boolean] Query param: Read text from images and scanned PDF pages. PDF page ranges still
2426
#
2527
# @param pdf [ContextDev::Models::ParseHandleParams::Pdf] Query param: PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5

‎rbi/context_dev/models/batch_submit_params.rbi‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,6 +2965,14 @@ module ContextDev
29652965
sig { params(end_page: Integer).void }
29662966
attr_writer :end_page
29672967

2968+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
2969+
# 1-based page number; these responses are never served from cache.
2970+
sig { returns(T.nilable(T::Boolean)) }
2971+
attr_reader :include_numbered_pages
2972+
2973+
sig { params(include_numbered_pages: T::Boolean).void }
2974+
attr_writer :include_numbered_pages
2975+
29682976
# Set `auto` to read scanned pages with OCR.
29692977
sig do
29702978
returns(
@@ -2994,6 +3002,7 @@ module ContextDev
29943002
sig do
29953003
params(
29963004
end_page: Integer,
3005+
include_numbered_pages: T::Boolean,
29973006
ocr:
29983007
ContextDev::BatchSubmitParams::Input::Scrape::Data::SharedParams::Parsers::Pdf::Ocr::OrSymbol,
29993008
start_page: Integer
@@ -3002,6 +3011,9 @@ module ContextDev
30023011
def self.new(
30033012
# Last page to parse. Must be at least `startPage`.
30043013
end_page: nil,
3014+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
3015+
# 1-based page number; these responses are never served from cache.
3016+
include_numbered_pages: nil,
30053017
# Set `auto` to read scanned pages with OCR.
30063018
ocr: nil,
30073019
# First page to parse, starting at 1.
@@ -3013,6 +3025,7 @@ module ContextDev
30133025
override.returns(
30143026
{
30153027
end_page: Integer,
3028+
include_numbered_pages: T::Boolean,
30163029
ocr:
30173030
ContextDev::BatchSubmitParams::Input::Scrape::Data::SharedParams::Parsers::Pdf::Ocr::OrSymbol,
30183031
start_page: Integer
@@ -7003,6 +7016,14 @@ module ContextDev
70037016
sig { params(end_page: Integer).void }
70047017
attr_writer :end_page
70057018

7019+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
7020+
# 1-based page number; these responses are never served from cache.
7021+
sig { returns(T.nilable(T::Boolean)) }
7022+
attr_reader :include_numbered_pages
7023+
7024+
sig { params(include_numbered_pages: T::Boolean).void }
7025+
attr_writer :include_numbered_pages
7026+
70067027
# Set `auto` to read scanned pages with OCR.
70077028
sig do
70087029
returns(
@@ -7032,6 +7053,7 @@ module ContextDev
70327053
sig do
70337054
params(
70347055
end_page: Integer,
7056+
include_numbered_pages: T::Boolean,
70357057
ocr:
70367058
ContextDev::BatchSubmitParams::Input::Crawl::Data::SharedParams::Parsers::Pdf::Ocr::OrSymbol,
70377059
start_page: Integer
@@ -7040,6 +7062,9 @@ module ContextDev
70407062
def self.new(
70417063
# Last page to parse. Must be at least `startPage`.
70427064
end_page: nil,
7065+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
7066+
# 1-based page number; these responses are never served from cache.
7067+
include_numbered_pages: nil,
70437068
# Set `auto` to read scanned pages with OCR.
70447069
ocr: nil,
70457070
# First page to parse, starting at 1.
@@ -7051,6 +7076,7 @@ module ContextDev
70517076
override.returns(
70527077
{
70537078
end_page: Integer,
7079+
include_numbered_pages: T::Boolean,
70547080
ocr:
70557081
ContextDev::BatchSubmitParams::Input::Crawl::Data::SharedParams::Parsers::Pdf::Ocr::OrSymbol,
70567082
start_page: Integer

‎rbi/context_dev/models/parse_handle_params.rbi‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ module ContextDev
4949
sig { params(include_links: T::Boolean).void }
5050
attr_writer :include_links
5151

52+
# Start each PDF page in the Markdown with a `<!-- page N -->` line, where N is
53+
# the original 1-based page number.
54+
sig { returns(T.nilable(T::Boolean)) }
55+
attr_reader :include_numbered_pages
56+
57+
sig { params(include_numbered_pages: T::Boolean).void }
58+
attr_writer :include_numbered_pages
59+
5260
# Read text from images and scanned PDF pages. PDF page ranges still apply.
5361
sig { returns(T.nilable(T::Boolean)) }
5462
attr_reader :ocr
@@ -99,6 +107,7 @@ module ContextDev
99107
extension: ContextDev::ParseHandleParams::Extension::OrSymbol,
100108
include_images: T::Boolean,
101109
include_links: T::Boolean,
110+
include_numbered_pages: T::Boolean,
102111
ocr: T::Boolean,
103112
pdf: ContextDev::ParseHandleParams::Pdf::OrHash,
104113
shorten_base64_images: T::Boolean,
@@ -119,6 +128,9 @@ module ContextDev
119128
include_images: nil,
120129
# Preserve hyperlinks in Markdown output
121130
include_links: nil,
131+
# Start each PDF page in the Markdown with a `<!-- page N -->` line, where N is
132+
# the original 1-based page number.
133+
include_numbered_pages: nil,
122134
# Read text from images and scanned PDF pages. PDF page ranges still apply.
123135
ocr: nil,
124136
# PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5}.
@@ -144,6 +156,7 @@ module ContextDev
144156
extension: ContextDev::ParseHandleParams::Extension::OrSymbol,
145157
include_images: T::Boolean,
146158
include_links: T::Boolean,
159+
include_numbered_pages: T::Boolean,
147160
ocr: T::Boolean,
148161
pdf: ContextDev::ParseHandleParams::Pdf,
149162
shorten_base64_images: T::Boolean,

‎rbi/context_dev/models/web_scrape_params.rbi‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,14 @@ module ContextDev
25892589
sig { params(end_page: Integer).void }
25902590
attr_writer :end_page
25912591

2592+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
2593+
# 1-based page number; these responses are never served from cache.
2594+
sig { returns(T.nilable(T::Boolean)) }
2595+
attr_reader :include_numbered_pages
2596+
2597+
sig { params(include_numbered_pages: T::Boolean).void }
2598+
attr_writer :include_numbered_pages
2599+
25922600
# Set `auto` to read scanned pages with OCR.
25932601
sig do
25942602
returns(
@@ -2618,6 +2626,7 @@ module ContextDev
26182626
sig do
26192627
params(
26202628
end_page: Integer,
2629+
include_numbered_pages: T::Boolean,
26212630
ocr:
26222631
ContextDev::WebScrapeParams::SharedParams::Parsers::Pdf::Ocr::OrSymbol,
26232632
start_page: Integer
@@ -2626,6 +2635,9 @@ module ContextDev
26262635
def self.new(
26272636
# Last page to parse. Must be at least `startPage`.
26282637
end_page: nil,
2638+
# Start each page in the Markdown with a `<!-- page N -->` line using its original
2639+
# 1-based page number; these responses are never served from cache.
2640+
include_numbered_pages: nil,
26292641
# Set `auto` to read scanned pages with OCR.
26302642
ocr: nil,
26312643
# First page to parse, starting at 1.
@@ -2637,6 +2649,7 @@ module ContextDev
26372649
override.returns(
26382650
{
26392651
end_page: Integer,
2652+
include_numbered_pages: T::Boolean,
26402653
ocr:
26412654
ContextDev::WebScrapeParams::SharedParams::Parsers::Pdf::Ocr::OrSymbol,
26422655
start_page: Integer

‎rbi/context_dev/resources/parse.rbi‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module ContextDev
1111
extension: ContextDev::ParseHandleParams::Extension::OrSymbol,
1212
include_images: T::Boolean,
1313
include_links: T::Boolean,
14+
include_numbered_pages: T::Boolean,
1415
ocr: T::Boolean,
1516
pdf: ContextDev::ParseHandleParams::Pdf::OrHash,
1617
shorten_base64_images: T::Boolean,
@@ -32,6 +33,9 @@ module ContextDev
3233
include_images: nil,
3334
# Query param: Preserve hyperlinks in Markdown output
3435
include_links: nil,
36+
# Query param: Start each PDF page in the Markdown with a `<!-- page N -->` line,
37+
# where N is the original 1-based page number.
38+
include_numbered_pages: nil,
3539
# Query param: Read text from images and scanned PDF pages. PDF page ranges still
3640
# apply.
3741
ocr: nil,

0 commit comments

Comments
 (0)