Class: Retab::Extractions
- Inherits:
-
Object
- Object
- Retab::Extractions
- Defined in:
- lib/retab/extractions.rb
Instance Method Summary collapse
-
#create(document:, json_schema:, model: nil, instructions: nil, n_consensus: nil, metadata: nil, additional_messages: nil, bust_cache: nil, stream: nil, background: nil, chunking_keys: nil, request_options: {}) ⇒ Retab::Extraction
Create Extraction.
-
#create_extraction_cancel(extraction_id:, request_options: {}) ⇒ Retab::Extraction
Cancel Extraction.
-
#create_stream(document:, json_schema:, model: nil, instructions: nil, n_consensus: nil, metadata: nil, additional_messages: nil, bust_cache: nil, stream: nil, background: nil, chunking_keys: nil, request_options: {}) ⇒ void
Create Extraction Stream.
-
#delete(extraction_id:, request_options: {}) ⇒ void
Delete Extraction.
-
#get(extraction_id:, include_output: true, request_options: {}) ⇒ Retab::Extraction
Get Extraction.
-
#initialize(client) ⇒ Extractions
constructor
A new instance of Extractions.
-
#list(before: nil, after: nil, limit: 10, order: "desc", filename: nil, filename_regex: nil, filename_contains: nil, document_type: nil, status: nil, from_date: nil, to_date: nil, metadata: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::Extraction>
List Extractions.
-
#sources(extraction_id:, request_options: {}) ⇒ Retab::SourcesResponse
Get Extraction Sources.
Constructor Details
#initialize(client) ⇒ Extractions
Returns a new instance of Extractions.
9 10 11 |
# File 'lib/retab/extractions.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create(document:, json_schema:, model: nil, instructions: nil, n_consensus: nil, metadata: nil, additional_messages: nil, bust_cache: nil, stream: nil, background: nil, chunking_keys: nil, request_options: {}) ⇒ Retab::Extraction
Create Extraction
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/retab/extractions.rb', line 115 def create( document:, json_schema:, model: nil, instructions: nil, n_consensus: nil, metadata: nil, additional_messages: nil, bust_cache: nil, stream: nil, background: nil, chunking_keys: nil, request_options: {} ) document = Retab::MimeData.coerce(document, client: @client) unless document.nil? body = { "document" => document, "json_schema" => json_schema, "model" => model, "instructions" => instructions, "n_consensus" => n_consensus, "metadata" => , "additional_messages" => , "bust_cache" => bust_cache, "stream" => stream, "background" => background, "chunking_keys" => chunking_keys }.compact response = @client.request( method: :post, path: "/v1/extractions", auth: true, body: body, request_options: ) result = Retab::Extraction.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#create_extraction_cancel(extraction_id:, request_options: {}) ⇒ Retab::Extraction
Cancel Extraction
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/retab/extractions.rb', line 261 def create_extraction_cancel( extraction_id:, request_options: {} ) response = @client.request( method: :post, path: "/v1/extractions/#{Retab::Util.encode_path(extraction_id)}/cancel", auth: true, request_options: ) result = Retab::Extraction.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#create_stream(document:, json_schema:, model: nil, instructions: nil, n_consensus: nil, metadata: nil, additional_messages: nil, bust_cache: nil, stream: nil, background: nil, chunking_keys: nil, request_options: {}) ⇒ void
This method returns an undefined value.
Create Extraction Stream
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/retab/extractions.rb', line 173 def create_stream( document:, json_schema:, model: nil, instructions: nil, n_consensus: nil, metadata: nil, additional_messages: nil, bust_cache: nil, stream: nil, background: nil, chunking_keys: nil, request_options: {} ) document = Retab::MimeData.coerce(document, client: @client) unless document.nil? body = { "document" => document, "json_schema" => json_schema, "model" => model, "instructions" => instructions, "n_consensus" => n_consensus, "metadata" => , "additional_messages" => , "bust_cache" => bust_cache, "stream" => stream, "background" => background, "chunking_keys" => chunking_keys }.compact @client.request( method: :post, path: "/v1/extractions/stream", auth: true, body: body, request_options: ) nil end |
#delete(extraction_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete Extraction
244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/retab/extractions.rb', line 244 def delete( extraction_id:, request_options: {} ) @client.request( method: :delete, path: "/v1/extractions/#{Retab::Util.encode_path(extraction_id)}", auth: true, request_options: ) nil end |
#get(extraction_id:, include_output: true, request_options: {}) ⇒ Retab::Extraction
Get Extraction
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/retab/extractions.rb', line 216 def get( extraction_id:, include_output: true, request_options: {} ) params = { "include_output" => include_output }.compact response = @client.request( method: :get, path: "/v1/extractions/#{Retab::Util.encode_path(extraction_id)}", auth: true, params: params, request_options: ) result = Retab::Extraction.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#list(before: nil, after: nil, limit: 10, order: "desc", filename: nil, filename_regex: nil, filename_contains: nil, document_type: nil, status: nil, from_date: nil, to_date: nil, metadata: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::Extraction>
List Extractions
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/retab/extractions.rb', line 28 def list( before: nil, after: nil, limit: 10, order: "desc", filename: nil, filename_regex: nil, filename_contains: nil, document_type: nil, status: nil, from_date: nil, to_date: nil, metadata: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "filename" => filename, "filename_regex" => filename_regex, "filename_contains" => filename_contains, "document_type" => document_type, "status" => status, "from_date" => from_date, "to_date" => to_date, "metadata" => }.compact response = @client.request( method: :get, path: "/v1/extractions", auth: true, params: params, request_options: ) fetch_next = -> (cursor) { list( before: before, after: cursor, limit: limit, order: order, filename: filename, filename_regex: filename_regex, filename_contains: filename_contains, document_type: document_type, status: status, from_date: from_date, to_date: to_date, metadata: , request_options: ) } Retab::PaginatedList.from_response( response, model: Retab::Extraction, filters: { before: before, limit: limit, order: order, filename: filename, filename_regex: filename_regex, filename_contains: filename_contains, document_type: document_type, status: status, from_date: from_date, to_date: to_date, metadata: }, fetch_next: fetch_next ) end |
#sources(extraction_id:, request_options: {}) ⇒ Retab::SourcesResponse
Get Extraction Sources
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/retab/extractions.rb', line 284 def sources( extraction_id:, request_options: {} ) response = @client.request( method: :get, path: "/v1/extractions/#{Retab::Util.encode_path(extraction_id)}/sources", auth: true, request_options: ) result = Retab::SourcesResponse.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |