retab 0.1.8 → 0.1.10
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/base_client.rb +1 -5
- data/lib/retab/classifications/file_ref.rb +1 -22
- data/lib/retab/classifications.rb +1 -1
- data/lib/retab/edit_templates.rb +1 -1
- data/lib/retab/edits.rb +1 -1
- data/lib/retab/experiment_run_metrics/experiment_metrics_stale_error.rb +3 -3
- data/lib/retab/experiment_run_metrics/experiment_summary_metrics_response.rb +3 -3
- data/lib/retab/experiment_run_metrics/metrics_stale_error_last_run.rb +3 -3
- data/lib/retab/experiment_run_results/error_workflow_experiment_result.rb +1 -22
- data/lib/retab/experiment_run_results/pending_workflow_experiment_result.rb +1 -1
- data/lib/retab/experiment_run_results/queued_workflow_experiment_result.rb +1 -1
- data/lib/retab/experiment_run_results/running_workflow_experiment_result.rb +1 -1
- data/lib/retab/experiment_runs/create_experiment_run_request.rb +5 -2
- data/lib/retab/experiment_runs/error_workflow_experiment_run.rb +1 -1
- data/lib/retab/experiment_runs/experiment_run.rb +3 -3
- data/lib/retab/experiment_runs/pending_workflow_experiment_run.rb +1 -1
- data/lib/retab/experiment_runs/queued_workflow_experiment_run.rb +1 -1
- data/lib/retab/experiment_runs/running_workflow_experiment_run.rb +1 -1
- data/lib/retab/experiment_runs.rb +4 -1
- data/lib/retab/extractions/extraction.rb +0 -3
- data/lib/retab/extractions/extraction_request.rb +0 -3
- data/lib/retab/extractions.rb +53 -4
- data/lib/retab/files/create_file_blueprint_request.rb +3 -3
- data/lib/retab/files/file_blueprint.rb +5 -5
- data/lib/retab/files.rb +3 -3
- data/lib/retab/mime.rb +77 -6
- data/lib/retab/parses/parse.rb +0 -3
- data/lib/retab/parses/parse_request.rb +0 -3
- data/lib/retab/parses.rb +1 -4
- data/lib/retab/partitions.rb +1 -1
- data/lib/retab/schemas/generate_schema_request.rb +0 -3
- data/lib/retab/schemas.rb +1 -4
- data/lib/retab/splits.rb +1 -1
- data/lib/retab/types/{workflow_test_run_results_order.rb → eval_run_freshness_reasons.rb} +1 -1
- data/lib/retab/types/eval_run_freshness_status.rb +9 -0
- data/lib/retab/types/eval_run_trigger_type.rb +18 -0
- data/lib/retab/types/{latest_block_test_run_summary_outcome.rb → latest_block_eval_run_summary_outcome.rb} +1 -1
- data/lib/retab/types/{latest_block_test_run_summary_status.rb → latest_block_eval_run_summary_status.rb} +1 -1
- data/lib/retab/types/trigger_info_type.rb +1 -10
- data/lib/retab/types/{workflow_test_runs_order.rb → workflow_eval_result_verdict.rb} +1 -1
- data/lib/retab/types/workflow_eval_run_results_order.rb +9 -0
- data/lib/retab/types/{workflow_test_result_verdict.rb → workflow_eval_runs_order.rb} +1 -1
- data/lib/retab/types/workflow_eval_schema_drift.rb +9 -0
- data/lib/retab/types/{workflow_tests_order.rb → workflow_evals_order.rb} +1 -1
- data/lib/retab/types/workflow_experiment_freshness_state.rb +9 -0
- data/lib/retab/types/workflow_experiment_run_plan_mode.rb +15 -0
- data/lib/retab/types/workflow_experiments_exclude_status.rb +1 -1
- data/lib/retab/types/workflow_experiments_status.rb +1 -1
- data/lib/retab/version.rb +1 -1
- data/lib/retab/workflow_artifacts/extraction_workflow_artifact.rb +0 -3
- data/lib/retab/workflow_artifacts/parse_workflow_artifact.rb +0 -3
- data/lib/retab/workflow_artifacts/workflow_artifact.rb +5 -2
- data/lib/retab/{workflow_experiments/file_handle_input.rb → workflow_block_executions/block_exec_file_handle_input.rb} +6 -6
- data/lib/retab/workflow_block_executions/block_exec_file_ref.rb +28 -0
- data/lib/retab/{workflow_experiments/json_handle_input.rb → workflow_block_executions/block_exec_json_handle_input.rb} +6 -6
- data/lib/retab/workflow_block_executions/cancelled_block_execution_lifecycle.rb +25 -0
- data/lib/retab/workflow_block_executions/pending_block_execution_lifecycle.rb +20 -0
- data/lib/retab/workflow_block_executions/queued_block_execution_lifecycle.rb +20 -0
- data/lib/retab/workflow_block_executions/running_block_execution_lifecycle.rb +20 -0
- data/lib/retab/workflow_block_executions/stored_block_execution.rb +29 -0
- data/lib/retab/workflow_edges.rb +6 -0
- data/lib/retab/{workflow_test_run_results/cancelled_workflow_test_run.rb → workflow_eval_run_results/cancelled_workflow_eval_run.rb} +1 -1
- data/lib/retab/{workflow_test_run_results/completed_workflow_test_run.rb → workflow_eval_run_results/completed_workflow_eval_run.rb} +1 -1
- data/lib/retab/workflow_eval_run_results/error_workflow_eval_run.rb +28 -0
- data/lib/retab/{workflow_test_run_results/queued_workflow_test_run.rb → workflow_eval_run_results/file_handle_input.rb} +1 -1
- data/lib/retab/{workflow_test_run_results/workflow_test_run_timing.rb → workflow_eval_run_results/json_handle_input.rb} +1 -1
- data/lib/retab/workflow_eval_run_results/pending_workflow_eval_run.rb +7 -0
- data/lib/retab/{workflow_test_run_results/error_workflow_test_run.rb → workflow_eval_run_results/queued_workflow_eval_run.rb} +1 -1
- data/lib/retab/{workflow_test_run_results/pending_workflow_test_run.rb → workflow_eval_run_results/result_file_ref.rb} +1 -1
- data/lib/retab/workflow_eval_run_results/running_workflow_eval_run.rb +7 -0
- data/lib/retab/{workflow_test_run_results/workflow_test_result.rb → workflow_eval_run_results/workflow_eval_result.rb} +32 -41
- data/lib/retab/workflow_eval_run_results/workflow_eval_run_timing.rb +7 -0
- data/lib/retab/{workflow_test_run_results.rb → workflow_eval_run_results.rb} +10 -10
- data/lib/retab/{workflow_test_runs/block_test_batch_execution_counts.rb → workflow_eval_runs/block_eval_batch_execution_counts.rb} +3 -3
- data/lib/retab/{workflow_test_runs/block_test_lifecycle_counts.rb → workflow_eval_runs/block_eval_lifecycle_counts.rb} +1 -1
- data/lib/retab/{workflow_test_runs/block_test_outcome_counts.rb → workflow_eval_runs/block_eval_outcome_counts.rb} +1 -1
- data/lib/retab/{workflow_test_runs/create_workflow_test_run_request.rb → workflow_eval_runs/create_workflow_eval_run_request.rb} +4 -4
- data/lib/retab/{workflow_tests/workflow_test_block_target.rb → workflow_eval_runs/eval_run_block_target.rb} +1 -1
- data/lib/retab/workflow_eval_runs/eval_run_freshness.rb +34 -0
- data/lib/retab/{workflow_test_runs/workflow_test_run_workflow_scope.rb → workflow_eval_runs/eval_run_trigger.rb} +1 -1
- data/lib/retab/{workflow_test_runs/workflow_test_run.rb → workflow_eval_runs/workflow_eval_run.rb} +18 -18
- data/lib/retab/{workflow_test_runs/workflow_test_run_block_scope.rb → workflow_eval_runs/workflow_eval_run_block_scope.rb} +1 -1
- data/lib/retab/{workflow_test_runs/workflow_test_run_single_scope.rb → workflow_eval_runs/workflow_eval_run_single_scope.rb} +4 -4
- data/lib/retab/workflow_eval_runs/workflow_eval_run_workflow_scope.rb +20 -0
- data/lib/retab/{workflow_test_runs.rb → workflow_eval_runs.rb} +24 -24
- data/lib/retab/{workflow_tests/create_workflow_test_request.rb → workflow_evals/create_workflow_eval_request.rb} +4 -4
- data/lib/retab/workflow_evals/eval_file_handle_input.rb +7 -0
- data/lib/retab/workflow_evals/eval_json_handle_input.rb +7 -0
- data/lib/retab/{workflow_test_run_results/running_workflow_test_run.rb → workflow_evals/eval_public_file_ref.rb} +1 -1
- data/lib/retab/{workflow_tests/latest_block_test_run_summary.rb → workflow_evals/latest_block_eval_run_summary.rb} +4 -4
- data/lib/retab/{workflow_tests/manual_workflow_test_source.rb → workflow_evals/manual_workflow_eval_source.rb} +1 -1
- data/lib/retab/{workflow_tests/run_step_workflow_test_source.rb → workflow_evals/run_step_workflow_eval_source.rb} +1 -1
- data/lib/retab/{workflow_tests/update_workflow_test_request.rb → workflow_evals/update_workflow_eval_request.rb} +3 -3
- data/lib/retab/{workflow_tests/workflow_test.rb → workflow_evals/workflow_eval.rb} +7 -7
- data/lib/retab/workflow_evals/workflow_eval_block_target.rb +7 -0
- data/lib/retab/{workflow_tests.rb → workflow_evals.rb} +31 -31
- data/lib/retab/workflow_experiments/workflow_experiment.rb +12 -0
- data/lib/retab/workflow_runs/pending_run.rb +1 -14
- data/lib/retab/workflow_runs/running_run.rb +1 -14
- data/lib/retab/workflow_runs.rb +1 -1
- data/lib/retab/workflow_steps/pending_step_lifecycle.rb +1 -1
- data/lib/retab/workflow_steps/queued_step_lifecycle.rb +1 -14
- data/lib/retab/workflow_steps/running_step_lifecycle.rb +1 -1
- data/lib/retab/workflows.rb +2 -2
- data/lib/retab.rb +3 -3
- data/rbi/retab/{block_test_batch_execution_counts.rbi → block_eval_batch_execution_counts.rbi} +5 -5
- data/rbi/retab/{block_test_lifecycle_counts.rbi → block_eval_lifecycle_counts.rbi} +1 -1
- data/rbi/retab/{block_test_outcome_counts.rbi → block_eval_outcome_counts.rbi} +1 -1
- data/rbi/retab/block_exec_file_handle_input.rbi +30 -0
- data/rbi/retab/block_exec_file_ref.rbi +36 -0
- data/rbi/retab/block_exec_json_handle_input.rbi +30 -0
- data/rbi/retab/cancelled_block_execution_lifecycle.rbi +30 -0
- data/rbi/retab/{cancelled_workflow_test_run.rbi → cancelled_workflow_eval_run.rbi} +1 -1
- data/rbi/retab/classification_request.rbi +2 -2
- data/rbi/retab/{completed_workflow_test_run.rbi → completed_workflow_eval_run.rbi} +1 -1
- data/rbi/retab/create_experiment_run_request.rbi +6 -0
- data/rbi/retab/create_file_blueprint_request.rbi +4 -4
- data/rbi/retab/{create_workflow_test_request.rbi → create_workflow_eval_request.rbi} +5 -5
- data/rbi/retab/{create_workflow_test_run_request.rbi → create_workflow_eval_run_request.rbi} +3 -3
- data/rbi/retab/create_workflow_run_request.rbi +2 -2
- data/rbi/retab/edit_request.rbi +2 -2
- data/rbi/retab/{error_workflow_test_run.rbi → error_workflow_eval_run.rbi} +1 -1
- data/rbi/retab/eval_file_handle_input.rbi +30 -0
- data/rbi/retab/eval_json_handle_input.rbi +30 -0
- data/rbi/retab/eval_public_file_ref.rbi +36 -0
- data/rbi/retab/{workflow_test_block_target.rbi → eval_run_block_target.rbi} +1 -1
- data/rbi/retab/eval_run_freshness.rbi +48 -0
- data/rbi/retab/{workflow_test_run_workflow_scope.rbi → eval_run_trigger.rbi} +1 -1
- data/rbi/retab/experiment_metrics_stale_error.rbi +2 -2
- data/rbi/retab/experiment_run.rbi +2 -2
- data/rbi/retab/experiment_runs.rbi +2 -1
- data/rbi/retab/experiment_summary_metrics_response.rbi +2 -2
- data/rbi/retab/extraction.rbi +0 -6
- data/rbi/retab/extraction_request.rbi +2 -8
- data/rbi/retab/extraction_workflow_artifact.rbi +0 -6
- data/rbi/retab/extractions.rbi +19 -2
- data/rbi/retab/file_blueprint.rbi +6 -6
- data/rbi/retab/file_handle_input.rbi +2 -2
- data/rbi/retab/files.rbi +2 -2
- data/rbi/retab/generate_schema_request.rbi +0 -6
- data/rbi/retab/{latest_block_test_run_summary.rbi → latest_block_eval_run_summary.rbi} +3 -3
- data/rbi/retab/{manual_workflow_test_source.rbi → manual_workflow_eval_source.rbi} +3 -3
- data/rbi/retab/metrics_stale_error_last_run.rbi +2 -2
- data/rbi/retab/parse.rbi +0 -6
- data/rbi/retab/parse_request.rbi +2 -8
- data/rbi/retab/parse_workflow_artifact.rbi +0 -6
- data/rbi/retab/parses.rbi +1 -2
- data/rbi/retab/partition_request.rbi +2 -2
- data/rbi/retab/pending_block_execution_lifecycle.rbi +24 -0
- data/rbi/retab/{pending_workflow_test_run.rbi → pending_workflow_eval_run.rbi} +1 -1
- data/rbi/retab/queued_block_execution_lifecycle.rbi +24 -0
- data/rbi/retab/{queued_workflow_test_run.rbi → queued_workflow_eval_run.rbi} +1 -1
- data/rbi/retab/result_file_ref.rbi +36 -0
- data/rbi/retab/{run_step_workflow_test_source.rbi → run_step_workflow_eval_source.rbi} +1 -1
- data/rbi/retab/running_block_execution_lifecycle.rbi +24 -0
- data/rbi/retab/{running_workflow_test_run.rbi → running_workflow_eval_run.rbi} +1 -1
- data/rbi/retab/schemas.rbi +1 -2
- data/rbi/retab/split_request.rbi +2 -2
- data/rbi/retab/stored_block_execution.rbi +48 -6
- data/rbi/retab/{update_workflow_test_request.rbi → update_workflow_eval_request.rbi} +3 -3
- data/rbi/retab/workflow_artifact.rbi +6 -0
- data/rbi/retab/workflow_edges.rbi +2 -1
- data/rbi/retab/{workflow_test.rbi → workflow_eval.rbi} +11 -11
- data/rbi/retab/workflow_eval_block_target.rbi +30 -0
- data/rbi/retab/{workflow_test_result.rbi → workflow_eval_result.rbi} +35 -35
- data/rbi/retab/workflow_eval_run.rbi +84 -0
- data/rbi/retab/{workflow_test_run_block_scope.rbi → workflow_eval_run_block_scope.rbi} +1 -1
- data/rbi/retab/{workflow_test_run_results.rbi → workflow_eval_run_results.rbi} +3 -3
- data/rbi/retab/{workflow_test_run_single_scope.rbi → workflow_eval_run_single_scope.rbi} +3 -3
- data/rbi/retab/{workflow_test_run_timing.rbi → workflow_eval_run_timing.rbi} +1 -1
- data/rbi/retab/workflow_eval_run_workflow_scope.rbi +24 -0
- data/rbi/retab/{workflow_test_runs.rbi → workflow_eval_runs.rbi} +8 -8
- data/rbi/retab/{workflow_tests.rbi → workflow_evals.rbi} +16 -16
- data/rbi/retab/workflow_experiment.rbi +24 -0
- data/rbi/retab/workflows.rbi +2 -2
- metadata +125 -92
- data/lib/retab/types/workflow_test_schema_drift.rb +0 -9
- data/rbi/retab/workflow_test_run.rbi +0 -84
- /data/lib/retab/{workflow_test_run_results → workflow_eval_run_results}/assertion_failure.rb +0 -0
- /data/lib/retab/{workflow_test_run_results → workflow_eval_run_results}/assertion_result.rb +0 -0
- /data/lib/retab/{workflow_test_run_results → workflow_eval_run_results}/verdict_summary.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/all_items_match_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/any_item_matches_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/array_contains_condition.rb +0 -0
- /data/lib/retab/{workflow_experiments → workflow_evals}/artifact_drift.rb +0 -0
- /data/lib/retab/{workflow_experiments → workflow_evals}/artifact_freshness.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/assertion_schema_dep.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/assertion_spec.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/between_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/contain_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/ends_with_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/equal_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/exist_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/json_schema_valid_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/length_compare_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/llm_judged_as_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/llm_not_judged_as_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/matche_regex_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/not_contains_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/not_equals_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/not_exists_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/number_compare_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/object_contains_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/output_target.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/similarity_gte_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/split_iou_condition.rb +0 -0
- /data/lib/retab/{workflow_tests → workflow_evals}/start_with_condition.rb +0 -0
data/lib/retab/mime.rb
CHANGED
|
@@ -69,7 +69,22 @@ module Retab
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# Single entry point used by every generator-emitted resource method.
|
|
72
|
-
|
|
72
|
+
#
|
|
73
|
+
# A file-id document input (a `Retab::FileRef` object, or a Hash
|
|
74
|
+
# carrying an `:id` key) is resolved CLIENT-SIDE into URL-backed
|
|
75
|
+
# MimeData by calling the Files download-link endpoint — the document
|
|
76
|
+
# routes now accept only URL-backed MimeData `{filename, url}` and 422
|
|
77
|
+
# a file-id wire body. Mirrors the Node SDK and Go CLI
|
|
78
|
+
# (`resolveFileIDToMIMEData`). `client:` is the `Retab::Client`
|
|
79
|
+
# threaded through from the resource method body; it must be present to
|
|
80
|
+
# resolve a file-id input.
|
|
81
|
+
def self.coerce(input = nil, client: nil, **rest)
|
|
82
|
+
# Backward-compatible bare-keyword form: `coerce(filename: ..., url: ...)`
|
|
83
|
+
# slurps the keywords (minus `client:`) into the Hash input shape.
|
|
84
|
+
input = rest if input.nil? && !rest.empty?
|
|
85
|
+
|
|
86
|
+
return resolve_file_ref(input, client: client) if file_ref_like?(input)
|
|
87
|
+
|
|
73
88
|
case input
|
|
74
89
|
when MimeData
|
|
75
90
|
input
|
|
@@ -89,14 +104,12 @@ module Retab
|
|
|
89
104
|
end
|
|
90
105
|
end
|
|
91
106
|
|
|
92
|
-
def self.coerce_document_map(input)
|
|
107
|
+
def self.coerce_document_map(input, client: nil)
|
|
93
108
|
unless input.respond_to?(:transform_values)
|
|
94
109
|
raise ArgumentError, "cannot coerce #{input.class} to a Retab::MimeData document map"
|
|
95
110
|
end
|
|
96
111
|
|
|
97
|
-
input.transform_values
|
|
98
|
-
file_ref_like?(document) ? document : coerce(document)
|
|
99
|
-
end
|
|
112
|
+
input.transform_values { |document| coerce(document, client: client) }
|
|
100
113
|
end
|
|
101
114
|
|
|
102
115
|
def to_h
|
|
@@ -140,13 +153,71 @@ module Retab
|
|
|
140
153
|
)
|
|
141
154
|
end
|
|
142
155
|
|
|
156
|
+
# A file-id document input: either a spec-derived FileRef-like model
|
|
157
|
+
# exposing `#id`, or a Hash carrying an `:id` / `'id'` key. These no
|
|
158
|
+
# longer serialize over the wire — `coerce` resolves them into
|
|
159
|
+
# URL-backed MimeData via the Files download-link endpoint.
|
|
143
160
|
private_class_method def self.file_ref_like?(input)
|
|
144
|
-
return
|
|
161
|
+
return false if input.is_a?(MimeData)
|
|
162
|
+
return true if input.respond_to?(:id) && !input.is_a?(Hash) && !input.is_a?(String)
|
|
145
163
|
return false unless input.is_a?(Hash)
|
|
146
164
|
|
|
147
165
|
input.key?(:id) || input.key?("id")
|
|
148
166
|
end
|
|
149
167
|
|
|
168
|
+
private_class_method def self.file_ref_id(input)
|
|
169
|
+
if input.is_a?(Hash)
|
|
170
|
+
sym = input.transform_keys { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
|
|
171
|
+
sym[:id]
|
|
172
|
+
elsif input.respond_to?(:id)
|
|
173
|
+
input.id
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
private_class_method def self.file_ref_filename(input)
|
|
178
|
+
if input.is_a?(Hash)
|
|
179
|
+
sym = input.transform_keys { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
|
|
180
|
+
sym[:filename]
|
|
181
|
+
elsif input.respond_to?(:filename)
|
|
182
|
+
input.filename
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Resolve a file-id document input into URL-backed MimeData by calling
|
|
187
|
+
# the Files download-link endpoint. Mirrors the Node SDK and the Go CLI
|
|
188
|
+
# `resolveFileIDToMIMEData`: prefer the link's durable `mime_data`, then
|
|
189
|
+
# fall back to its `download_url`; filename precedence is
|
|
190
|
+
# input.filename → mime_data.filename → link.filename → 'document'.
|
|
191
|
+
private_class_method def self.resolve_file_ref(input, client:)
|
|
192
|
+
file_id = file_ref_id(input)
|
|
193
|
+
if file_id.nil? || file_id.to_s.empty?
|
|
194
|
+
raise ArgumentError, "file-id document input is missing an id"
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
if client.nil?
|
|
198
|
+
raise(
|
|
199
|
+
ArgumentError,
|
|
200
|
+
"cannot resolve file-id #{file_id} document input without a client; " \
|
|
201
|
+
"pass URL-backed MimeData instead"
|
|
202
|
+
)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
link = client.files.get_download_link(file_id: file_id)
|
|
206
|
+
mime_data = link.mime_data
|
|
207
|
+
input_filename = file_ref_filename(input)
|
|
208
|
+
|
|
209
|
+
filename = input_filename ||
|
|
210
|
+
(mime_data && mime_data.filename) ||
|
|
211
|
+
link.filename ||
|
|
212
|
+
"document"
|
|
213
|
+
url = (mime_data && mime_data.url) || link.download_url
|
|
214
|
+
if url.nil? || url.to_s.empty?
|
|
215
|
+
raise ArgumentError, "file-id #{file_id}: server returned no download URL"
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
new(filename: filename, url: url)
|
|
219
|
+
end
|
|
220
|
+
|
|
150
221
|
private_class_method def self.from_string(str)
|
|
151
222
|
if str.match?(%r{\A(https?|gs|data):}i)
|
|
152
223
|
# It's a URL.
|
data/lib/retab/parses/parse.rb
CHANGED
|
@@ -10,7 +10,6 @@ module Retab
|
|
|
10
10
|
file: :file,
|
|
11
11
|
model: :model,
|
|
12
12
|
table_parsing_format: :table_parsing_format,
|
|
13
|
-
image_resolution_dpi: :image_resolution_dpi,
|
|
14
13
|
instructions: :instructions,
|
|
15
14
|
output: :output,
|
|
16
15
|
status: :status,
|
|
@@ -24,7 +23,6 @@ module Retab
|
|
|
24
23
|
:file,
|
|
25
24
|
:model,
|
|
26
25
|
:table_parsing_format,
|
|
27
|
-
:image_resolution_dpi,
|
|
28
26
|
:instructions,
|
|
29
27
|
:output,
|
|
30
28
|
:status,
|
|
@@ -40,7 +38,6 @@ module Retab
|
|
|
40
38
|
@file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
|
|
41
39
|
@model = hash[:model]
|
|
42
40
|
@table_parsing_format = hash[:table_parsing_format]
|
|
43
|
-
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
44
41
|
@instructions = hash[:instructions]
|
|
45
42
|
@output = hash[:output] ? Retab::ParseOutput.new(hash[:output]) : nil
|
|
46
43
|
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
@@ -9,7 +9,6 @@ module Retab
|
|
|
9
9
|
document: :document,
|
|
10
10
|
model: :model,
|
|
11
11
|
table_parsing_format: :table_parsing_format,
|
|
12
|
-
image_resolution_dpi: :image_resolution_dpi,
|
|
13
12
|
instructions: :instructions,
|
|
14
13
|
bust_cache: :bust_cache,
|
|
15
14
|
background: :background
|
|
@@ -19,7 +18,6 @@ module Retab
|
|
|
19
18
|
:document,
|
|
20
19
|
:model,
|
|
21
20
|
:table_parsing_format,
|
|
22
|
-
:image_resolution_dpi,
|
|
23
21
|
:instructions,
|
|
24
22
|
:bust_cache,
|
|
25
23
|
:background
|
|
@@ -31,7 +29,6 @@ module Retab
|
|
|
31
29
|
@document = hash[:document] ? Retab::MimeData.new(hash[:document]) : nil
|
|
32
30
|
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
33
31
|
@table_parsing_format = hash[:table_parsing_format].nil? ? "html" : hash[:table_parsing_format]
|
|
34
|
-
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
35
32
|
@instructions = hash[:instructions]
|
|
36
33
|
@bust_cache = hash[:bust_cache].nil? ? false : hash[:bust_cache]
|
|
37
34
|
@background = hash[:background].nil? ? false : hash[:background]
|
data/lib/retab/parses.rb
CHANGED
|
@@ -77,7 +77,6 @@ module Retab
|
|
|
77
77
|
# @param document [Retab::MimeData, Pathname, IO, String, Hash] The document to parse
|
|
78
78
|
# @param model [String, nil] The model to use for parsing
|
|
79
79
|
# @param table_parsing_format [Retab::Types::ParseRequestTableParsingFormat, nil] Format used to render tables extracted from the document
|
|
80
|
-
# @param image_resolution_dpi [Integer, nil] DPI used when rasterizing pages for the parser
|
|
81
80
|
# @param instructions [String, nil] Free-form instructions appended to the system prompt to steer the parse.
|
|
82
81
|
# @param bust_cache [Boolean, nil] If true, skip the LLM cache and force a fresh completion
|
|
83
82
|
# @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.
|
|
@@ -87,18 +86,16 @@ module Retab
|
|
|
87
86
|
document:,
|
|
88
87
|
model: nil,
|
|
89
88
|
table_parsing_format: nil,
|
|
90
|
-
image_resolution_dpi: nil,
|
|
91
89
|
instructions: nil,
|
|
92
90
|
bust_cache: nil,
|
|
93
91
|
background: nil,
|
|
94
92
|
request_options: {}
|
|
95
93
|
)
|
|
96
|
-
document = Retab::MimeData.coerce(document) unless document.nil?
|
|
94
|
+
document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
|
|
97
95
|
body = {
|
|
98
96
|
"document" => document,
|
|
99
97
|
"model" => model,
|
|
100
98
|
"table_parsing_format" => table_parsing_format,
|
|
101
|
-
"image_resolution_dpi" => image_resolution_dpi,
|
|
102
99
|
"instructions" => instructions,
|
|
103
100
|
"bust_cache" => bust_cache,
|
|
104
101
|
"background" => background
|
data/lib/retab/partitions.rb
CHANGED
|
@@ -100,7 +100,7 @@ module Retab
|
|
|
100
100
|
background: nil,
|
|
101
101
|
request_options: {}
|
|
102
102
|
)
|
|
103
|
-
document = Retab::MimeData.coerce(document) unless document.nil?
|
|
103
|
+
document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
|
|
104
104
|
body = {
|
|
105
105
|
"document" => document,
|
|
106
106
|
"key" => key,
|
|
@@ -9,7 +9,6 @@ module Retab
|
|
|
9
9
|
documents: :documents,
|
|
10
10
|
model: :model,
|
|
11
11
|
instructions: :instructions,
|
|
12
|
-
image_resolution_dpi: :image_resolution_dpi,
|
|
13
12
|
background: :background
|
|
14
13
|
}.freeze
|
|
15
14
|
|
|
@@ -17,7 +16,6 @@ module Retab
|
|
|
17
16
|
:documents,
|
|
18
17
|
:model,
|
|
19
18
|
:instructions,
|
|
20
|
-
:image_resolution_dpi,
|
|
21
19
|
:background
|
|
22
20
|
)
|
|
23
21
|
|
|
@@ -27,7 +25,6 @@ module Retab
|
|
|
27
25
|
@documents = (hash[:documents] || []).map { |item| item ? Retab::MimeData.new(item) : nil }
|
|
28
26
|
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
29
27
|
@instructions = hash[:instructions]
|
|
30
|
-
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
31
28
|
@background = hash[:background].nil? ? false : hash[:background]
|
|
32
29
|
end
|
|
33
30
|
end
|
data/lib/retab/schemas.rb
CHANGED
|
@@ -14,7 +14,6 @@ module Retab
|
|
|
14
14
|
# @param documents [Array<Retab::MimeData, Pathname, IO, String, Hash>]
|
|
15
15
|
# @param model [String, nil]
|
|
16
16
|
# @param instructions [String, nil]
|
|
17
|
-
# @param image_resolution_dpi [Integer, nil] Resolution of the image sent to the LLM
|
|
18
17
|
# @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
18
|
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
20
19
|
# @return [Retab::SchemaGeneration]
|
|
@@ -22,16 +21,14 @@ module Retab
|
|
|
22
21
|
documents:,
|
|
23
22
|
model: nil,
|
|
24
23
|
instructions: nil,
|
|
25
|
-
image_resolution_dpi: nil,
|
|
26
24
|
background: nil,
|
|
27
25
|
request_options: {}
|
|
28
26
|
)
|
|
29
|
-
documents = documents.map { |d| Retab::MimeData.coerce(d) } unless documents.nil?
|
|
27
|
+
documents = documents.map { |d| Retab::MimeData.coerce(d, client: @client) } unless documents.nil?
|
|
30
28
|
body = {
|
|
31
29
|
"documents" => documents,
|
|
32
30
|
"model" => model,
|
|
33
31
|
"instructions" => instructions,
|
|
34
|
-
"image_resolution_dpi" => image_resolution_dpi,
|
|
35
32
|
"background" => background
|
|
36
33
|
}.compact
|
|
37
34
|
response = @client.request(
|
data/lib/retab/splits.rb
CHANGED
|
@@ -98,7 +98,7 @@ module Retab
|
|
|
98
98
|
background: nil,
|
|
99
99
|
request_options: {}
|
|
100
100
|
)
|
|
101
|
-
document = Retab::MimeData.coerce(document) unless document.nil?
|
|
101
|
+
document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
|
|
102
102
|
body = {
|
|
103
103
|
"document" => document,
|
|
104
104
|
"subdocuments" => subdocuments,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
module Types
|
|
7
|
+
class EvalRunTriggerType
|
|
8
|
+
MANUAL = "manual"
|
|
9
|
+
API = "api"
|
|
10
|
+
SCHEDULE = "schedule"
|
|
11
|
+
WEBHOOK = "webhook"
|
|
12
|
+
EMAIL = "email"
|
|
13
|
+
CUSTOM = "custom"
|
|
14
|
+
RESTART = "restart"
|
|
15
|
+
ALL = [MANUAL, API, SCHEDULE, WEBHOOK, EMAIL, CUSTOM, RESTART].freeze
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -4,15 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
module Retab
|
|
6
6
|
module Types
|
|
7
|
-
|
|
8
|
-
MANUAL = "manual"
|
|
9
|
-
API = "api"
|
|
10
|
-
SCHEDULE = "schedule"
|
|
11
|
-
WEBHOOK = "webhook"
|
|
12
|
-
EMAIL = "email"
|
|
13
|
-
CUSTOM = "custom"
|
|
14
|
-
RESTART = "restart"
|
|
15
|
-
ALL = [MANUAL, API, SCHEDULE, WEBHOOK, EMAIL, CUSTOM, RESTART].freeze
|
|
16
|
-
end
|
|
7
|
+
TriggerInfoType = EvalRunTriggerType
|
|
17
8
|
end
|
|
18
9
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
module Types
|
|
7
|
+
class WorkflowExperimentRunPlanMode
|
|
8
|
+
RUN = "run"
|
|
9
|
+
NOOP = "noop"
|
|
10
|
+
CONFLICT = "conflict"
|
|
11
|
+
UNKNOWN = "unknown"
|
|
12
|
+
ALL = [RUN, NOOP, CONFLICT, UNKNOWN].freeze
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/retab/version.rb
CHANGED
|
@@ -11,7 +11,6 @@ module Retab
|
|
|
11
11
|
model: :model,
|
|
12
12
|
json_schema: :json_schema,
|
|
13
13
|
n_consensus: :n_consensus,
|
|
14
|
-
image_resolution_dpi: :image_resolution_dpi,
|
|
15
14
|
instructions: :instructions,
|
|
16
15
|
output: :output,
|
|
17
16
|
status: :status,
|
|
@@ -29,7 +28,6 @@ module Retab
|
|
|
29
28
|
:model,
|
|
30
29
|
:json_schema,
|
|
31
30
|
:n_consensus,
|
|
32
|
-
:image_resolution_dpi,
|
|
33
31
|
:instructions,
|
|
34
32
|
:output,
|
|
35
33
|
:status,
|
|
@@ -49,7 +47,6 @@ module Retab
|
|
|
49
47
|
@model = hash[:model]
|
|
50
48
|
@json_schema = hash[:json_schema] || {}
|
|
51
49
|
@n_consensus = hash[:n_consensus]
|
|
52
|
-
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
53
50
|
@instructions = hash[:instructions]
|
|
54
51
|
@output = hash[:output] || {}
|
|
55
52
|
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
@@ -10,7 +10,6 @@ module Retab
|
|
|
10
10
|
file: :file,
|
|
11
11
|
model: :model,
|
|
12
12
|
table_parsing_format: :table_parsing_format,
|
|
13
|
-
image_resolution_dpi: :image_resolution_dpi,
|
|
14
13
|
instructions: :instructions,
|
|
15
14
|
output: :output,
|
|
16
15
|
status: :status,
|
|
@@ -25,7 +24,6 @@ module Retab
|
|
|
25
24
|
:file,
|
|
26
25
|
:model,
|
|
27
26
|
:table_parsing_format,
|
|
28
|
-
:image_resolution_dpi,
|
|
29
27
|
:instructions,
|
|
30
28
|
:output,
|
|
31
29
|
:status,
|
|
@@ -42,7 +40,6 @@ module Retab
|
|
|
42
40
|
@file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
|
|
43
41
|
@model = hash[:model]
|
|
44
42
|
@table_parsing_format = hash[:table_parsing_format]
|
|
45
|
-
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
46
43
|
@instructions = hash[:instructions]
|
|
47
44
|
@output = hash[:output] ? Retab::ParseOutput.new(hash[:output]) : nil
|
|
48
45
|
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
@@ -7,12 +7,14 @@ module Retab
|
|
|
7
7
|
|
|
8
8
|
HASH_ATTRS = {
|
|
9
9
|
operation: :operation,
|
|
10
|
-
id: :id
|
|
10
|
+
id: :id,
|
|
11
|
+
additionalProperties: :additional_properties
|
|
11
12
|
}.freeze
|
|
12
13
|
|
|
13
14
|
attr_accessor(
|
|
14
15
|
:operation,
|
|
15
|
-
:id
|
|
16
|
+
:id,
|
|
17
|
+
:additional_properties
|
|
16
18
|
)
|
|
17
19
|
|
|
18
20
|
def initialize(json)
|
|
@@ -20,6 +22,7 @@ module Retab
|
|
|
20
22
|
hash = self.class.normalize(json)
|
|
21
23
|
@operation = hash[:operation]
|
|
22
24
|
@id = hash[:id]
|
|
25
|
+
@additional_properties = hash[:additionalProperties] || {}
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
end
|
|
@@ -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 BlockExecFileHandleInput < Retab::Types::BaseModel
|
|
7
7
|
|
|
8
8
|
HASH_ATTRS = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
document: :document,
|
|
10
|
+
type: :type
|
|
11
11
|
}.freeze
|
|
12
12
|
|
|
13
13
|
attr_accessor(
|
|
14
|
-
:
|
|
15
|
-
:
|
|
14
|
+
:document,
|
|
15
|
+
:type
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
def initialize(json)
|
|
19
19
|
super()
|
|
20
20
|
hash = self.class.normalize(json)
|
|
21
|
+
@document = hash[:document] ? Retab::BlockExecFileRef.new(hash[:document]) : nil
|
|
21
22
|
@type = hash[:type].nil? ? "file" : hash[:type]
|
|
22
|
-
@document = hash[:document] ? Retab::FileRef.new(hash[:document]) : nil
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
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 BlockExecFileRef < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
id: :id,
|
|
10
|
+
filename: :filename,
|
|
11
|
+
mime_type: :mime_type
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
attr_accessor(
|
|
15
|
+
:id,
|
|
16
|
+
:filename,
|
|
17
|
+
:mime_type
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def initialize(json)
|
|
21
|
+
super()
|
|
22
|
+
hash = self.class.normalize(json)
|
|
23
|
+
@id = hash[:id]
|
|
24
|
+
@filename = hash[:filename]
|
|
25
|
+
@mime_type = hash[:mime_type]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -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 BlockExecJsonHandleInput < Retab::Types::BaseModel
|
|
7
7
|
|
|
8
8
|
HASH_ATTRS = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
data: :data,
|
|
10
|
+
type: :type
|
|
11
11
|
}.freeze
|
|
12
12
|
|
|
13
13
|
attr_accessor(
|
|
14
|
-
:
|
|
15
|
-
:
|
|
14
|
+
:data,
|
|
15
|
+
:type
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
def initialize(json)
|
|
19
19
|
super()
|
|
20
20
|
hash = self.class.normalize(json)
|
|
21
|
-
@type = hash[:type].nil? ? "json" : hash[:type]
|
|
22
21
|
@data = hash[:data]
|
|
22
|
+
@type = hash[:type].nil? ? "json" : hash[:type]
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated by oagen. Do not edit.
|
|
4
|
+
|
|
5
|
+
module Retab
|
|
6
|
+
class CancelledBlockExecutionLifecycle < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
status: :status,
|
|
10
|
+
reason: :reason
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
attr_accessor(
|
|
14
|
+
:status,
|
|
15
|
+
:reason
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def initialize(json)
|
|
19
|
+
super()
|
|
20
|
+
hash = self.class.normalize(json)
|
|
21
|
+
@status = hash[:status].nil? ? "cancelled" : hash[:status]
|
|
22
|
+
@reason = hash[:reason]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
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 PendingBlockExecutionLifecycle < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
status: :status
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
attr_accessor :status
|
|
13
|
+
|
|
14
|
+
def initialize(json)
|
|
15
|
+
super()
|
|
16
|
+
hash = self.class.normalize(json)
|
|
17
|
+
@status = hash[:status].nil? ? "pending" : hash[:status]
|
|
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 QueuedBlockExecutionLifecycle < Retab::Types::BaseModel
|
|
7
|
+
|
|
8
|
+
HASH_ATTRS = {
|
|
9
|
+
status: :status
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
attr_accessor :status
|
|
13
|
+
|
|
14
|
+
def initialize(json)
|
|
15
|
+
super()
|
|
16
|
+
hash = self.class.normalize(json)
|
|
17
|
+
@status = hash[:status].nil? ? "queued" : hash[:status]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|