retab 0.1.4 → 0.1.6
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 +8 -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/files/create_file_blueprint_request.rb +31 -0
- data/lib/retab/files/file_blueprint.rb +52 -0
- data/lib/retab/files.rb +88 -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/schemas/generate_schema_request.rb +3 -3
- data/lib/retab/schemas/{partial_schema.rb → schema_generation.rb} +12 -3
- data/lib/retab/schemas.rb +5 -5
- data/lib/retab/{jobs/job_response.rb → secrets/create_secret_request.rb} +7 -7
- data/lib/retab/secrets/secret.rb +34 -0
- data/lib/retab/secrets/secret_list_response.rb +20 -0
- data/lib/retab/secrets/secret_response.rb +20 -0
- data/lib/retab/secrets/secret_value.rb +28 -0
- data/lib/retab/secrets/secret_value_response.rb +20 -0
- data/lib/retab/secrets/set_secret_request.rb +20 -0
- data/lib/retab/secrets.rb +154 -0
- 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/tables/body_create_table_v_1_tables_post.rb +28 -0
- data/lib/retab/tables/body_replace_table_v_1_tables_table_id_put.rb +25 -0
- data/lib/retab/tables/query_workflow_table_request.rb +72 -0
- data/lib/retab/{jobs/create_job_request.rb → tables/update_workflow_table_request.rb} +4 -7
- data/lib/retab/tables/workflow_table.rb +55 -0
- data/lib/retab/tables/workflow_table_aggregation_request.rb +28 -0
- data/lib/retab/tables/workflow_table_column.rb +34 -0
- data/lib/retab/tables/workflow_table_distinct_request.rb +20 -0
- data/lib/retab/tables/workflow_table_explain.rb +54 -0
- data/lib/retab/tables/workflow_table_filter_rule.rb +28 -0
- data/lib/retab/tables/workflow_table_list_response.rb +20 -0
- data/lib/retab/tables/workflow_table_profile_column.rb +49 -0
- data/lib/retab/tables/workflow_table_profile_response.rb +28 -0
- data/lib/retab/tables/workflow_table_response.rb +20 -0
- data/lib/retab/tables/workflow_table_row.rb +28 -0
- data/lib/retab/tables/workflow_table_rows_response.rb +52 -0
- data/lib/retab/tables/workflow_table_sample_request.rb +20 -0
- data/lib/retab/tables/workflow_table_schema_response.rb +25 -0
- data/lib/retab/tables/workflow_table_search_request.rb +25 -0
- data/lib/retab/tables/workflow_table_sort_rule.rb +25 -0
- data/lib/retab/{jobs/job_warning.rb → tables/workflow_table_tail_request.rb} +1 -1
- data/lib/retab/tables/workflow_table_validation_column_rule.rb +28 -0
- data/lib/retab/tables/workflow_table_validation_diagnostic.rb +31 -0
- data/lib/retab/tables/workflow_table_validation_request.rb +28 -0
- data/lib/retab/tables/workflow_table_validation_response.rb +30 -0
- data/lib/retab/tables.rb +356 -0
- 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/create_file_blueprint_request_mode.rb +13 -0
- data/lib/retab/types/declarative_plan_resource_change_type.rb +0 -2
- 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/file_blueprint_mode.rb +9 -0
- data/lib/retab/types/file_blueprint_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/schema_generation_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/types/validate_workflow_block_config_request_config_mode.rb +9 -0
- data/lib/retab/types/workflow_block_type.rb +0 -2
- data/lib/retab/types/workflow_table_aggregation_function.rb +17 -0
- data/lib/retab/types/workflow_table_filter_operator.rb +46 -0
- data/lib/retab/types/workflow_table_sort_direction.rb +9 -0
- data/lib/retab/types/workflow_table_validation_severity.rb +13 -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_blocks/validate_workflow_block_config_request.rb +25 -0
- data/lib/retab/workflow_blocks/validate_workflow_block_config_response.rb +34 -0
- data/lib/retab/workflow_blocks/workflow_block.rb +6 -0
- data/lib/retab/workflow_blocks.rb +38 -0
- data/lib/retab/workflow_steps.rb +2 -2
- data/lib/retab.rb +2 -1
- data/rbi/retab/body_create_table_v_1_tables_post.rbi +36 -0
- data/rbi/retab/body_replace_table_v_1_tables_table_id_put.rbi +30 -0
- 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 +6 -3
- data/rbi/retab/create_file_blueprint_request.rbi +42 -0
- data/rbi/retab/create_secret_request.rbi +30 -0
- 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/{job.rbi → file_blueprint.rbi} +29 -65
- data/rbi/retab/files.rbi +28 -0
- data/rbi/retab/generate_schema_request.rbi +2 -2
- 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/query_workflow_table_request.rbi +120 -0
- data/rbi/retab/{partial_schema.rbi → schema_generation.rbi} +19 -1
- data/rbi/retab/schemas.rbi +3 -3
- data/rbi/retab/secret.rbi +48 -0
- data/rbi/retab/secret_list_response.rbi +24 -0
- data/rbi/retab/secret_response.rbi +24 -0
- data/rbi/retab/secret_value.rbi +36 -0
- data/rbi/retab/secret_value_response.rbi +24 -0
- data/rbi/retab/secrets.rbi +62 -0
- data/rbi/retab/set_secret_request.rbi +24 -0
- 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
- data/rbi/retab/tables.rbi +127 -0
- data/rbi/retab/update_workflow_table_request.rbi +30 -0
- data/rbi/retab/{job_response.rbi → validate_workflow_block_config_request.rbi} +9 -9
- data/rbi/retab/validate_workflow_block_config_response.rbi +48 -0
- data/rbi/retab/workflow_block.rbi +12 -0
- data/rbi/retab/workflow_blocks.rbi +11 -0
- data/rbi/retab/workflow_table.rbi +90 -0
- data/rbi/retab/workflow_table_aggregation_request.rbi +36 -0
- data/rbi/retab/workflow_table_column.rbi +48 -0
- data/rbi/retab/workflow_table_distinct_request.rbi +24 -0
- data/rbi/retab/workflow_table_explain.rbi +84 -0
- data/rbi/retab/workflow_table_filter_rule.rbi +36 -0
- data/rbi/retab/workflow_table_list_response.rbi +24 -0
- data/rbi/retab/workflow_table_profile_column.rbi +78 -0
- data/rbi/retab/workflow_table_profile_response.rbi +36 -0
- data/rbi/retab/workflow_table_response.rbi +24 -0
- data/rbi/retab/{job_warning.rbi → workflow_table_row.rbi} +11 -11
- data/rbi/retab/workflow_table_rows_response.rbi +84 -0
- data/rbi/retab/workflow_table_sample_request.rbi +24 -0
- data/rbi/retab/workflow_table_schema_response.rbi +30 -0
- data/rbi/retab/workflow_table_search_request.rbi +30 -0
- data/rbi/retab/workflow_table_sort_rule.rbi +30 -0
- data/rbi/retab/workflow_table_tail_request.rbi +24 -0
- data/rbi/retab/workflow_table_validation_column_rule.rbi +36 -0
- data/rbi/retab/workflow_table_validation_diagnostic.rbi +42 -0
- data/rbi/retab/workflow_table_validation_request.rbi +36 -0
- data/rbi/retab/workflow_table_validation_response.rbi +36 -0
- metadata +107 -22
- data/lib/retab/jobs/job.rb +0 -70
- 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/jobs.rbi +0 -76
data/lib/retab/files.rb
CHANGED
|
@@ -88,6 +88,94 @@ module Retab
|
|
|
88
88
|
)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
# Create File Blueprint
|
|
92
|
+
# @param file_id [String] File id to analyze.
|
|
93
|
+
# @param mode [Retab::Types::CreateFileBlueprintRequestMode, nil] Optional analysis depth override. Omit to let Retab choose.
|
|
94
|
+
# @param intent [String, nil] Optional user intent used to guide the blueprint analysis.
|
|
95
|
+
# @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.
|
|
96
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
97
|
+
# @return [Retab::FileBlueprint]
|
|
98
|
+
def create_blueprint(
|
|
99
|
+
file_id:,
|
|
100
|
+
mode: nil,
|
|
101
|
+
intent: nil,
|
|
102
|
+
background: nil,
|
|
103
|
+
request_options: {}
|
|
104
|
+
)
|
|
105
|
+
body = {
|
|
106
|
+
"file_id" => file_id,
|
|
107
|
+
"mode" => mode,
|
|
108
|
+
"intent" => intent,
|
|
109
|
+
"background" => background
|
|
110
|
+
}.compact
|
|
111
|
+
response = @client.request(
|
|
112
|
+
method: :post,
|
|
113
|
+
path: "/v1/files/blueprints",
|
|
114
|
+
auth: true,
|
|
115
|
+
body: body,
|
|
116
|
+
request_options: request_options
|
|
117
|
+
)
|
|
118
|
+
result = Retab::FileBlueprint.new(response.body)
|
|
119
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
120
|
+
http_status: response.code.to_i,
|
|
121
|
+
http_headers: response.each_header.to_h,
|
|
122
|
+
request_id: response["x-request-id"]
|
|
123
|
+
)
|
|
124
|
+
result
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Get File Blueprint
|
|
128
|
+
# @param blueprint_id [String]
|
|
129
|
+
# @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
|
|
130
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
131
|
+
# @return [Retab::FileBlueprint]
|
|
132
|
+
def get_blueprint(
|
|
133
|
+
blueprint_id:,
|
|
134
|
+
include_output: true,
|
|
135
|
+
request_options: {}
|
|
136
|
+
)
|
|
137
|
+
params = {
|
|
138
|
+
"include_output" => include_output
|
|
139
|
+
}.compact
|
|
140
|
+
response = @client.request(
|
|
141
|
+
method: :get,
|
|
142
|
+
path: "/v1/files/blueprints/#{Retab::Util.encode_path(blueprint_id)}",
|
|
143
|
+
auth: true,
|
|
144
|
+
params: params,
|
|
145
|
+
request_options: request_options
|
|
146
|
+
)
|
|
147
|
+
result = Retab::FileBlueprint.new(response.body)
|
|
148
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
149
|
+
http_status: response.code.to_i,
|
|
150
|
+
http_headers: response.each_header.to_h,
|
|
151
|
+
request_id: response["x-request-id"]
|
|
152
|
+
)
|
|
153
|
+
result
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Cancel File Blueprint
|
|
157
|
+
# @param blueprint_id [String]
|
|
158
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
159
|
+
# @return [Retab::FileBlueprint]
|
|
160
|
+
def create_blueprint_cancel(
|
|
161
|
+
blueprint_id:,
|
|
162
|
+
request_options: {}
|
|
163
|
+
)
|
|
164
|
+
response = @client.request(
|
|
165
|
+
method: :post,
|
|
166
|
+
path: "/v1/files/blueprints/#{Retab::Util.encode_path(blueprint_id)}/cancel",
|
|
167
|
+
auth: true,
|
|
168
|
+
request_options: request_options
|
|
169
|
+
)
|
|
170
|
+
result = Retab::FileBlueprint.new(response.body)
|
|
171
|
+
result.last_response = Retab::Types::ApiResponse.new(
|
|
172
|
+
http_status: response.code.to_i,
|
|
173
|
+
http_headers: response.each_header.to_h,
|
|
174
|
+
request_id: response["x-request-id"]
|
|
175
|
+
)
|
|
176
|
+
result
|
|
177
|
+
end
|
|
178
|
+
|
|
91
179
|
# Upload File
|
|
92
180
|
# @param filename [String] Filename to store
|
|
93
181
|
# @param content_type [String, nil] MIME type the client will upload
|
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
|
|
@@ -14,6 +14,8 @@ module Retab
|
|
|
14
14
|
n_consensus: :n_consensus,
|
|
15
15
|
allow_overlap: :allow_overlap,
|
|
16
16
|
output: :output,
|
|
17
|
+
status: :status,
|
|
18
|
+
error: :error,
|
|
17
19
|
consensus: :consensus,
|
|
18
20
|
usage: :usage,
|
|
19
21
|
created_at: :created_at
|
|
@@ -28,6 +30,8 @@ module Retab
|
|
|
28
30
|
:n_consensus,
|
|
29
31
|
:allow_overlap,
|
|
30
32
|
:output,
|
|
33
|
+
:status,
|
|
34
|
+
:error,
|
|
31
35
|
:consensus,
|
|
32
36
|
:usage,
|
|
33
37
|
:created_at
|
|
@@ -44,6 +48,8 @@ module Retab
|
|
|
44
48
|
@n_consensus = hash[:n_consensus]
|
|
45
49
|
@allow_overlap = hash[:allow_overlap].nil? ? true : hash[:allow_overlap]
|
|
46
50
|
@output = (hash[:output] || []).map { |item| item ? Retab::PartitionChunk.new(item) : nil }
|
|
51
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
52
|
+
@error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
|
|
47
53
|
@consensus = hash[:consensus] ? Retab::PartitionConsensus.new(hash[:consensus]) : nil
|
|
48
54
|
@usage = hash[:usage] ? Retab::RetabUsage.new(hash[:usage]) : nil
|
|
49
55
|
@created_at = hash[:created_at]
|
|
@@ -12,7 +12,8 @@ module Retab
|
|
|
12
12
|
model: :model,
|
|
13
13
|
n_consensus: :n_consensus,
|
|
14
14
|
allow_overlap: :allow_overlap,
|
|
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
|
:model,
|
|
23
24
|
:n_consensus,
|
|
24
25
|
:allow_overlap,
|
|
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
|
@n_consensus = hash[:n_consensus]
|
|
36
38
|
@allow_overlap = hash[:allow_overlap].nil? ? true : hash[:allow_overlap]
|
|
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
|
data/lib/retab/partitions.rb
CHANGED
|
@@ -16,6 +16,7 @@ module Retab
|
|
|
16
16
|
# @param limit [Integer, nil]
|
|
17
17
|
# @param order [Retab::Types::PartitionsOrder, nil]
|
|
18
18
|
# @param filename [String, nil]
|
|
19
|
+
# @param status [Retab::Types::PartitionsStatus, 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 n_consensus [Integer, nil] Number of partitioning runs to use for consensus voting. Uses deterministic single-pass when set to 1.
|
|
82
87
|
# @param allow_overlap [Boolean, nil] If true, allow a page to appear in more than one partition chunk
|
|
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::Partition]
|
|
86
92
|
def create(
|
|
@@ -91,6 +97,7 @@ module Retab
|
|
|
91
97
|
n_consensus: nil,
|
|
92
98
|
allow_overlap: 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
|
"model" => model,
|
|
102
109
|
"n_consensus" => n_consensus,
|
|
103
110
|
"allow_overlap" => allow_overlap,
|
|
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 Partition
|
|
123
131
|
# @param partition_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::Partition]
|
|
126
135
|
def get(
|
|
127
136
|
partition_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/partitions/#{Retab::Util.encode_path(partition_id)}",
|
|
133
146
|
auth: true,
|
|
147
|
+
params: params,
|
|
134
148
|
request_options: request_options
|
|
135
149
|
)
|
|
136
150
|
result = Retab::Partition.new(response.body)
|
|
@@ -158,5 +172,28 @@ module Retab
|
|
|
158
172
|
)
|
|
159
173
|
nil
|
|
160
174
|
end
|
|
175
|
+
|
|
176
|
+
# Cancel Partition
|
|
177
|
+
# @param partition_id [String]
|
|
178
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
179
|
+
# @return [Retab::Partition]
|
|
180
|
+
def create_partition_cancel(
|
|
181
|
+
partition_id:,
|
|
182
|
+
request_options: {}
|
|
183
|
+
)
|
|
184
|
+
response = @client.request(
|
|
185
|
+
method: :post,
|
|
186
|
+
path: "/v1/partitions/#{Retab::Util.encode_path(partition_id)}/cancel",
|
|
187
|
+
auth: true,
|
|
188
|
+
request_options: request_options
|
|
189
|
+
)
|
|
190
|
+
result = Retab::Partition.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
|
|
@@ -10,7 +10,7 @@ module Retab
|
|
|
10
10
|
model: :model,
|
|
11
11
|
instructions: :instructions,
|
|
12
12
|
image_resolution_dpi: :image_resolution_dpi,
|
|
13
|
-
|
|
13
|
+
background: :background
|
|
14
14
|
}.freeze
|
|
15
15
|
|
|
16
16
|
attr_accessor(
|
|
@@ -18,7 +18,7 @@ module Retab
|
|
|
18
18
|
:model,
|
|
19
19
|
:instructions,
|
|
20
20
|
:image_resolution_dpi,
|
|
21
|
-
:
|
|
21
|
+
:background
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
def initialize(json)
|
|
@@ -28,7 +28,7 @@ module Retab
|
|
|
28
28
|
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
29
29
|
@instructions = hash[:instructions]
|
|
30
30
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
31
|
-
@
|
|
31
|
+
@background = hash[:background].nil? ? false : hash[:background]
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
|
@@ -3,20 +3,26 @@
|
|
|
3
3
|
# This file is auto-generated by oagen. Do not edit.
|
|
4
4
|
|
|
5
5
|
module Retab
|
|
6
|
-
class
|
|
6
|
+
class SchemaGeneration < Retab::Types::BaseModel
|
|
7
7
|
|
|
8
8
|
HASH_ATTRS = {
|
|
9
9
|
object: :object,
|
|
10
10
|
created_at: :created_at,
|
|
11
11
|
json_schema: :json_schema,
|
|
12
|
-
strict: :strict
|
|
12
|
+
strict: :strict,
|
|
13
|
+
id: :id,
|
|
14
|
+
status: :status,
|
|
15
|
+
error: :error
|
|
13
16
|
}.freeze
|
|
14
17
|
|
|
15
18
|
attr_accessor(
|
|
16
19
|
:object,
|
|
17
20
|
:created_at,
|
|
18
21
|
:json_schema,
|
|
19
|
-
:strict
|
|
22
|
+
:strict,
|
|
23
|
+
:id,
|
|
24
|
+
:status,
|
|
25
|
+
:error
|
|
20
26
|
)
|
|
21
27
|
|
|
22
28
|
def initialize(json)
|
|
@@ -26,6 +32,9 @@ module Retab
|
|
|
26
32
|
@created_at = hash[:created_at]
|
|
27
33
|
@json_schema = hash[:json_schema] || {}
|
|
28
34
|
@strict = hash[:strict].nil? ? true : hash[:strict]
|
|
35
|
+
@id = hash[:id]
|
|
36
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
37
|
+
@error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
|
|
29
38
|
end
|
|
30
39
|
end
|
|
31
40
|
end
|
data/lib/retab/schemas.rb
CHANGED
|
@@ -15,15 +15,15 @@ module Retab
|
|
|
15
15
|
# @param model [String, nil]
|
|
16
16
|
# @param instructions [String, nil]
|
|
17
17
|
# @param image_resolution_dpi [Integer, nil] Resolution of the image sent to the LLM
|
|
18
|
-
# @param
|
|
18
|
+
# @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued'. Poll GET /v1/schemas/generate/{schema_generation_id} until status is terminal.
|
|
19
19
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
20
|
-
# @return [Retab::
|
|
20
|
+
# @return [Retab::SchemaGeneration]
|
|
21
21
|
def generate(
|
|
22
22
|
documents:,
|
|
23
23
|
model: nil,
|
|
24
24
|
instructions: nil,
|
|
25
25
|
image_resolution_dpi: nil,
|
|
26
|
-
|
|
26
|
+
background: nil,
|
|
27
27
|
request_options: {}
|
|
28
28
|
)
|
|
29
29
|
documents = documents.map { |d| Retab::MimeData.coerce(d) } unless documents.nil?
|
|
@@ -32,7 +32,7 @@ module Retab
|
|
|
32
32
|
"model" => model,
|
|
33
33
|
"instructions" => instructions,
|
|
34
34
|
"image_resolution_dpi" => image_resolution_dpi,
|
|
35
|
-
"
|
|
35
|
+
"background" => background
|
|
36
36
|
}.compact
|
|
37
37
|
response = @client.request(
|
|
38
38
|
method: :post,
|
|
@@ -41,7 +41,7 @@ module Retab
|
|
|
41
41
|
body: body,
|
|
42
42
|
request_options: request_options
|
|
43
43
|
)
|
|
44
|
-
result = Retab::
|
|
44
|
+
result = Retab::SchemaGeneration.new(response.body)
|
|
45
45
|
result.last_response = Retab::Types::ApiResponse.new(
|
|
46
46
|
http_status: response.code.to_i,
|
|
47
47
|
http_headers: response.each_header.to_h,
|
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
# This file is auto-generated by oagen. Do not edit.
|
|
4
4
|
|
|
5
5
|
module Retab
|
|
6
|
-
class
|
|
6
|
+
class CreateSecretRequest < Retab::Types::BaseModel
|
|
7
7
|
|
|
8
8
|
HASH_ATTRS = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
name: :name,
|
|
10
|
+
value: :value
|
|
11
11
|
}.freeze
|
|
12
12
|
|
|
13
13
|
attr_accessor(
|
|
14
|
-
:
|
|
15
|
-
:
|
|
14
|
+
:name,
|
|
15
|
+
:value
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
def initialize(json)
|
|
19
19
|
super()
|
|
20
20
|
hash = self.class.normalize(json)
|
|
21
|
-
@
|
|
22
|
-
@
|
|
21
|
+
@name = hash[:name]
|
|
22
|
+
@value = hash[:value]
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class Secret < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
name: :name,
|
|
10
|
+
created_at: :created_at,
|
|
11
|
+
updated_at: :updated_at,
|
|
12
|
+
created_by: :created_by,
|
|
13
|
+
updated_by: :updated_by
|
|
14
|
+
}.freeze
|
|
15
|
+
|
|
16
|
+
attr_accessor(
|
|
17
|
+
:name,
|
|
18
|
+
:created_at,
|
|
19
|
+
:updated_at,
|
|
20
|
+
:created_by,
|
|
21
|
+
:updated_by
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def initialize(json)
|
|
25
|
+
super()
|
|
26
|
+
hash = self.class.normalize(json)
|
|
27
|
+
@name = hash[:name]
|
|
28
|
+
@created_at = hash[:created_at]
|
|
29
|
+
@updated_at = hash[:updated_at]
|
|
30
|
+
@created_by = hash[:created_by]
|
|
31
|
+
@updated_by = hash[:updated_by]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class SecretListResponse < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
secrets: :secrets
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
attr_accessor :secrets
|
|
13
|
+
|
|
14
|
+
def initialize(json)
|
|
15
|
+
super()
|
|
16
|
+
hash = self.class.normalize(json)
|
|
17
|
+
@secrets = (hash[:secrets] || []).map { |item| item ? Retab::Secret.new(item) : nil }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class SecretResponse < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
secret: :secret
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
attr_accessor :secret
|
|
13
|
+
|
|
14
|
+
def initialize(json)
|
|
15
|
+
super()
|
|
16
|
+
hash = self.class.normalize(json)
|
|
17
|
+
@secret = hash[:secret] ? Retab::Secret.new(hash[:secret]) : nil
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class SecretValue < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
name: :name,
|
|
10
|
+
value: :value,
|
|
11
|
+
updated_at: :updated_at
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
attr_accessor(
|
|
15
|
+
:name,
|
|
16
|
+
:value,
|
|
17
|
+
:updated_at
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def initialize(json)
|
|
21
|
+
super()
|
|
22
|
+
hash = self.class.normalize(json)
|
|
23
|
+
@name = hash[:name]
|
|
24
|
+
@value = hash[:value]
|
|
25
|
+
@updated_at = hash[:updated_at]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class SecretValueResponse < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
secret: :secret
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
attr_accessor :secret
|
|
13
|
+
|
|
14
|
+
def initialize(json)
|
|
15
|
+
super()
|
|
16
|
+
hash = self.class.normalize(json)
|
|
17
|
+
@secret = hash[:secret] ? Retab::SecretValue.new(hash[:secret]) : nil
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class SetSecretRequest < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
value: :value
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
attr_accessor :value
|
|
13
|
+
|
|
14
|
+
def initialize(json)
|
|
15
|
+
super()
|
|
16
|
+
hash = self.class.normalize(json)
|
|
17
|
+
@value = hash[:value]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|