Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions lib/veryfi/api/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
40 changes: 40 additions & 0 deletions spec/veryfi/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading