From 6eb23927c298cbad35e00ef4be66ef2cfe3b2022 Mon Sep 17 00:00:00 2001 From: Andres Garcia Date: Thu, 12 Nov 2026 11:46:50 -0500 Subject: [PATCH] PLAT-9438: document the thinking parameter in the Ruby SDK Add thinking ("light" or "deep") to the YARD docs of process and process_url and to the README parameters table, and add specs. Co-Authored-By: Claude Sonnet 5.5 --- README.md | 1 + lib/veryfi/api/document.rb | 4 ++++ spec/veryfi/document_spec.rb | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/README.md b/README.md index 2165aa2..82735ec 100644 --- a/README.md +++ b/README.md @@ -509,6 +509,7 @@ explicit in your own code. | `max_pages_to_process` | No | `nil` (= all pages) | Hard cap on the number of pages Veryfi reads, starting from page 1. Useful for very long PDFs when you only care about the first few pages. | | `bounding_boxes` | No | `false` | When `true`, the response includes `bounding_box` / `bounding_region` metadata for each extracted field. | | `confidence_details` | No | `false` | When `true`, the response includes per-field `score` and `ocr_score` values. | +| `thinking` | No | `nil` (off) | Extra LLM pass on the line items: `"light"` or `"deep"` (slower). Used by `process` / `process_url`, and only takes effect if thinking mode is enabled for your account. | So all four of the following calls are equivalent and produce the same request payload — pick whichever style your team prefers: diff --git a/lib/veryfi/api/document.rb b/lib/veryfi/api/document.rb index 736a774..4a73e69 100644 --- a/lib/veryfi/api/document.rb +++ b/lib/veryfi/api/document.rb @@ -91,6 +91,9 @@ def all(params = {}) # Return bounding-box info for extracted fields. # @option raw_params [Hash] :confidence_details (`false`) # Return confidence score details. + # @option raw_params [String] :thinking (`nil`) + # Extra LLM pass on the line items: `"light"` or `"deep"` (slower). + # Omit to turn it off. Needs thinking mode enabled for your account. # # @return [Veryfi::Resource] Extracted document data. def process(raw_params) @@ -126,6 +129,7 @@ def process(raw_params) # @option raw_params [Boolean] :async (`false`) # @option raw_params [String] :external_id (`nil`) # @option raw_params [Integer] :max_pages_to_process (`nil` = all pages) + # @option raw_params [String] :thinking (`nil`) `"light"` or `"deep"`, see {#process} # # @return [Veryfi::Resource] def process_url(raw_params) diff --git a/spec/veryfi/document_spec.rb b/spec/veryfi/document_spec.rb index f27dc4f..a3a61f5 100644 --- a/spec/veryfi/document_spec.rb +++ b/spec/veryfi/document_spec.rb @@ -86,6 +86,26 @@ expect(response["id"]).to eq(44_691_518) end + + %w[light deep].each do |mode| + it "sends thinking=#{mode}" do + client.document.process(document_params.merge(thinking: mode)) + + expect( + a_request(:post, "https://api.veryfi.com/api/v8/partner/documents/") + .with { |req| JSON.parse(req.body)["thinking"] == mode } + ).to have_been_made.once + end + end + + it "does not send thinking when omitted" do + client.document.process(document_params) + + expect( + a_request(:post, "https://api.veryfi.com/api/v8/partner/documents/") + .with { |req| !JSON.parse(req.body).key?("thinking") } + ).to have_been_made.once + end end describe "document.process_url(id, params)" do @@ -122,6 +142,26 @@ expect(response["id"]).to eq(44_691_518) end + + %w[light deep].each do |mode| + it "sends thinking=#{mode}" do + client.document.process_url(document_params.merge(thinking: mode)) + + expect( + a_request(:post, "https://api.veryfi.com/api/v8/partner/documents/") + .with { |req| JSON.parse(req.body)["thinking"] == mode } + ).to have_been_made.once + end + end + + it "does not send thinking when omitted" do + client.document.process_url(document_params) + + expect( + a_request(:post, "https://api.veryfi.com/api/v8/partner/documents/") + .with { |req| !JSON.parse(req.body).key?("thinking") } + ).to have_been_made.once + end end describe "document.get(id)" do