Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.3.0"
".": "2.4.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 30
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-c90f13e3cf4b9ae6a1d8f22c0e7285ab12d412d3a659a51a247a97adc7f08121.yml
openapi_spec_hash: bf7879be38ebf3397a939c80b261a47a
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-fb56935a194e69348fecd985f7cf8b249795b46af2fb32f6c5c8ef648cf10c15.yml
openapi_spec_hash: 7260a560474283b7ad6ac5d426058ac9
config_hash: daabb160675d86b354711da1e77e5129
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 2.4.0 (2026-07-12)

Full Changelog: [v2.3.0...v2.4.0](https://github.com/context-dot-dev/context-ruby-sdk/compare/v2.3.0...v2.4.0)

### Features

* **api:** api update ([426deb1](https://github.com/context-dot-dev/context-ruby-sdk/commit/426deb18249b214c3ccaa44c1e654e75ef666dd2))

## 2.3.0 (2026-07-12)

Full Changelog: [v2.2.0...v2.3.0](https://github.com/context-dot-dev/context-ruby-sdk/compare/v2.2.0...v2.3.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
context.dev (2.3.0)
context.dev (2.4.0)
cgi
connection_pool

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "context.dev", "~> 2.3.0"
gem "context.dev", "~> 2.4.0"
```

<!-- x-release-please-end -->
Expand Down Expand Up @@ -213,25 +213,25 @@ context_dev.brand.retrieve(**params)
Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:

```ruby
# :light
puts(ContextDev::WebExtractStyleguideParams::ColorScheme::LIGHT)
# :txt
puts(ContextDev::ParseHandleParams::Extension::TXT)

# Revealed type: `T.all(ContextDev::WebExtractStyleguideParams::ColorScheme, Symbol)`
T.reveal_type(ContextDev::WebExtractStyleguideParams::ColorScheme::LIGHT)
# Revealed type: `T.all(ContextDev::ParseHandleParams::Extension, Symbol)`
T.reveal_type(ContextDev::ParseHandleParams::Extension::TXT)
```

Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:

```ruby
# Using the enum constants preserves the tagged type information:
context_dev.web.extract_styleguide(
color_scheme: ContextDev::WebExtractStyleguideParams::ColorScheme::LIGHT,
context_dev.parse.handle(
extension: ContextDev::ParseHandleParams::Extension::TXT,
# …
)

# Literal values are also permissible:
context_dev.web.extract_styleguide(
color_scheme: :light,
context_dev.parse.handle(
extension: :txt,
# …
)
```
Expand Down
168 changes: 126 additions & 42 deletions lib/context_dev/models/parse_handle_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,12 @@ class ParseHandleParams < ContextDev::Internal::Type::BaseModel
# @return [Pathname, StringIO, IO, String, ContextDev::FilePart]
required :body, ContextDev::Internal::Type::FileInput

# @!attribute base_url
# Optional HTTP(S) source document URL used to resolve relative links and image
# references. Relative references remain relative when omitted.
#
# @return [String, nil]
optional :base_url, String

# @!attribute extension
# Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv,
# md, py, rtf, jpg, png, or txt.
#
# @return [String, nil]
optional :extension, String

# @!attribute filename
# Optional filename hint used to infer the extension when extension is omitted.
# Optional file extension hint. Case-insensitive; a leading dot is accepted (e.g.
# ".pdf").
#
# @return [String, nil]
optional :filename, String
# @return [Symbol, ContextDev::Models::ParseHandleParams::Extension, nil]
optional :extension, enum: -> { ContextDev::ParseHandleParams::Extension }

# @!attribute include_images
# Include image references in Markdown output
Expand All @@ -45,26 +32,23 @@ class ParseHandleParams < ContextDev::Internal::Type::BaseModel
optional :include_links, ContextDev::Internal::Type::Boolean

# @!attribute ocr
# When true for PDF inputs, detect and OCR images embedded in the selected pages,
# inserting recognized text at each image's position in page reading order while
# preserving the PDF text layer. pdfStart/pdfEnd limit the inclusive page range.
# This is separate from automatic scanned-PDF OCR fallback.
# Gates all OCR. When true, PDFs get embedded-image OCR (recognized text inserted
# at each image's position in page reading order, preserving the text layer;
# pdf.start/pdf.end limit the page range), scanned PDFs with no text layer get
# full-document OCR, and raster images get their visible text transcribed. When
# false, no OCR runs: scanned PDFs may yield no content and images return only
# format/dimension metadata. Calls where OCR actually runs cost 5 credits instead
# of 1.
#
# @return [Boolean, nil]
optional :ocr, ContextDev::Internal::Type::Boolean

# @!attribute pdf_end
# Last 1-based PDF page to parse. When omitted, parsing ends at the last page.
# Must be greater than or equal to pdfStart when both are provided.
# @!attribute pdf
# PDF page-range controls. Use start/end to limit parsing (and OCR when ocr=true)
# to an inclusive 1-based page range.
#
# @return [Integer, nil]
optional :pdf_end, Integer

# @!attribute pdf_start
# First 1-based PDF page to parse. When omitted, parsing starts at the first page.
#
# @return [Integer, nil]
optional :pdf_start, Integer
# @return [ContextDev::Models::ParseHandleParams::Pdf, nil]
optional :pdf, -> { ContextDev::ParseHandleParams::Pdf }

# @!attribute shorten_base64_images
# Shorten base64-encoded image data in the Markdown output
Expand All @@ -78,33 +62,133 @@ class ParseHandleParams < ContextDev::Internal::Type::BaseModel
# @return [Boolean, nil]
optional :use_main_content_only, ContextDev::Internal::Type::Boolean

# @!method initialize(body:, base_url: nil, extension: nil, filename: nil, include_images: nil, include_links: nil, ocr: nil, pdf_end: nil, pdf_start: nil, shorten_base64_images: nil, use_main_content_only: nil, request_options: {})
# @!method initialize(body:, extension: nil, include_images: nil, include_links: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, use_main_content_only: nil, request_options: {})
# Some parameter documentations has been truncated, see
# {ContextDev::Models::ParseHandleParams} for more details.
#
# @param body [Pathname, StringIO, IO, String, ContextDev::FilePart]
#
# @param base_url [String] Optional HTTP(S) source document URL used to resolve relative links and image re
#
# @param extension [String] Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv, md
#
# @param filename [String] Optional filename hint used to infer the extension when extension is omitted.
# @param extension [Symbol, ContextDev::Models::ParseHandleParams::Extension] Optional file extension hint. Case-insensitive; a leading dot is accepted (e.g.
#
# @param include_images [Boolean] Include image references in Markdown output
#
# @param include_links [Boolean] Preserve hyperlinks in Markdown output
#
# @param ocr [Boolean] When true for PDF inputs, detect and OCR images embedded in the selected pages,
# @param ocr [Boolean] Gates all OCR. When true, PDFs get embedded-image OCR (recognized text inserted
#
# @param pdf_end [Integer] Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Mus
#
# @param pdf_start [Integer] First 1-based PDF page to parse. When omitted, parsing starts at the first page.
# @param pdf [ContextDev::Models::ParseHandleParams::Pdf] PDF page-range controls. Use start/end to limit parsing (and OCR when ocr=true)
#
# @param shorten_base64_images [Boolean] Shorten base64-encoded image data in the Markdown output
#
# @param use_main_content_only [Boolean] Extract only the main content from HTML-like inputs
#
# @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}]

# Optional file extension hint. Case-insensitive; a leading dot is accepted (e.g.
# ".pdf").
module Extension
extend ContextDev::Internal::Type::Enum

TXT = :txt
TEXT = :text
MD = :md
MARKDOWN = :markdown
HTML = :html
HTM = :htm
XHTML = :xhtml
XML = :xml
RSS = :rss
ATOM = :atom
CSV = :csv
TSV = :tsv
YAML = :yaml
YML = :yml
PY = :py
JAVA = :java
JS = :js
JSX = :jsx
MJS = :mjs
CJS = :cjs
JSON = :json
JSONL = :jsonl
NDJSON = :ndjson
PHP = :php
SH = :sh
BASH = :bash
ZSH = :zsh
FISH = :fish
RB = :rb
TS = :ts
TSX = :tsx
RTF = :rtf
SRT = :srt
CSS = :css
SCSS = :scss
LESS = :less
STYL = :styl
SASS = :sass
SVG = :svg
PDF = :pdf
DOCX = :docx
DOC = :doc
XLSX = :xlsx
XLSM = :xlsm
XLSB = :xlsb
XLTX = :xltx
XLTM = :xltm
XLS = :xls
PPTX = :pptx
PPTM = :pptm
PPSX = :ppsx
PPSM = :ppsm
POTX = :potx
POTM = :potm
PPT = :ppt
PPS = :pps
POT = :pot
JPG = :jpg
JPEG = :jpeg
JPE = :jpe
PNG = :png
GIF = :gif
BMP = :bmp
TIFF = :tiff
TIF = :tif
WEBP = :webp
PPM = :ppm
PBM = :pbm
PGM = :pgm
PNM = :pnm

# @!method self.values
# @return [Array<Symbol>]
end

class Pdf < ContextDev::Internal::Type::BaseModel
# @!attribute end_
# Last 1-based PDF page to parse. When omitted, parsing ends at the last page.
# Must be greater than or equal to start when both are provided.
#
# @return [Integer, nil]
optional :end_, Integer, api_name: :end

# @!attribute start
# First 1-based PDF page to parse. When omitted, parsing starts at the first page.
#
# @return [Integer, nil]
optional :start, Integer

# @!method initialize(end_: nil, start: nil)
# Some parameter documentations has been truncated, see
# {ContextDev::Models::ParseHandleParams::Pdf} for more details.
#
# PDF page-range controls. Use start/end to limit parsing (and OCR when ocr=true)
# to an inclusive 1-based page range.
#
# @param end_ [Integer] Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Mus
#
# @param start [Integer] First 1-based PDF page to parse. When omitted, parsing starts at the first page.
end
end
end
end
18 changes: 7 additions & 11 deletions lib/context_dev/resources/parse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@ class Parse
# {ContextDev::Models::ParseHandleParams} for more details.
#
# Converts raw text, source code, web/data, PDF, Microsoft Office, and image bytes
# into LLM-usable Markdown.
# into LLM-usable Markdown. The base request costs 1 credit. When OCR runs
# (requires ocr=true), the entire call costs 5 credits; ocr=true requests where no
# OCR ends up running still cost 1 credit.
#
# @overload handle(body:, base_url: nil, extension: nil, filename: nil, include_images: nil, include_links: nil, ocr: nil, pdf_end: nil, pdf_start: nil, shorten_base64_images: nil, use_main_content_only: nil, request_options: {})
# @overload handle(body:, extension: nil, include_images: nil, include_links: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, use_main_content_only: nil, request_options: {})
#
# @param body [Pathname, StringIO, IO, String, ContextDev::FilePart] Body param
#
# @param base_url [String] Query param: Optional HTTP(S) source document URL used to resolve relative links
#
# @param extension [String] Query param: Optional file extension hint, such as pdf, docx, xlsx, pptx, html,
#
# @param filename [String] Query param: Optional filename hint used to infer the extension when extension i
# @param extension [Symbol, ContextDev::Models::ParseHandleParams::Extension] Query param: Optional file extension hint. Case-insensitive; a leading dot is ac
#
# @param include_images [Boolean] Query param: Include image references in Markdown output
#
# @param include_links [Boolean] Query param: Preserve hyperlinks in Markdown output
#
# @param ocr [Boolean] Query param: When true for PDF inputs, detect and OCR images embedded in the sel
#
# @param pdf_end [Integer] Query param: Last 1-based PDF page to parse. When omitted, parsing ends at the l
# @param ocr [Boolean] Query param: Gates all OCR. When true, PDFs get embedded-image OCR (recognized t
#
# @param pdf_start [Integer] Query param: First 1-based PDF page to parse. When omitted, parsing starts at th
# @param pdf [ContextDev::Models::ParseHandleParams::Pdf] Query param: PDF page-range controls. Use start/end to limit parsing (and OCR wh
#
# @param shorten_base64_images [Boolean] Query param: Shorten base64-encoded image data in the Markdown output
#
Expand Down
2 changes: 1 addition & 1 deletion lib/context_dev/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ContextDev
VERSION = "2.3.0"
VERSION = "2.4.0"
end
Loading