retab 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/retab/classifications/classification.rb +6 -0
- data/lib/retab/classifications/classification_request.rb +5 -2
- data/lib/retab/{jobs/job_error.rb → classifications/primitive_error.rb} +1 -1
- data/lib/retab/classifications.rb +38 -1
- data/lib/retab/client.rb +0 -4
- data/lib/retab/edits/edit.rb +6 -0
- data/lib/retab/edits/edit_request.rb +5 -2
- data/lib/retab/edits.rb +38 -1
- data/lib/retab/extractions/extraction.rb +6 -0
- data/lib/retab/extractions/extraction_request.rb +3 -0
- data/lib/retab/extractions.rb +37 -0
- data/lib/retab/parses/parse.rb +6 -0
- data/lib/retab/parses/parse_request.rb +5 -2
- data/lib/retab/parses.rb +33 -1
- data/lib/retab/partitions/partition.rb +6 -0
- data/lib/retab/partitions/partition_request.rb +5 -2
- data/lib/retab/partitions.rb +38 -1
- data/lib/retab/splits/split.rb +6 -0
- data/lib/retab/splits/split_request.rb +5 -2
- data/lib/retab/splits.rb +38 -1
- data/lib/retab/types/{job_status.rb → classification_status.rb} +3 -4
- data/lib/retab/types/classification_workflow_artifact_status.rb +9 -0
- data/lib/retab/types/{supported_endpoint.rb → classifications_status.rb} +1 -1
- data/lib/retab/types/{jobs_order.rb → edit_status.rb} +1 -1
- data/lib/retab/types/edit_workflow_artifact_status.rb +9 -0
- data/lib/retab/types/{jobs_status.rb → edits_status.rb} +1 -1
- data/lib/retab/types/{jobs_endpoint.rb → extraction_status.rb} +1 -1
- data/lib/retab/types/extraction_workflow_artifact_status.rb +9 -0
- data/lib/retab/types/extractions_status.rb +9 -0
- data/lib/retab/types/parse_status.rb +9 -0
- data/lib/retab/types/parse_workflow_artifact_status.rb +9 -0
- data/lib/retab/types/partition_status.rb +9 -0
- data/lib/retab/types/partition_workflow_artifact_status.rb +9 -0
- data/lib/retab/types/partitions_status.rb +9 -0
- data/lib/retab/types/split_status.rb +9 -0
- data/lib/retab/types/split_workflow_artifact_status.rb +9 -0
- data/lib/retab/types/splits_status.rb +9 -0
- data/lib/retab/workflow_artifacts/classification_workflow_artifact.rb +6 -0
- data/lib/retab/workflow_artifacts/edit_workflow_artifact.rb +6 -0
- data/lib/retab/workflow_artifacts/extraction_workflow_artifact.rb +6 -0
- data/lib/retab/workflow_artifacts/parse_workflow_artifact.rb +6 -0
- data/lib/retab/workflow_artifacts/partition_workflow_artifact.rb +6 -0
- data/lib/retab/workflow_artifacts/split_workflow_artifact.rb +6 -0
- data/lib/retab/workflow_steps.rb +2 -2
- data/lib/retab.rb +0 -1
- data/rbi/retab/classification.rbi +14 -2
- data/rbi/retab/classification_request.rbi +6 -0
- data/rbi/retab/classification_workflow_artifact.rbi +14 -2
- data/rbi/retab/classifications.rbi +14 -3
- data/rbi/retab/client.rbi +0 -3
- data/rbi/retab/edit.rbi +14 -2
- data/rbi/retab/edit_request.rbi +6 -0
- data/rbi/retab/edit_workflow_artifact.rbi +14 -2
- data/rbi/retab/edits.rbi +14 -3
- data/rbi/retab/extraction.rbi +12 -0
- data/rbi/retab/extraction_request.rbi +6 -0
- data/rbi/retab/extraction_workflow_artifact.rbi +12 -0
- data/rbi/retab/extractions.rbi +14 -3
- data/rbi/retab/parse.rbi +12 -0
- data/rbi/retab/parse_request.rbi +6 -0
- data/rbi/retab/parse_workflow_artifact.rbi +12 -0
- data/rbi/retab/parses.rbi +12 -2
- data/rbi/retab/partition.rbi +12 -0
- data/rbi/retab/partition_request.rbi +6 -0
- data/rbi/retab/partition_workflow_artifact.rbi +12 -0
- data/rbi/retab/partitions.rbi +14 -3
- data/rbi/retab/{job_error.rbi → primitive_error.rbi} +1 -1
- data/rbi/retab/split.rbi +14 -2
- data/rbi/retab/split_request.rbi +6 -0
- data/rbi/retab/split_workflow_artifact.rbi +14 -2
- data/rbi/retab/splits.rbi +14 -3
- metadata +20 -20
- data/lib/retab/jobs/create_job_request.rb +0 -28
- data/lib/retab/jobs/job.rb +0 -70
- data/lib/retab/jobs/job_response.rb +0 -25
- data/lib/retab/jobs/job_warning.rb +0 -7
- data/lib/retab/jobs.rb +0 -252
- data/lib/retab/types/create_job_request_endpoint.rb +0 -34
- data/lib/retab/types/jobs_source.rb +0 -14
- data/rbi/retab/create_job_request.rbi +0 -36
- data/rbi/retab/job.rbi +0 -120
- data/rbi/retab/job_response.rbi +0 -30
- data/rbi/retab/job_warning.rbi +0 -36
- data/rbi/retab/jobs.rbi +0 -76
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 892cc7d33cd77ee2992206da231970259f4f0cf3668c762671b114b78116d1ee
|
|
4
|
+
data.tar.gz: 17e6a78b1858ab551518b0b379b92b4d54980e25565ce0d567504b17c2f0294c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 653dc2782eee8ec927931b08da074dff4bceb322e7605a74ba14f2629cc6c9a8dca82c66de8748bc13e72a5cfc38c256b2b147844298b0c82000ccfa84c8d33e
|
|
7
|
+
data.tar.gz: 04d599b812516886ac4b0a2f3336af22d96418a40340da1412b45ed43e2b98733d2cbdbee41e35d70af30b7b4ea38df5c7651ef40ece0fba3a1a065b12d74237
|
|
@@ -13,6 +13,8 @@ module Retab
|
|
|
13
13
|
n_consensus: :n_consensus,
|
|
14
14
|
instructions: :instructions,
|
|
15
15
|
output: :output,
|
|
16
|
+
status: :status,
|
|
17
|
+
error: :error,
|
|
16
18
|
consensus: :consensus,
|
|
17
19
|
usage: :usage,
|
|
18
20
|
created_at: :created_at
|
|
@@ -26,6 +28,8 @@ module Retab
|
|
|
26
28
|
:n_consensus,
|
|
27
29
|
:instructions,
|
|
28
30
|
:output,
|
|
31
|
+
:status,
|
|
32
|
+
:error,
|
|
29
33
|
:consensus,
|
|
30
34
|
:usage,
|
|
31
35
|
:created_at
|
|
@@ -41,6 +45,8 @@ module Retab
|
|
|
41
45
|
@n_consensus = hash[:n_consensus]
|
|
42
46
|
@instructions = hash[:instructions]
|
|
43
47
|
@output = hash[:output] ? Retab::ClassificationDecision.new(hash[:output]) : nil
|
|
48
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
49
|
+
@error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
|
|
44
50
|
@consensus = hash[:consensus] ? Retab::ClassificationConsensus.new(hash[:consensus]) : nil
|
|
45
51
|
@usage = hash[:usage] ? Retab::RetabUsage.new(hash[:usage]) : nil
|
|
46
52
|
@created_at = hash[:created_at]
|
|
@@ -12,7 +12,8 @@ module Retab
|
|
|
12
12
|
first_n_pages: :first_n_pages,
|
|
13
13
|
instructions: :instructions,
|
|
14
14
|
n_consensus: :n_consensus,
|
|
15
|
-
bust_cache: :bust_cache
|
|
15
|
+
bust_cache: :bust_cache,
|
|
16
|
+
background: :background
|
|
16
17
|
}.freeze
|
|
17
18
|
|
|
18
19
|
attr_accessor(
|
|
@@ -22,7 +23,8 @@ module Retab
|
|
|
22
23
|
:first_n_pages,
|
|
23
24
|
:instructions,
|
|
24
25
|
:n_consensus,
|
|
25
|
-
:bust_cache
|
|
26
|
+
:bust_cache,
|
|
27
|
+
:background
|
|
26
28
|
)
|
|
27
29
|
|
|
28
30
|
def initialize(json)
|
|
@@ -35,6 +37,7 @@ module Retab
|
|
|
35
37
|
@instructions = hash[:instructions]
|
|
36
38
|
@n_consensus = hash[:n_consensus]
|
|
37
39
|
@bust_cache = hash[:bust_cache].nil? ? false : hash[:bust_cache]
|
|
40
|
+
@background = hash[:background].nil? ? false : hash[:background]
|
|
38
41
|
end
|
|
39
42
|
end
|
|
40
43
|
end
|
|
@@ -16,6 +16,7 @@ module Retab
|
|
|
16
16
|
# @param limit [Integer, nil]
|
|
17
17
|
# @param order [Retab::Types::ClassificationsOrder, nil]
|
|
18
18
|
# @param filename [String, nil]
|
|
19
|
+
# @param status [Retab::Types::ClassificationsStatus, nil]
|
|
19
20
|
# @param from_date [String, nil]
|
|
20
21
|
# @param to_date [String, nil]
|
|
21
22
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
@@ -26,6 +27,7 @@ module Retab
|
|
|
26
27
|
limit: 10,
|
|
27
28
|
order: "desc",
|
|
28
29
|
filename: nil,
|
|
30
|
+
status: nil,
|
|
29
31
|
from_date: nil,
|
|
30
32
|
to_date: nil,
|
|
31
33
|
request_options: {}
|
|
@@ -36,6 +38,7 @@ module Retab
|
|
|
36
38
|
"limit" => limit,
|
|
37
39
|
"order" => order,
|
|
38
40
|
"filename" => filename,
|
|
41
|
+
"status" => status,
|
|
39
42
|
"from_date" => from_date,
|
|
40
43
|
"to_date" => to_date
|
|
41
44
|
}.compact
|
|
@@ -53,6 +56,7 @@ module Retab
|
|
|
53
56
|
limit: limit,
|
|
54
57
|
order: order,
|
|
55
58
|
filename: filename,
|
|
59
|
+
status: status,
|
|
56
60
|
from_date: from_date,
|
|
57
61
|
to_date: to_date,
|
|
58
62
|
request_options: request_options
|
|
@@ -66,6 +70,7 @@ module Retab
|
|
|
66
70
|
limit: limit,
|
|
67
71
|
order: order,
|
|
68
72
|
filename: filename,
|
|
73
|
+
status: status,
|
|
69
74
|
from_date: from_date,
|
|
70
75
|
to_date: to_date
|
|
71
76
|
},
|
|
@@ -81,6 +86,7 @@ module Retab
|
|
|
81
86
|
# @param instructions [String, nil] Free-form instructions appended to the system prompt to steer the classification.
|
|
82
87
|
# @param n_consensus [Integer, nil] Number of classification runs to use for consensus voting. Uses deterministic single-pass when set to 1.
|
|
83
88
|
# @param bust_cache [Boolean, nil] If true, skip the LLM cache and force a fresh completion
|
|
89
|
+
# @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1/<primitive>/{id} until status is terminal. Mutually exclusive with stream.
|
|
84
90
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
85
91
|
# @return [Retab::Classification]
|
|
86
92
|
def create(
|
|
@@ -91,6 +97,7 @@ module Retab
|
|
|
91
97
|
instructions: nil,
|
|
92
98
|
n_consensus: nil,
|
|
93
99
|
bust_cache: nil,
|
|
100
|
+
background: nil,
|
|
94
101
|
request_options: {}
|
|
95
102
|
)
|
|
96
103
|
document = Retab::MimeData.coerce(document) unless document.nil?
|
|
@@ -101,7 +108,8 @@ module Retab
|
|
|
101
108
|
"first_n_pages" => first_n_pages,
|
|
102
109
|
"instructions" => instructions,
|
|
103
110
|
"n_consensus" => n_consensus,
|
|
104
|
-
"bust_cache" => bust_cache
|
|
111
|
+
"bust_cache" => bust_cache,
|
|
112
|
+
"background" => background
|
|
105
113
|
}.compact
|
|
106
114
|
response = @client.request(
|
|
107
115
|
method: :post,
|
|
@@ -121,16 +129,22 @@ module Retab
|
|
|
121
129
|
|
|
122
130
|
# Get Classification
|
|
123
131
|
# @param classification_id [String]
|
|
132
|
+
# @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
|
|
124
133
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
125
134
|
# @return [Retab::Classification]
|
|
126
135
|
def get(
|
|
127
136
|
classification_id:,
|
|
137
|
+
include_output: true,
|
|
128
138
|
request_options: {}
|
|
129
139
|
)
|
|
140
|
+
params = {
|
|
141
|
+
"include_output" => include_output
|
|
142
|
+
}.compact
|
|
130
143
|
response = @client.request(
|
|
131
144
|
method: :get,
|
|
132
145
|
path: "/v1/classifications/#{Retab::Util.encode_path(classification_id)}",
|
|
133
146
|
auth: true,
|
|
147
|
+
params: params,
|
|
134
148
|
request_options: request_options
|
|
135
149
|
)
|
|
136
150
|
result = Retab::Classification.new(response.body)
|
|
@@ -158,5 +172,28 @@ module Retab
|
|
|
158
172
|
)
|
|
159
173
|
nil
|
|
160
174
|
end
|
|
175
|
+
|
|
176
|
+
# Cancel Classification
|
|
177
|
+
# @param classification_id [String]
|
|
178
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
179
|
+
# @return [Retab::Classification]
|
|
180
|
+
def create_classification_cancel(
|
|
181
|
+
classification_id:,
|
|
182
|
+
request_options: {}
|
|
183
|
+
)
|
|
184
|
+
response = @client.request(
|
|
185
|
+
method: :post,
|
|
186
|
+
path: "/v1/classifications/#{Retab::Util.encode_path(classification_id)}/cancel",
|
|
187
|
+
auth: true,
|
|
188
|
+
request_options: request_options
|
|
189
|
+
)
|
|
190
|
+
result = Retab::Classification.new(response.body)
|
|
191
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
192
|
+
http_status: response.code.to_i,
|
|
193
|
+
http_headers: response.each_header.to_h,
|
|
194
|
+
request_id: response["x-request-id"]
|
|
195
|
+
)
|
|
196
|
+
result
|
|
197
|
+
end
|
|
161
198
|
end
|
|
162
199
|
end
|
data/lib/retab/client.rb
CHANGED
data/lib/retab/edits/edit.rb
CHANGED
|
@@ -13,6 +13,8 @@ module Retab
|
|
|
13
13
|
config: :config,
|
|
14
14
|
template_id: :template_id,
|
|
15
15
|
output: :output,
|
|
16
|
+
status: :status,
|
|
17
|
+
error: :error,
|
|
16
18
|
filled_document_ref: :filled_document_ref,
|
|
17
19
|
usage: :usage,
|
|
18
20
|
created_at: :created_at
|
|
@@ -26,6 +28,8 @@ module Retab
|
|
|
26
28
|
:config,
|
|
27
29
|
:template_id,
|
|
28
30
|
:output,
|
|
31
|
+
:status,
|
|
32
|
+
:error,
|
|
29
33
|
:filled_document_ref,
|
|
30
34
|
:usage,
|
|
31
35
|
:created_at
|
|
@@ -41,6 +45,8 @@ module Retab
|
|
|
41
45
|
@config = hash[:config] ? Retab::EditConfig.new(hash[:config]) : nil
|
|
42
46
|
@template_id = hash[:template_id]
|
|
43
47
|
@output = hash[:output] ? Retab::EditResult.new(hash[:output]) : nil
|
|
48
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
49
|
+
@error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
|
|
44
50
|
@filled_document_ref = hash[:filled_document_ref] ? Retab::FileRef.new(hash[:filled_document_ref]) : nil
|
|
45
51
|
@usage = hash[:usage] ? Retab::RetabUsage.new(hash[:usage]) : nil
|
|
46
52
|
@created_at = hash[:created_at]
|
|
@@ -11,7 +11,8 @@ module Retab
|
|
|
11
11
|
template_id: :template_id,
|
|
12
12
|
model: :model,
|
|
13
13
|
config: :config,
|
|
14
|
-
bust_cache: :bust_cache
|
|
14
|
+
bust_cache: :bust_cache,
|
|
15
|
+
background: :background
|
|
15
16
|
}.freeze
|
|
16
17
|
|
|
17
18
|
attr_accessor(
|
|
@@ -20,7 +21,8 @@ module Retab
|
|
|
20
21
|
:template_id,
|
|
21
22
|
:model,
|
|
22
23
|
:config,
|
|
23
|
-
:bust_cache
|
|
24
|
+
:bust_cache,
|
|
25
|
+
:background
|
|
24
26
|
)
|
|
25
27
|
|
|
26
28
|
def initialize(json)
|
|
@@ -32,6 +34,7 @@ module Retab
|
|
|
32
34
|
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
33
35
|
@config = hash[:config] ? Retab::EditConfig.new(hash[:config]) : nil
|
|
34
36
|
@bust_cache = hash[:bust_cache].nil? ? false : hash[:bust_cache]
|
|
37
|
+
@background = hash[:background].nil? ? false : hash[:background]
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
40
|
end
|
data/lib/retab/edits.rb
CHANGED
|
@@ -21,6 +21,7 @@ module Retab
|
|
|
21
21
|
# @param order [Retab::Types::EditsOrder, nil]
|
|
22
22
|
# @param filename [String, nil]
|
|
23
23
|
# @param template_id [String, nil]
|
|
24
|
+
# @param status [Retab::Types::EditsStatus, nil]
|
|
24
25
|
# @param from_date [String, nil]
|
|
25
26
|
# @param to_date [String, nil]
|
|
26
27
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
@@ -32,6 +33,7 @@ module Retab
|
|
|
32
33
|
order: "desc",
|
|
33
34
|
filename: nil,
|
|
34
35
|
template_id: nil,
|
|
36
|
+
status: nil,
|
|
35
37
|
from_date: nil,
|
|
36
38
|
to_date: nil,
|
|
37
39
|
request_options: {}
|
|
@@ -43,6 +45,7 @@ module Retab
|
|
|
43
45
|
"order" => order,
|
|
44
46
|
"filename" => filename,
|
|
45
47
|
"template_id" => template_id,
|
|
48
|
+
"status" => status,
|
|
46
49
|
"from_date" => from_date,
|
|
47
50
|
"to_date" => to_date
|
|
48
51
|
}.compact
|
|
@@ -61,6 +64,7 @@ module Retab
|
|
|
61
64
|
order: order,
|
|
62
65
|
filename: filename,
|
|
63
66
|
template_id: template_id,
|
|
67
|
+
status: status,
|
|
64
68
|
from_date: from_date,
|
|
65
69
|
to_date: to_date,
|
|
66
70
|
request_options: request_options
|
|
@@ -75,6 +79,7 @@ module Retab
|
|
|
75
79
|
order: order,
|
|
76
80
|
filename: filename,
|
|
77
81
|
template_id: template_id,
|
|
82
|
+
status: status,
|
|
78
83
|
from_date: from_date,
|
|
79
84
|
to_date: to_date
|
|
80
85
|
},
|
|
@@ -89,6 +94,7 @@ module Retab
|
|
|
89
94
|
# @param model [String, nil] The model to use for edit inference.
|
|
90
95
|
# @param config [Retab::EditConfig, nil] Edit configuration (rendering options).
|
|
91
96
|
# @param bust_cache [Boolean, nil] If true, skip the LLM cache and force a fresh completion.
|
|
97
|
+
# @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1/<primitive>/{id} until status is terminal. Mutually exclusive with stream.
|
|
92
98
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
93
99
|
# @return [Retab::Edit]
|
|
94
100
|
def create(
|
|
@@ -98,6 +104,7 @@ module Retab
|
|
|
98
104
|
model: nil,
|
|
99
105
|
config: nil,
|
|
100
106
|
bust_cache: nil,
|
|
107
|
+
background: nil,
|
|
101
108
|
request_options: {}
|
|
102
109
|
)
|
|
103
110
|
document = Retab::MimeData.coerce(document) unless document.nil?
|
|
@@ -107,7 +114,8 @@ module Retab
|
|
|
107
114
|
"template_id" => template_id,
|
|
108
115
|
"model" => model,
|
|
109
116
|
"config" => config,
|
|
110
|
-
"bust_cache" => bust_cache
|
|
117
|
+
"bust_cache" => bust_cache,
|
|
118
|
+
"background" => background
|
|
111
119
|
}.compact
|
|
112
120
|
response = @client.request(
|
|
113
121
|
method: :post,
|
|
@@ -127,16 +135,22 @@ module Retab
|
|
|
127
135
|
|
|
128
136
|
# Get Edit
|
|
129
137
|
# @param edit_id [String]
|
|
138
|
+
# @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
|
|
130
139
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
131
140
|
# @return [Retab::Edit]
|
|
132
141
|
def get(
|
|
133
142
|
edit_id:,
|
|
143
|
+
include_output: true,
|
|
134
144
|
request_options: {}
|
|
135
145
|
)
|
|
146
|
+
params = {
|
|
147
|
+
"include_output" => include_output
|
|
148
|
+
}.compact
|
|
136
149
|
response = @client.request(
|
|
137
150
|
method: :get,
|
|
138
151
|
path: "/v1/edits/#{Retab::Util.encode_path(edit_id)}",
|
|
139
152
|
auth: true,
|
|
153
|
+
params: params,
|
|
140
154
|
request_options: request_options
|
|
141
155
|
)
|
|
142
156
|
result = Retab::Edit.new(response.body)
|
|
@@ -164,5 +178,28 @@ module Retab
|
|
|
164
178
|
)
|
|
165
179
|
nil
|
|
166
180
|
end
|
|
181
|
+
|
|
182
|
+
# Cancel Edit
|
|
183
|
+
# @param edit_id [String]
|
|
184
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
185
|
+
# @return [Retab::Edit]
|
|
186
|
+
def create_edit_cancel(
|
|
187
|
+
edit_id:,
|
|
188
|
+
request_options: {}
|
|
189
|
+
)
|
|
190
|
+
response = @client.request(
|
|
191
|
+
method: :post,
|
|
192
|
+
path: "/v1/edits/#{Retab::Util.encode_path(edit_id)}/cancel",
|
|
193
|
+
auth: true,
|
|
194
|
+
request_options: request_options
|
|
195
|
+
)
|
|
196
|
+
result = Retab::Edit.new(response.body)
|
|
197
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
198
|
+
http_status: response.code.to_i,
|
|
199
|
+
http_headers: response.each_header.to_h,
|
|
200
|
+
request_id: response["x-request-id"]
|
|
201
|
+
)
|
|
202
|
+
result
|
|
203
|
+
end
|
|
167
204
|
end
|
|
168
205
|
end
|
|
@@ -14,6 +14,8 @@ module Retab
|
|
|
14
14
|
image_resolution_dpi: :image_resolution_dpi,
|
|
15
15
|
instructions: :instructions,
|
|
16
16
|
output: :output,
|
|
17
|
+
status: :status,
|
|
18
|
+
error: :error,
|
|
17
19
|
consensus: :consensus,
|
|
18
20
|
metadata: :metadata,
|
|
19
21
|
usage: :usage,
|
|
@@ -29,6 +31,8 @@ module Retab
|
|
|
29
31
|
:image_resolution_dpi,
|
|
30
32
|
:instructions,
|
|
31
33
|
:output,
|
|
34
|
+
:status,
|
|
35
|
+
:error,
|
|
32
36
|
:consensus,
|
|
33
37
|
:metadata,
|
|
34
38
|
:usage,
|
|
@@ -46,6 +50,8 @@ module Retab
|
|
|
46
50
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
47
51
|
@instructions = hash[:instructions]
|
|
48
52
|
@output = hash[:output] || {}
|
|
53
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
54
|
+
@error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
|
|
49
55
|
@consensus = hash[:consensus] ? Retab::ExtractionConsensus.new(hash[:consensus]) : nil
|
|
50
56
|
@metadata = hash[:metadata] || {}
|
|
51
57
|
@usage = hash[:usage] ? Retab::RetabUsage.new(hash[:usage]) : nil
|
|
@@ -16,6 +16,7 @@ module Retab
|
|
|
16
16
|
additional_messages: :additional_messages,
|
|
17
17
|
bust_cache: :bust_cache,
|
|
18
18
|
stream: :stream,
|
|
19
|
+
background: :background,
|
|
19
20
|
chunking_keys: :chunking_keys
|
|
20
21
|
}.freeze
|
|
21
22
|
|
|
@@ -30,6 +31,7 @@ module Retab
|
|
|
30
31
|
:additional_messages,
|
|
31
32
|
:bust_cache,
|
|
32
33
|
:stream,
|
|
34
|
+
:background,
|
|
33
35
|
:chunking_keys
|
|
34
36
|
)
|
|
35
37
|
|
|
@@ -46,6 +48,7 @@ module Retab
|
|
|
46
48
|
@additional_messages = (hash[:additional_messages] || []).map { |item| item || {} }
|
|
47
49
|
@bust_cache = hash[:bust_cache].nil? ? false : hash[:bust_cache]
|
|
48
50
|
@stream = hash[:stream].nil? ? false : hash[:stream]
|
|
51
|
+
@background = hash[:background].nil? ? false : hash[:background]
|
|
49
52
|
@chunking_keys = hash[:chunking_keys] || {}
|
|
50
53
|
end
|
|
51
54
|
end
|
data/lib/retab/extractions.rb
CHANGED
|
@@ -19,6 +19,7 @@ module Retab
|
|
|
19
19
|
# @param filename_regex [String, nil] Deprecated alias for prefix filename filtering. Regex patterns are rejected.
|
|
20
20
|
# @param filename_contains [String, nil] Plain-text search over the filename.
|
|
21
21
|
# @param document_type [Array<String>, nil] Filter by document type. Can be repeated. Accepted values: bmp, csv, doc, docm, docx, dotm, dotx, eml, gif, heic, heif, htm, html, jpeg, jpg, json, md, mhtml, msg, odp, ods, odt, ots, ott, pdf, png, ppt, pptx, rtf, svg, tif, tiff, tsv, txt, webp, xlam, xls, xlsb, xlsm, xlsx, xltm, xltx, xml, yaml, yml.
|
|
22
|
+
# @param status [Retab::Types::ExtractionsStatus, nil]
|
|
22
23
|
# @param from_date [String, nil]
|
|
23
24
|
# @param to_date [String, nil]
|
|
24
25
|
# @param metadata [String, nil]
|
|
@@ -33,6 +34,7 @@ module Retab
|
|
|
33
34
|
filename_regex: nil,
|
|
34
35
|
filename_contains: nil,
|
|
35
36
|
document_type: nil,
|
|
37
|
+
status: nil,
|
|
36
38
|
from_date: nil,
|
|
37
39
|
to_date: nil,
|
|
38
40
|
metadata: nil,
|
|
@@ -47,6 +49,7 @@ module Retab
|
|
|
47
49
|
"filename_regex" => filename_regex,
|
|
48
50
|
"filename_contains" => filename_contains,
|
|
49
51
|
"document_type" => document_type,
|
|
52
|
+
"status" => status,
|
|
50
53
|
"from_date" => from_date,
|
|
51
54
|
"to_date" => to_date,
|
|
52
55
|
"metadata" => metadata
|
|
@@ -68,6 +71,7 @@ module Retab
|
|
|
68
71
|
filename_regex: filename_regex,
|
|
69
72
|
filename_contains: filename_contains,
|
|
70
73
|
document_type: document_type,
|
|
74
|
+
status: status,
|
|
71
75
|
from_date: from_date,
|
|
72
76
|
to_date: to_date,
|
|
73
77
|
metadata: metadata,
|
|
@@ -85,6 +89,7 @@ module Retab
|
|
|
85
89
|
filename_regex: filename_regex,
|
|
86
90
|
filename_contains: filename_contains,
|
|
87
91
|
document_type: document_type,
|
|
92
|
+
status: status,
|
|
88
93
|
from_date: from_date,
|
|
89
94
|
to_date: to_date,
|
|
90
95
|
metadata: metadata
|
|
@@ -104,6 +109,7 @@ module Retab
|
|
|
104
109
|
# @param additional_messages [Array<Hash{String => Object}>, nil] Additional chat messages forwarded to the extraction model.
|
|
105
110
|
# @param bust_cache [Boolean, nil] If true, skip the LLM cache and force a fresh completion
|
|
106
111
|
# @param stream [Boolean, nil]
|
|
112
|
+
# @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1/<primitive>/{id} until status is terminal. Mutually exclusive with stream.
|
|
107
113
|
# @param chunking_keys [Hash{String => String}, nil]
|
|
108
114
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
109
115
|
# @return [Retab::Extraction]
|
|
@@ -118,6 +124,7 @@ module Retab
|
|
|
118
124
|
additional_messages: nil,
|
|
119
125
|
bust_cache: nil,
|
|
120
126
|
stream: nil,
|
|
127
|
+
background: nil,
|
|
121
128
|
chunking_keys: nil,
|
|
122
129
|
request_options: {}
|
|
123
130
|
)
|
|
@@ -133,6 +140,7 @@ module Retab
|
|
|
133
140
|
"additional_messages" => additional_messages,
|
|
134
141
|
"bust_cache" => bust_cache,
|
|
135
142
|
"stream" => stream,
|
|
143
|
+
"background" => background,
|
|
136
144
|
"chunking_keys" => chunking_keys
|
|
137
145
|
}.compact
|
|
138
146
|
response = @client.request(
|
|
@@ -153,16 +161,22 @@ module Retab
|
|
|
153
161
|
|
|
154
162
|
# Get Extraction
|
|
155
163
|
# @param extraction_id [String]
|
|
164
|
+
# @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
|
|
156
165
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
157
166
|
# @return [Retab::Extraction]
|
|
158
167
|
def get(
|
|
159
168
|
extraction_id:,
|
|
169
|
+
include_output: true,
|
|
160
170
|
request_options: {}
|
|
161
171
|
)
|
|
172
|
+
params = {
|
|
173
|
+
"include_output" => include_output
|
|
174
|
+
}.compact
|
|
162
175
|
response = @client.request(
|
|
163
176
|
method: :get,
|
|
164
177
|
path: "/v1/extractions/#{Retab::Util.encode_path(extraction_id)}",
|
|
165
178
|
auth: true,
|
|
179
|
+
params: params,
|
|
166
180
|
request_options: request_options
|
|
167
181
|
)
|
|
168
182
|
result = Retab::Extraction.new(response.body)
|
|
@@ -191,6 +205,29 @@ module Retab
|
|
|
191
205
|
nil
|
|
192
206
|
end
|
|
193
207
|
|
|
208
|
+
# Cancel Extraction
|
|
209
|
+
# @param extraction_id [String]
|
|
210
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
211
|
+
# @return [Retab::Extraction]
|
|
212
|
+
def create_extraction_cancel(
|
|
213
|
+
extraction_id:,
|
|
214
|
+
request_options: {}
|
|
215
|
+
)
|
|
216
|
+
response = @client.request(
|
|
217
|
+
method: :post,
|
|
218
|
+
path: "/v1/extractions/#{Retab::Util.encode_path(extraction_id)}/cancel",
|
|
219
|
+
auth: true,
|
|
220
|
+
request_options: request_options
|
|
221
|
+
)
|
|
222
|
+
result = Retab::Extraction.new(response.body)
|
|
223
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
224
|
+
http_status: response.code.to_i,
|
|
225
|
+
http_headers: response.each_header.to_h,
|
|
226
|
+
request_id: response["x-request-id"]
|
|
227
|
+
)
|
|
228
|
+
result
|
|
229
|
+
end
|
|
230
|
+
|
|
194
231
|
# Get Extraction Sources
|
|
195
232
|
# @param extraction_id [String]
|
|
196
233
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
data/lib/retab/parses/parse.rb
CHANGED
|
@@ -13,6 +13,8 @@ module Retab
|
|
|
13
13
|
image_resolution_dpi: :image_resolution_dpi,
|
|
14
14
|
instructions: :instructions,
|
|
15
15
|
output: :output,
|
|
16
|
+
status: :status,
|
|
17
|
+
error: :error,
|
|
16
18
|
usage: :usage,
|
|
17
19
|
created_at: :created_at
|
|
18
20
|
}.freeze
|
|
@@ -25,6 +27,8 @@ module Retab
|
|
|
25
27
|
:image_resolution_dpi,
|
|
26
28
|
:instructions,
|
|
27
29
|
:output,
|
|
30
|
+
:status,
|
|
31
|
+
:error,
|
|
28
32
|
:usage,
|
|
29
33
|
:created_at
|
|
30
34
|
)
|
|
@@ -39,6 +43,8 @@ module Retab
|
|
|
39
43
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
40
44
|
@instructions = hash[:instructions]
|
|
41
45
|
@output = hash[:output] ? Retab::ParseOutput.new(hash[:output]) : nil
|
|
46
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
47
|
+
@error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
|
|
42
48
|
@usage = hash[:usage] ? Retab::RetabUsage.new(hash[:usage]) : nil
|
|
43
49
|
@created_at = hash[:created_at]
|
|
44
50
|
end
|
|
@@ -11,7 +11,8 @@ module Retab
|
|
|
11
11
|
table_parsing_format: :table_parsing_format,
|
|
12
12
|
image_resolution_dpi: :image_resolution_dpi,
|
|
13
13
|
instructions: :instructions,
|
|
14
|
-
bust_cache: :bust_cache
|
|
14
|
+
bust_cache: :bust_cache,
|
|
15
|
+
background: :background
|
|
15
16
|
}.freeze
|
|
16
17
|
|
|
17
18
|
attr_accessor(
|
|
@@ -20,7 +21,8 @@ module Retab
|
|
|
20
21
|
:table_parsing_format,
|
|
21
22
|
:image_resolution_dpi,
|
|
22
23
|
:instructions,
|
|
23
|
-
:bust_cache
|
|
24
|
+
:bust_cache,
|
|
25
|
+
:background
|
|
24
26
|
)
|
|
25
27
|
|
|
26
28
|
def initialize(json)
|
|
@@ -32,6 +34,7 @@ module Retab
|
|
|
32
34
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
33
35
|
@instructions = hash[:instructions]
|
|
34
36
|
@bust_cache = hash[:bust_cache].nil? ? false : hash[:bust_cache]
|
|
37
|
+
@background = hash[:background].nil? ? false : hash[:background]
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
40
|
end
|
data/lib/retab/parses.rb
CHANGED
|
@@ -80,6 +80,7 @@ module Retab
|
|
|
80
80
|
# @param image_resolution_dpi [Integer, nil] DPI used when rasterizing pages for the parser
|
|
81
81
|
# @param instructions [String, nil] Free-form instructions appended to the system prompt to steer the parse.
|
|
82
82
|
# @param bust_cache [Boolean, nil] If true, skip the LLM cache and force a fresh completion
|
|
83
|
+
# @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1/<primitive>/{id} until status is terminal. Mutually exclusive with stream.
|
|
83
84
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
84
85
|
# @return [Retab::Parse]
|
|
85
86
|
def create(
|
|
@@ -89,6 +90,7 @@ module Retab
|
|
|
89
90
|
image_resolution_dpi: nil,
|
|
90
91
|
instructions: nil,
|
|
91
92
|
bust_cache: nil,
|
|
93
|
+
background: nil,
|
|
92
94
|
request_options: {}
|
|
93
95
|
)
|
|
94
96
|
document = Retab::MimeData.coerce(document) unless document.nil?
|
|
@@ -98,7 +100,8 @@ module Retab
|
|
|
98
100
|
"table_parsing_format" => table_parsing_format,
|
|
99
101
|
"image_resolution_dpi" => image_resolution_dpi,
|
|
100
102
|
"instructions" => instructions,
|
|
101
|
-
"bust_cache" => bust_cache
|
|
103
|
+
"bust_cache" => bust_cache,
|
|
104
|
+
"background" => background
|
|
102
105
|
}.compact
|
|
103
106
|
response = @client.request(
|
|
104
107
|
method: :post,
|
|
@@ -118,16 +121,22 @@ module Retab
|
|
|
118
121
|
|
|
119
122
|
# Get Parse
|
|
120
123
|
# @param parse_id [String]
|
|
124
|
+
# @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
|
|
121
125
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
122
126
|
# @return [Retab::Parse]
|
|
123
127
|
def get(
|
|
124
128
|
parse_id:,
|
|
129
|
+
include_output: true,
|
|
125
130
|
request_options: {}
|
|
126
131
|
)
|
|
132
|
+
params = {
|
|
133
|
+
"include_output" => include_output
|
|
134
|
+
}.compact
|
|
127
135
|
response = @client.request(
|
|
128
136
|
method: :get,
|
|
129
137
|
path: "/v1/parses/#{Retab::Util.encode_path(parse_id)}",
|
|
130
138
|
auth: true,
|
|
139
|
+
params: params,
|
|
131
140
|
request_options: request_options
|
|
132
141
|
)
|
|
133
142
|
result = Retab::Parse.new(response.body)
|
|
@@ -155,5 +164,28 @@ module Retab
|
|
|
155
164
|
)
|
|
156
165
|
nil
|
|
157
166
|
end
|
|
167
|
+
|
|
168
|
+
# Cancel Parse
|
|
169
|
+
# @param parse_id [String]
|
|
170
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
171
|
+
# @return [Retab::Parse]
|
|
172
|
+
def cancel(
|
|
173
|
+
parse_id:,
|
|
174
|
+
request_options: {}
|
|
175
|
+
)
|
|
176
|
+
response = @client.request(
|
|
177
|
+
method: :post,
|
|
178
|
+
path: "/v1/parses/#{Retab::Util.encode_path(parse_id)}/cancel",
|
|
179
|
+
auth: true,
|
|
180
|
+
request_options: request_options
|
|
181
|
+
)
|
|
182
|
+
result = Retab::Parse.new(response.body)
|
|
183
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
184
|
+
http_status: response.code.to_i,
|
|
185
|
+
http_headers: response.each_header.to_h,
|
|
186
|
+
request_id: response["x-request-id"]
|
|
187
|
+
)
|
|
188
|
+
result
|
|
189
|
+
end
|
|
158
190
|
end
|
|
159
191
|
end
|