retab 0.1.3 → 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/category.rb +1 -1
- data/lib/retab/classifications/classification.rb +6 -0
- data/lib/retab/classifications/classification_request.rb +7 -4
- 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 +12 -16
- data/lib/retab/edits/edit.rb +6 -0
- data/lib/retab/{workflow_artifacts → edits}/edit_config.rb +1 -1
- data/lib/retab/edits/edit_request.rb +7 -4
- data/lib/retab/edits.rb +38 -1
- data/lib/retab/experiment_run_metrics/experiment_by_document_metrics_response.rb +2 -2
- data/lib/retab/experiment_run_metrics/experiment_by_target_metrics_response.rb +2 -2
- data/lib/retab/experiment_run_metrics/experiment_metrics_missing_error.rb +2 -2
- data/lib/retab/experiment_run_metrics/experiment_metrics_stale_error.rb +2 -2
- data/lib/retab/experiment_run_metrics/experiment_summary_metrics_response.rb +2 -2
- data/lib/retab/experiment_run_metrics/experiment_votes_metrics_response.rb +2 -2
- data/lib/retab/experiment_run_results/error_workflow_experiment_result.rb +2 -2
- data/lib/retab/experiment_run_results/experiment_result.rb +2 -5
- data/lib/retab/experiment_runs/experiment_run.rb +6 -3
- data/lib/retab/experiment_runs.rb +0 -10
- data/lib/retab/extractions/extraction.rb +6 -0
- data/lib/retab/extractions/extraction_request.rb +6 -3
- data/lib/retab/extractions/sources_response.rb +1 -1
- data/lib/retab/extractions.rb +38 -1
- data/lib/retab/files/create_upload_response.rb +1 -1
- data/lib/retab/files/file.rb +1 -1
- data/lib/retab/files.rb +65 -65
- data/lib/retab/parses/parse.rb +6 -0
- data/lib/retab/parses/parse_request.rb +8 -5
- data/lib/retab/parses.rb +33 -1
- data/lib/retab/partitions/partition.rb +7 -1
- data/lib/retab/partitions/partition_request.rb +8 -5
- data/lib/retab/partitions.rb +38 -1
- data/lib/retab/schemas/generate_schema_request.rb +2 -5
- data/lib/retab/schemas/partial_schema.rb +2 -2
- data/lib/retab/schemas.rb +0 -3
- data/lib/retab/splits/split.rb +6 -0
- data/lib/retab/splits/split_request.rb +7 -4
- data/lib/retab/splits/subdocument.rb +2 -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/types/trigger_info_type.rb +18 -0
- data/lib/retab/types/{workflow_export_payload_request_trigger_types.rb → workflow_export_payload_request_trigger_type.rb} +1 -1
- data/lib/retab/types/workflow_runs_trigger_type.rb +1 -1
- data/lib/retab/workflow_artifacts/api_call_invocation.rb +4 -4
- data/lib/retab/workflow_artifacts/classification_workflow_artifact.rb +7 -1
- data/lib/retab/workflow_artifacts/condition_evaluation_details.rb +6 -6
- data/lib/retab/workflow_artifacts/condition_evaluation_per_item.rb +1 -1
- data/lib/retab/workflow_artifacts/condition_evaluation_result.rb +7 -7
- data/lib/retab/workflow_artifacts/condition_evaluation_sub_condition.rb +6 -6
- data/lib/retab/workflow_artifacts/conditional_evaluation.rb +4 -4
- data/lib/retab/workflow_artifacts/edit_workflow_artifact.rb +7 -1
- data/lib/retab/workflow_artifacts/extraction_workflow_artifact.rb +7 -1
- data/lib/retab/workflow_artifacts/function_invocation.rb +4 -4
- data/lib/retab/workflow_artifacts/parse_workflow_artifact.rb +7 -1
- data/lib/retab/workflow_artifacts/partition_workflow_artifact.rb +8 -2
- data/lib/retab/workflow_artifacts/review_evaluation.rb +6 -6
- data/lib/retab/workflow_artifacts/split_workflow_artifact.rb +7 -1
- data/lib/retab/workflow_artifacts/while_loop_termination.rb +4 -4
- data/lib/retab/workflow_artifacts.rb +22 -22
- data/lib/retab/workflow_block_executions/completed_block_execution_lifecycle.rb +1 -1
- data/lib/retab/workflow_block_executions/create_block_execution_request.rb +1 -1
- data/lib/retab/workflow_block_executions/error_block_execution_lifecycle.rb +1 -1
- data/lib/retab/workflow_block_executions/skipped_block_execution_lifecycle.rb +1 -1
- data/lib/retab/workflow_block_executions/stored_block_execution.rb +3 -3
- data/lib/retab/workflow_block_executions.rb +1 -1
- data/lib/retab/workflow_blocks/workflow_block.rb +1 -1
- data/lib/retab/workflow_blocks/workflow_block_create_request.rb +1 -1
- data/lib/retab/workflow_blocks.rb +7 -7
- data/lib/retab/workflow_edges.rb +3 -3
- data/lib/retab/workflow_experiments/experiment_document_capture_request.rb +3 -3
- data/lib/retab/workflow_experiments/experiment_document_provenance.rb +3 -3
- data/lib/retab/{workflow_test_run_results → workflow_experiments}/file_handle_input.rb +1 -1
- data/lib/retab/{workflow_test_run_results → workflow_experiments}/json_handle_input.rb +1 -1
- data/lib/retab/workflow_experiments/workflow_experiment.rb +3 -3
- data/lib/retab/workflow_reviews/review.rb +3 -3
- data/lib/retab/workflow_reviews/review_all_of.rb +1 -1
- data/lib/retab/workflow_reviews/review_always.rb +1 -1
- data/lib/retab/workflow_reviews/review_any_of.rb +1 -1
- data/lib/retab/workflow_reviews/review_any_required_field_null.rb +1 -1
- data/lib/retab/workflow_reviews/review_any_split_pages_lt.rb +1 -1
- data/lib/retab/workflow_reviews/review_boundary_confidence_lt.rb +1 -1
- data/lib/retab/workflow_reviews/review_branch_in.rb +1 -1
- data/lib/retab/workflow_reviews/review_category_in.rb +1 -1
- data/lib/retab/workflow_reviews/review_confidence_lt.rb +1 -1
- data/lib/retab/workflow_reviews/review_decision.rb +3 -3
- data/lib/retab/workflow_reviews/review_field_confidence_lt.rb +1 -1
- data/lib/retab/workflow_reviews/review_json_condition.rb +1 -1
- data/lib/retab/workflow_reviews/review_split_count_neq.rb +1 -1
- data/lib/retab/workflow_reviews/review_top_margin_lt.rb +1 -1
- data/lib/retab/workflow_reviews/review_validation_failed.rb +1 -1
- data/lib/retab/workflow_reviews/submit_decision_response.rb +2 -2
- data/lib/retab/workflow_runs/awaiting_review_run.rb +1 -1
- data/lib/retab/workflow_runs/cancel_workflow_response.rb +2 -2
- data/lib/retab/workflow_runs/cancelled_terminal.rb +1 -1
- data/lib/retab/workflow_runs/create_workflow_run_request.rb +1 -1
- data/lib/retab/workflow_runs/error_terminal.rb +1 -1
- data/lib/retab/workflow_runs/pending_run.rb +1 -1
- data/lib/retab/workflow_runs/run_timing.rb +2 -11
- data/lib/retab/workflow_runs/running_run.rb +1 -1
- data/lib/retab/workflow_runs/{manual_trigger.rb → trigger_info.rb} +3 -8
- data/lib/retab/workflow_runs/workflow_export_payload_request.rb +7 -7
- data/lib/retab/workflow_runs/workflow_run.rb +7 -21
- data/lib/retab/workflow_runs.rb +6 -16
- data/lib/retab/workflow_spec/declarative_apply_response.rb +2 -2
- data/lib/retab/workflow_spec/declarative_plan_field_change.rb +2 -2
- data/lib/retab/workflow_spec/declarative_plan_response.rb +2 -2
- data/lib/retab/workflow_spec/declarative_plan_summary.rb +1 -1
- data/lib/retab/workflow_spec.rb +10 -10
- data/lib/retab/workflow_steps/awaiting_review_step_lifecycle.rb +1 -1
- data/lib/retab/workflow_steps/cancelled_step_lifecycle.rb +1 -1
- data/lib/retab/workflow_steps/container_context_data.rb +1 -1
- data/lib/retab/workflow_steps/error_step_lifecycle.rb +1 -1
- data/lib/retab/workflow_steps/queued_step_lifecycle.rb +1 -1
- data/lib/retab/workflow_steps.rb +5 -10
- data/lib/retab/workflow_test_run_results/verdict_summary.rb +3 -3
- data/lib/retab/workflow_test_run_results/workflow_test_result.rb +4 -4
- data/lib/retab/{jobs/job_warning.rb → workflow_test_run_results/workflow_test_run_timing.rb} +1 -1
- data/lib/retab/workflow_test_runs/workflow_test_run.rb +7 -21
- data/lib/retab/workflow_test_runs.rb +1 -11
- data/lib/retab/workflow_tests/all_items_match_condition.rb +1 -1
- data/lib/retab/workflow_tests/any_item_matches_condition.rb +1 -1
- data/lib/retab/workflow_tests/array_contains_condition.rb +1 -1
- data/lib/retab/workflow_tests/assertion_schema_dep.rb +1 -1
- data/lib/retab/workflow_tests/between_condition.rb +2 -2
- data/lib/retab/workflow_tests/contain_condition.rb +1 -1
- data/lib/retab/workflow_tests/ends_with_condition.rb +1 -1
- data/lib/retab/workflow_tests/equal_condition.rb +1 -1
- data/lib/retab/workflow_tests/exist_condition.rb +1 -1
- data/lib/retab/workflow_tests/json_schema_valid_condition.rb +1 -1
- data/lib/retab/workflow_tests/length_compare_condition.rb +1 -1
- data/lib/retab/workflow_tests/llm_judged_as_condition.rb +1 -1
- data/lib/retab/workflow_tests/llm_not_judged_as_condition.rb +1 -1
- data/lib/retab/{workflow_test_run_results → workflow_tests}/manual_workflow_test_source.rb +1 -1
- data/lib/retab/workflow_tests/matche_regex_condition.rb +1 -1
- data/lib/retab/workflow_tests/not_contains_condition.rb +1 -1
- data/lib/retab/workflow_tests/not_equals_condition.rb +1 -1
- data/lib/retab/workflow_tests/not_exists_condition.rb +1 -1
- data/lib/retab/workflow_tests/number_compare_condition.rb +1 -1
- data/lib/retab/workflow_tests/object_contains_condition.rb +1 -1
- data/lib/retab/{workflow_test_run_results → workflow_tests}/run_step_workflow_test_source.rb +1 -1
- data/lib/retab/workflow_tests/similarity_gte_condition.rb +2 -2
- data/lib/retab/workflow_tests/split_iou_condition.rb +1 -1
- data/lib/retab/workflow_tests/start_with_condition.rb +1 -1
- data/lib/retab/workflow_tests/workflow_test.rb +2 -2
- data/lib/retab/{workflow_test_runs → workflow_tests}/workflow_test_block_target.rb +1 -1
- data/lib/retab/workflows/create_workflow_request.rb +2 -2
- data/lib/retab/workflows/publish_workflow_request.rb +1 -1
- data/lib/retab/workflows/workflow.rb +2 -2
- data/lib/retab/workflows/workflow_published.rb +1 -1
- data/lib/retab/workflows.rb +23 -0
- data/lib/retab.rb +0 -1
- data/rbi/retab/api_call_invocation.rbi +4 -4
- 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 +10 -13
- data/rbi/retab/condition_evaluation_details.rbi +2 -2
- data/rbi/retab/condition_evaluation_result.rbi +2 -2
- data/rbi/retab/condition_evaluation_sub_condition.rbi +2 -2
- data/rbi/retab/conditional_evaluation.rbi +4 -4
- data/rbi/retab/edit.rbi +14 -2
- data/rbi/retab/edit_request.rbi +6 -0
- data/rbi/retab/edit_workflow_artifact.rbi +16 -4
- data/rbi/retab/edits.rbi +14 -3
- data/rbi/retab/experiment_document_capture_request.rbi +2 -2
- data/rbi/retab/experiment_document_provenance.rbi +2 -2
- data/rbi/retab/experiment_result.rbi +0 -6
- data/rbi/retab/experiment_run.rbi +10 -4
- data/rbi/retab/experiment_runs.rbi +1 -3
- data/rbi/retab/extraction.rbi +12 -0
- data/rbi/retab/extraction_request.rbi +6 -0
- data/rbi/retab/extraction_workflow_artifact.rbi +14 -2
- data/rbi/retab/extractions.rbi +14 -3
- data/rbi/retab/files.rbi +17 -17
- data/rbi/retab/function_invocation.rbi +4 -4
- data/rbi/retab/generate_schema_request.rbi +0 -6
- 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 +14 -2
- data/rbi/retab/partitions.rbi +14 -3
- data/rbi/retab/{job_warning.rbi → primitive_error.rbi} +1 -1
- data/rbi/retab/review.rbi +2 -2
- data/rbi/retab/review_decision.rbi +4 -4
- data/rbi/retab/review_evaluation.rbi +2 -2
- data/rbi/retab/run_timing.rbi +0 -18
- data/rbi/retab/schemas.rbi +1 -2
- 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/stored_block_execution.rbi +2 -2
- data/rbi/retab/{schedule_trigger.rbi → trigger_info.rbi} +3 -9
- data/rbi/retab/verdict_summary.rbi +2 -2
- data/rbi/retab/while_loop_termination.rbi +2 -2
- data/rbi/retab/workflow_artifacts.rbi +8 -8
- data/rbi/retab/workflow_export_payload_request.rbi +4 -4
- data/rbi/retab/workflow_run.rbi +12 -6
- data/rbi/retab/workflow_runs.rbi +3 -5
- data/rbi/retab/workflow_spec.rbi +4 -4
- data/rbi/retab/workflow_steps.rbi +1 -2
- data/rbi/retab/workflow_test_result.rbi +2 -2
- data/rbi/retab/workflow_test_run.rbi +12 -6
- data/rbi/retab/workflow_test_run_timing.rbi +2 -2
- data/rbi/retab/workflow_test_runs.rbi +1 -3
- data/rbi/retab/workflows.rbi +8 -0
- metadata +45 -57
- 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.rb +0 -252
- data/lib/retab/types/create_job_request_endpoint.rb +0 -34
- data/lib/retab/types/generate_schema_request_reasoning_effort.rb +0 -17
- data/lib/retab/types/jobs_source.rb +0 -14
- data/lib/retab/workflow_runs/api_trigger.rb +0 -25
- data/lib/retab/workflow_runs/email_trigger.rb +0 -28
- data/lib/retab/workflow_runs/restart_trigger.rb +0 -25
- data/lib/retab/workflow_runs/schedule_trigger.rb +0 -25
- data/lib/retab/workflow_runs/webhook_trigger.rb +0 -25
- data/lib/retab/workflow_runs/workflow_snapshot_ref.rb +0 -25
- data/lib/retab/workflow_test_runs/workflow_test_run_timing.rb +0 -31
- data/rbi/retab/api_trigger.rbi +0 -30
- data/rbi/retab/create_job_request.rbi +0 -36
- data/rbi/retab/email_trigger.rbi +0 -36
- data/rbi/retab/job.rbi +0 -120
- data/rbi/retab/job_error.rbi +0 -36
- data/rbi/retab/job_response.rbi +0 -30
- data/rbi/retab/jobs.rbi +0 -76
- data/rbi/retab/manual_trigger.rbi +0 -30
- data/rbi/retab/restart_trigger.rbi +0 -30
- data/rbi/retab/webhook_trigger.rbi +0 -30
- data/rbi/retab/workflow_snapshot_ref.rbi +0 -30
- /data/lib/retab/{extractions → classifications}/file_ref.rb +0 -0
- /data/lib/retab/{extractions → classifications}/retab_usage.rb +0 -0
- /data/lib/retab/{workflow_artifacts → edits}/b_box.rb +0 -0
- /data/lib/retab/{workflow_artifacts → edits}/edit_result.rb +0 -0
- /data/lib/retab/{workflow_artifacts → edits}/form_field.rb +0 -0
- /data/lib/retab/{workflow_runs → workflow_artifacts}/error_details.rb +0 -0
- /data/lib/retab/{workflow_steps → workflow_block_executions}/step_artifact_ref.rb +0 -0
- /data/lib/retab/{workflow_test_run_results → workflow_experiments}/materialized_document.rb +0 -0
- /data/lib/retab/{workflow_test_runs → workflow_test_run_results}/cancelled_workflow_test_run.rb +0 -0
- /data/lib/retab/{workflow_test_runs → workflow_test_run_results}/completed_workflow_test_run.rb +0 -0
- /data/lib/retab/{workflow_test_runs → workflow_test_run_results}/error_workflow_test_run.rb +0 -0
- /data/lib/retab/{workflow_test_runs → workflow_test_run_results}/pending_workflow_test_run.rb +0 -0
- /data/lib/retab/{workflow_test_runs → workflow_test_run_results}/queued_workflow_test_run.rb +0 -0
- /data/lib/retab/{workflow_test_runs → workflow_test_run_results}/running_workflow_test_run.rb +0 -0
|
@@ -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
|
|
|
@@ -38,14 +40,15 @@ module Retab
|
|
|
38
40
|
hash = self.class.normalize(json)
|
|
39
41
|
@document = hash[:document] ? Retab::MimeData.new(hash[:document]) : nil
|
|
40
42
|
@json_schema = hash[:json_schema] || {}
|
|
41
|
-
@model = hash[:model]
|
|
43
|
+
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
42
44
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
43
45
|
@instructions = hash[:instructions]
|
|
44
46
|
@n_consensus = hash[:n_consensus]
|
|
45
47
|
@metadata = hash[:metadata] || {}
|
|
46
48
|
@additional_messages = (hash[:additional_messages] || []).map { |item| item || {} }
|
|
47
|
-
@bust_cache = hash[:bust_cache]
|
|
48
|
-
@stream = hash[:stream]
|
|
49
|
+
@bust_cache = hash[:bust_cache].nil? ? false : hash[:bust_cache]
|
|
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
|
|
@@ -26,7 +26,7 @@ module Retab
|
|
|
26
26
|
def initialize(json)
|
|
27
27
|
super()
|
|
28
28
|
hash = self.class.normalize(json)
|
|
29
|
-
@object = hash[:object]
|
|
29
|
+
@object = hash[:object].nil? ? "extraction.sources" : hash[:object]
|
|
30
30
|
@extraction_id = hash[:extraction_id]
|
|
31
31
|
@document_type = hash[:document_type]
|
|
32
32
|
@file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
|
data/lib/retab/extractions.rb
CHANGED
|
@@ -17,8 +17,9 @@ module Retab
|
|
|
17
17
|
# @param order [Retab::Types::ExtractionsOrder, nil]
|
|
18
18
|
# @param filename [String, nil]
|
|
19
19
|
# @param filename_regex [String, nil] Deprecated alias for prefix filename filtering. Regex patterns are rejected.
|
|
20
|
-
# @param filename_contains [String, nil] Plain
|
|
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)
|
|
@@ -28,7 +28,7 @@ module Retab
|
|
|
28
28
|
hash = self.class.normalize(json)
|
|
29
29
|
@file_id = hash[:fileId]
|
|
30
30
|
@upload_url = hash[:uploadUrl]
|
|
31
|
-
@upload_method = hash[:uploadMethod]
|
|
31
|
+
@upload_method = hash[:uploadMethod].nil? ? "PUT" : hash[:uploadMethod]
|
|
32
32
|
@upload_headers = hash[:uploadHeaders] || {}
|
|
33
33
|
@mime_data = hash[:mimeData] ? Retab::MimeData.new(hash[:mimeData]) : nil
|
|
34
34
|
@expires_at = hash[:expiresAt]
|
data/lib/retab/files/file.rb
CHANGED
data/lib/retab/files.rb
CHANGED
|
@@ -10,71 +10,6 @@ module Retab
|
|
|
10
10
|
@client = client
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# Upload File
|
|
14
|
-
# @param filename [String] Filename to store
|
|
15
|
-
# @param content_type [String, nil] MIME type the client will upload
|
|
16
|
-
# @param size_bytes [Integer] Expected upload size in bytes
|
|
17
|
-
# @param sha_256 [String, nil] Optional SHA-256 checksum
|
|
18
|
-
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
19
|
-
# @return [Retab::CreateUploadResponse]
|
|
20
|
-
def create_upload(
|
|
21
|
-
filename:,
|
|
22
|
-
size_bytes:,
|
|
23
|
-
content_type: nil,
|
|
24
|
-
sha_256: nil,
|
|
25
|
-
request_options: {}
|
|
26
|
-
)
|
|
27
|
-
body = {
|
|
28
|
-
"filename" => filename,
|
|
29
|
-
"content_type" => content_type,
|
|
30
|
-
"size_bytes" => size_bytes,
|
|
31
|
-
"sha256" => sha_256
|
|
32
|
-
}.compact
|
|
33
|
-
response = @client.request(
|
|
34
|
-
method: :post,
|
|
35
|
-
path: "/v1/files/upload",
|
|
36
|
-
auth: true,
|
|
37
|
-
body: body,
|
|
38
|
-
request_options: request_options
|
|
39
|
-
)
|
|
40
|
-
result = Retab::CreateUploadResponse.new(response.body)
|
|
41
|
-
result.last_response = Retab::Types::ApiResponse.new(
|
|
42
|
-
http_status: response.code.to_i,
|
|
43
|
-
http_headers: response.each_header.to_h,
|
|
44
|
-
request_id: response["x-request-id"]
|
|
45
|
-
)
|
|
46
|
-
result
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Complete Upload File
|
|
50
|
-
# @param file_id [String]
|
|
51
|
-
# @param sha_256 [String, nil] Optional SHA-256 checksum
|
|
52
|
-
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
53
|
-
# @return [Retab::MimeData]
|
|
54
|
-
def complete_upload(
|
|
55
|
-
file_id:,
|
|
56
|
-
sha_256: nil,
|
|
57
|
-
request_options: {}
|
|
58
|
-
)
|
|
59
|
-
body = {
|
|
60
|
-
"sha256" => sha_256
|
|
61
|
-
}.compact
|
|
62
|
-
response = @client.request(
|
|
63
|
-
method: :post,
|
|
64
|
-
path: "/v1/files/upload/#{Retab::Util.encode_path(file_id)}/complete",
|
|
65
|
-
auth: true,
|
|
66
|
-
body: body,
|
|
67
|
-
request_options: request_options
|
|
68
|
-
)
|
|
69
|
-
result = Retab::MimeData.new(response.body)
|
|
70
|
-
result.last_response = Retab::Types::ApiResponse.new(
|
|
71
|
-
http_status: response.code.to_i,
|
|
72
|
-
http_headers: response.each_header.to_h,
|
|
73
|
-
request_id: response["x-request-id"]
|
|
74
|
-
)
|
|
75
|
-
result
|
|
76
|
-
end
|
|
77
|
-
|
|
78
13
|
# List Files
|
|
79
14
|
# @param before [String, nil]
|
|
80
15
|
# @param after [String, nil]
|
|
@@ -153,6 +88,71 @@ module Retab
|
|
|
153
88
|
)
|
|
154
89
|
end
|
|
155
90
|
|
|
91
|
+
# Upload File
|
|
92
|
+
# @param filename [String] Filename to store
|
|
93
|
+
# @param content_type [String, nil] MIME type the client will upload
|
|
94
|
+
# @param size_bytes [Integer] Expected upload size in bytes
|
|
95
|
+
# @param sha_256 [String, nil] Optional SHA-256 checksum
|
|
96
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
97
|
+
# @return [Retab::CreateUploadResponse]
|
|
98
|
+
def create_upload(
|
|
99
|
+
filename:,
|
|
100
|
+
size_bytes:,
|
|
101
|
+
content_type: nil,
|
|
102
|
+
sha_256: nil,
|
|
103
|
+
request_options: {}
|
|
104
|
+
)
|
|
105
|
+
body = {
|
|
106
|
+
"filename" => filename,
|
|
107
|
+
"content_type" => content_type,
|
|
108
|
+
"size_bytes" => size_bytes,
|
|
109
|
+
"sha256" => sha_256
|
|
110
|
+
}.compact
|
|
111
|
+
response = @client.request(
|
|
112
|
+
method: :post,
|
|
113
|
+
path: "/v1/files/upload",
|
|
114
|
+
auth: true,
|
|
115
|
+
body: body,
|
|
116
|
+
request_options: request_options
|
|
117
|
+
)
|
|
118
|
+
result = Retab::CreateUploadResponse.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
|
+
# Complete Upload File
|
|
128
|
+
# @param file_id [String]
|
|
129
|
+
# @param sha_256 [String, nil] Optional SHA-256 checksum
|
|
130
|
+
# @param request_options [Hash] (see Retab::Types::RequestOptions)
|
|
131
|
+
# @return [Retab::MimeData]
|
|
132
|
+
def complete_upload(
|
|
133
|
+
file_id:,
|
|
134
|
+
sha_256: nil,
|
|
135
|
+
request_options: {}
|
|
136
|
+
)
|
|
137
|
+
body = {
|
|
138
|
+
"sha256" => sha_256
|
|
139
|
+
}.compact
|
|
140
|
+
response = @client.request(
|
|
141
|
+
method: :post,
|
|
142
|
+
path: "/v1/files/upload/#{Retab::Util.encode_path(file_id)}/complete",
|
|
143
|
+
auth: true,
|
|
144
|
+
body: body,
|
|
145
|
+
request_options: request_options
|
|
146
|
+
)
|
|
147
|
+
result = Retab::MimeData.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
156
|
# Get File
|
|
157
157
|
# @param file_id [String]
|
|
158
158
|
# @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,18 +21,20 @@ 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)
|
|
27
29
|
super()
|
|
28
30
|
hash = self.class.normalize(json)
|
|
29
31
|
@document = hash[:document] ? Retab::MimeData.new(hash[:document]) : nil
|
|
30
|
-
@model = hash[:model]
|
|
31
|
-
@table_parsing_format = hash[:table_parsing_format]
|
|
32
|
+
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
33
|
+
@table_parsing_format = hash[:table_parsing_format].nil? ? "html" : hash[:table_parsing_format]
|
|
32
34
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
33
35
|
@instructions = hash[:instructions]
|
|
34
|
-
@bust_cache = hash[:bust_cache]
|
|
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
|
|
@@ -42,8 +46,10 @@ module Retab
|
|
|
42
46
|
@key = hash[:key]
|
|
43
47
|
@instructions = hash[:instructions]
|
|
44
48
|
@n_consensus = hash[:n_consensus]
|
|
45
|
-
@allow_overlap = hash[:allow_overlap]
|
|
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)
|
|
@@ -31,10 +33,11 @@ module Retab
|
|
|
31
33
|
@document = hash[:document] ? Retab::MimeData.new(hash[:document]) : nil
|
|
32
34
|
@key = hash[:key]
|
|
33
35
|
@instructions = hash[:instructions]
|
|
34
|
-
@model = hash[:model]
|
|
36
|
+
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
35
37
|
@n_consensus = hash[:n_consensus]
|
|
36
|
-
@allow_overlap = hash[:allow_overlap]
|
|
37
|
-
@bust_cache = hash[:bust_cache]
|
|
38
|
+
@allow_overlap = hash[:allow_overlap].nil? ? true : hash[:allow_overlap]
|
|
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
|
|
@@ -8,7 +8,6 @@ module Retab
|
|
|
8
8
|
HASH_ATTRS = {
|
|
9
9
|
documents: :documents,
|
|
10
10
|
model: :model,
|
|
11
|
-
reasoning_effort: :reasoning_effort,
|
|
12
11
|
instructions: :instructions,
|
|
13
12
|
image_resolution_dpi: :image_resolution_dpi,
|
|
14
13
|
stream: :stream
|
|
@@ -17,7 +16,6 @@ module Retab
|
|
|
17
16
|
attr_accessor(
|
|
18
17
|
:documents,
|
|
19
18
|
:model,
|
|
20
|
-
:reasoning_effort,
|
|
21
19
|
:instructions,
|
|
22
20
|
:image_resolution_dpi,
|
|
23
21
|
:stream
|
|
@@ -27,11 +25,10 @@ module Retab
|
|
|
27
25
|
super()
|
|
28
26
|
hash = self.class.normalize(json)
|
|
29
27
|
@documents = (hash[:documents] || []).map { |item| item ? Retab::MimeData.new(item) : nil }
|
|
30
|
-
@model = hash[:model]
|
|
31
|
-
@reasoning_effort = hash[:reasoning_effort]
|
|
28
|
+
@model = hash[:model].nil? ? "retab-small" : hash[:model]
|
|
32
29
|
@instructions = hash[:instructions]
|
|
33
30
|
@image_resolution_dpi = hash[:image_resolution_dpi]
|
|
34
|
-
@stream = hash[:stream]
|
|
31
|
+
@stream = hash[:stream].nil? ? false : hash[:stream]
|
|
35
32
|
end
|
|
36
33
|
end
|
|
37
34
|
end
|
|
@@ -22,10 +22,10 @@ module Retab
|
|
|
22
22
|
def initialize(json)
|
|
23
23
|
super()
|
|
24
24
|
hash = self.class.normalize(json)
|
|
25
|
-
@object = hash[:object]
|
|
25
|
+
@object = hash[:object].nil? ? "schema" : hash[:object]
|
|
26
26
|
@created_at = hash[:created_at]
|
|
27
27
|
@json_schema = hash[:json_schema] || {}
|
|
28
|
-
@strict = hash[:strict]
|
|
28
|
+
@strict = hash[:strict].nil? ? true : hash[:strict]
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|