retab 0.1.9 → 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.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/lib/retab/base_client.rb +1 -5
  3. data/lib/retab/classifications.rb +1 -1
  4. data/lib/retab/edit_templates.rb +1 -1
  5. data/lib/retab/edits.rb +1 -1
  6. data/lib/retab/experiment_run_metrics/experiment_metrics_stale_error.rb +3 -3
  7. data/lib/retab/experiment_run_metrics/experiment_summary_metrics_response.rb +3 -3
  8. data/lib/retab/experiment_run_metrics/metrics_stale_error_last_run.rb +3 -3
  9. data/lib/retab/experiment_run_results/error_workflow_experiment_result.rb +1 -22
  10. data/lib/retab/experiment_runs/create_experiment_run_request.rb +5 -2
  11. data/lib/retab/experiment_runs/error_workflow_experiment_run.rb +1 -1
  12. data/lib/retab/experiment_runs/experiment_run.rb +3 -3
  13. data/lib/retab/experiment_runs.rb +4 -1
  14. data/lib/retab/extractions/extraction.rb +0 -3
  15. data/lib/retab/extractions/extraction_request.rb +0 -3
  16. data/lib/retab/extractions.rb +53 -4
  17. data/lib/retab/files/create_file_blueprint_request.rb +3 -3
  18. data/lib/retab/files/file_blueprint.rb +5 -5
  19. data/lib/retab/files.rb +3 -3
  20. data/lib/retab/mime.rb +77 -6
  21. data/lib/retab/parses/parse.rb +0 -3
  22. data/lib/retab/parses/parse_request.rb +0 -3
  23. data/lib/retab/parses.rb +1 -4
  24. data/lib/retab/partitions.rb +1 -1
  25. data/lib/retab/schemas/generate_schema_request.rb +0 -3
  26. data/lib/retab/schemas.rb +1 -4
  27. data/lib/retab/splits.rb +1 -1
  28. data/lib/retab/types/{workflow_test_run_results_order.rb → eval_run_freshness_reasons.rb} +1 -1
  29. data/lib/retab/types/eval_run_freshness_status.rb +9 -0
  30. data/lib/retab/types/eval_run_trigger_type.rb +18 -0
  31. data/lib/retab/types/{latest_block_test_run_summary_outcome.rb → latest_block_eval_run_summary_outcome.rb} +1 -1
  32. data/lib/retab/types/{latest_block_test_run_summary_status.rb → latest_block_eval_run_summary_status.rb} +1 -1
  33. data/lib/retab/types/trigger_info_type.rb +1 -10
  34. data/lib/retab/types/{workflow_test_runs_order.rb → workflow_eval_result_verdict.rb} +1 -1
  35. data/lib/retab/types/workflow_eval_run_results_order.rb +9 -0
  36. data/lib/retab/types/{workflow_test_result_verdict.rb → workflow_eval_runs_order.rb} +1 -1
  37. data/lib/retab/types/workflow_eval_schema_drift.rb +9 -0
  38. data/lib/retab/types/{workflow_tests_order.rb → workflow_evals_order.rb} +1 -1
  39. data/lib/retab/types/workflow_experiment_freshness_state.rb +9 -0
  40. data/lib/retab/types/workflow_experiment_run_plan_mode.rb +15 -0
  41. data/lib/retab/types/workflow_experiments_exclude_status.rb +1 -1
  42. data/lib/retab/types/workflow_experiments_status.rb +1 -1
  43. data/lib/retab/version.rb +1 -1
  44. data/lib/retab/workflow_artifacts/extraction_workflow_artifact.rb +0 -3
  45. data/lib/retab/workflow_artifacts/parse_workflow_artifact.rb +0 -3
  46. data/lib/retab/workflow_artifacts/workflow_artifact.rb +5 -2
  47. data/lib/retab/workflow_block_executions/stored_block_execution.rb +3 -3
  48. data/lib/retab/workflow_edges.rb +6 -0
  49. data/lib/retab/{workflow_test_run_results/cancelled_workflow_test_run.rb → workflow_eval_run_results/cancelled_workflow_eval_run.rb} +1 -1
  50. data/lib/retab/{workflow_test_run_results/completed_workflow_test_run.rb → workflow_eval_run_results/completed_workflow_eval_run.rb} +1 -1
  51. data/lib/retab/workflow_eval_run_results/error_workflow_eval_run.rb +28 -0
  52. data/lib/retab/workflow_eval_run_results/pending_workflow_eval_run.rb +7 -0
  53. data/lib/retab/{workflow_test_run_results/error_workflow_test_run.rb → workflow_eval_run_results/queued_workflow_eval_run.rb} +1 -1
  54. data/lib/retab/{workflow_test_run_results/workflow_test_run_timing.rb → workflow_eval_run_results/result_file_ref.rb} +1 -1
  55. data/lib/retab/workflow_eval_run_results/running_workflow_eval_run.rb +7 -0
  56. data/lib/retab/{workflow_test_run_results/workflow_test_result.rb → workflow_eval_run_results/workflow_eval_result.rb} +17 -17
  57. data/lib/retab/workflow_eval_run_results/workflow_eval_run_timing.rb +7 -0
  58. data/lib/retab/{workflow_test_run_results.rb → workflow_eval_run_results.rb} +10 -10
  59. data/lib/retab/{workflow_test_runs/block_test_batch_execution_counts.rb → workflow_eval_runs/block_eval_batch_execution_counts.rb} +3 -3
  60. data/lib/retab/{workflow_test_runs/block_test_lifecycle_counts.rb → workflow_eval_runs/block_eval_lifecycle_counts.rb} +1 -1
  61. data/lib/retab/{workflow_test_runs/block_test_outcome_counts.rb → workflow_eval_runs/block_eval_outcome_counts.rb} +1 -1
  62. data/lib/retab/{workflow_test_runs/create_workflow_test_run_request.rb → workflow_eval_runs/create_workflow_eval_run_request.rb} +4 -4
  63. data/lib/retab/{workflow_tests/workflow_test_block_target.rb → workflow_eval_runs/eval_run_block_target.rb} +1 -1
  64. data/lib/retab/workflow_eval_runs/eval_run_freshness.rb +34 -0
  65. data/lib/retab/{workflow_test_runs/workflow_test_run_workflow_scope.rb → workflow_eval_runs/eval_run_trigger.rb} +1 -1
  66. data/lib/retab/{workflow_test_runs/workflow_test_run.rb → workflow_eval_runs/workflow_eval_run.rb} +18 -18
  67. data/lib/retab/{workflow_test_runs/workflow_test_run_block_scope.rb → workflow_eval_runs/workflow_eval_run_block_scope.rb} +1 -1
  68. data/lib/retab/{workflow_test_runs/workflow_test_run_single_scope.rb → workflow_eval_runs/workflow_eval_run_single_scope.rb} +4 -4
  69. data/lib/retab/workflow_eval_runs/workflow_eval_run_workflow_scope.rb +20 -0
  70. data/lib/retab/{workflow_test_runs.rb → workflow_eval_runs.rb} +24 -24
  71. data/lib/retab/{workflow_tests/create_workflow_test_request.rb → workflow_evals/create_workflow_eval_request.rb} +4 -4
  72. data/lib/retab/workflow_evals/eval_file_handle_input.rb +7 -0
  73. data/lib/retab/workflow_evals/eval_json_handle_input.rb +7 -0
  74. data/lib/retab/workflow_evals/eval_public_file_ref.rb +7 -0
  75. data/lib/retab/{workflow_tests/latest_block_test_run_summary.rb → workflow_evals/latest_block_eval_run_summary.rb} +4 -4
  76. data/lib/retab/{workflow_tests/manual_workflow_test_source.rb → workflow_evals/manual_workflow_eval_source.rb} +1 -1
  77. data/lib/retab/{workflow_tests/run_step_workflow_test_source.rb → workflow_evals/run_step_workflow_eval_source.rb} +1 -1
  78. data/lib/retab/{workflow_tests/update_workflow_test_request.rb → workflow_evals/update_workflow_eval_request.rb} +3 -3
  79. data/lib/retab/{workflow_tests/workflow_test.rb → workflow_evals/workflow_eval.rb} +7 -7
  80. data/lib/retab/workflow_evals/workflow_eval_block_target.rb +7 -0
  81. data/lib/retab/{workflow_tests.rb → workflow_evals.rb} +31 -31
  82. data/lib/retab/workflow_experiments/workflow_experiment.rb +12 -0
  83. data/lib/retab/workflow_runs.rb +1 -1
  84. data/lib/retab/workflows.rb +2 -2
  85. data/lib/retab.rb +3 -3
  86. data/rbi/retab/{block_test_batch_execution_counts.rbi → block_eval_batch_execution_counts.rbi} +5 -5
  87. data/rbi/retab/{block_test_lifecycle_counts.rbi → block_eval_lifecycle_counts.rbi} +1 -1
  88. data/rbi/retab/{block_test_outcome_counts.rbi → block_eval_outcome_counts.rbi} +1 -1
  89. data/rbi/retab/{cancelled_workflow_test_run.rbi → cancelled_workflow_eval_run.rbi} +1 -1
  90. data/rbi/retab/classification_request.rbi +2 -2
  91. data/rbi/retab/{completed_workflow_test_run.rbi → completed_workflow_eval_run.rbi} +1 -1
  92. data/rbi/retab/create_experiment_run_request.rbi +6 -0
  93. data/rbi/retab/create_file_blueprint_request.rbi +4 -4
  94. data/rbi/retab/{create_workflow_test_request.rbi → create_workflow_eval_request.rbi} +5 -5
  95. data/rbi/retab/{create_workflow_test_run_request.rbi → create_workflow_eval_run_request.rbi} +3 -3
  96. data/rbi/retab/create_workflow_run_request.rbi +2 -2
  97. data/rbi/retab/edit_request.rbi +2 -2
  98. data/rbi/retab/{error_workflow_test_run.rbi → error_workflow_eval_run.rbi} +1 -1
  99. data/rbi/retab/eval_file_handle_input.rbi +30 -0
  100. data/rbi/retab/eval_json_handle_input.rbi +30 -0
  101. data/rbi/retab/eval_public_file_ref.rbi +36 -0
  102. data/rbi/retab/{workflow_test_block_target.rbi → eval_run_block_target.rbi} +1 -1
  103. data/rbi/retab/eval_run_freshness.rbi +48 -0
  104. data/rbi/retab/{workflow_test_run_workflow_scope.rbi → eval_run_trigger.rbi} +1 -1
  105. data/rbi/retab/experiment_metrics_stale_error.rbi +2 -2
  106. data/rbi/retab/experiment_run.rbi +2 -2
  107. data/rbi/retab/experiment_runs.rbi +2 -1
  108. data/rbi/retab/experiment_summary_metrics_response.rbi +2 -2
  109. data/rbi/retab/extraction.rbi +0 -6
  110. data/rbi/retab/extraction_request.rbi +2 -8
  111. data/rbi/retab/extraction_workflow_artifact.rbi +0 -6
  112. data/rbi/retab/extractions.rbi +19 -2
  113. data/rbi/retab/file_blueprint.rbi +6 -6
  114. data/rbi/retab/file_handle_input.rbi +2 -2
  115. data/rbi/retab/files.rbi +2 -2
  116. data/rbi/retab/generate_schema_request.rbi +0 -6
  117. data/rbi/retab/{latest_block_test_run_summary.rbi → latest_block_eval_run_summary.rbi} +3 -3
  118. data/rbi/retab/{manual_workflow_test_source.rbi → manual_workflow_eval_source.rbi} +3 -3
  119. data/rbi/retab/metrics_stale_error_last_run.rbi +2 -2
  120. data/rbi/retab/parse.rbi +0 -6
  121. data/rbi/retab/parse_request.rbi +2 -8
  122. data/rbi/retab/parse_workflow_artifact.rbi +0 -6
  123. data/rbi/retab/parses.rbi +1 -2
  124. data/rbi/retab/partition_request.rbi +2 -2
  125. data/rbi/retab/{pending_workflow_test_run.rbi → pending_workflow_eval_run.rbi} +1 -1
  126. data/rbi/retab/{queued_workflow_test_run.rbi → queued_workflow_eval_run.rbi} +1 -1
  127. data/rbi/retab/result_file_ref.rbi +36 -0
  128. data/rbi/retab/{run_step_workflow_test_source.rbi → run_step_workflow_eval_source.rbi} +1 -1
  129. data/rbi/retab/{running_workflow_test_run.rbi → running_workflow_eval_run.rbi} +1 -1
  130. data/rbi/retab/schemas.rbi +1 -2
  131. data/rbi/retab/split_request.rbi +2 -2
  132. data/rbi/retab/stored_block_execution.rbi +2 -2
  133. data/rbi/retab/{update_workflow_test_request.rbi → update_workflow_eval_request.rbi} +3 -3
  134. data/rbi/retab/workflow_artifact.rbi +6 -0
  135. data/rbi/retab/workflow_edges.rbi +2 -1
  136. data/rbi/retab/{workflow_test.rbi → workflow_eval.rbi} +11 -11
  137. data/rbi/retab/workflow_eval_block_target.rbi +30 -0
  138. data/rbi/retab/{workflow_test_result.rbi → workflow_eval_result.rbi} +11 -11
  139. data/rbi/retab/workflow_eval_run.rbi +84 -0
  140. data/rbi/retab/{workflow_test_run_block_scope.rbi → workflow_eval_run_block_scope.rbi} +1 -1
  141. data/rbi/retab/{workflow_test_run_results.rbi → workflow_eval_run_results.rbi} +3 -3
  142. data/rbi/retab/{workflow_test_run_single_scope.rbi → workflow_eval_run_single_scope.rbi} +3 -3
  143. data/rbi/retab/{workflow_test_run_timing.rbi → workflow_eval_run_timing.rbi} +1 -1
  144. data/rbi/retab/workflow_eval_run_workflow_scope.rbi +24 -0
  145. data/rbi/retab/{workflow_test_runs.rbi → workflow_eval_runs.rbi} +8 -8
  146. data/rbi/retab/{workflow_tests.rbi → workflow_evals.rbi} +16 -16
  147. data/rbi/retab/workflow_experiment.rbi +24 -0
  148. data/rbi/retab/workflows.rbi +2 -2
  149. metadata +111 -92
  150. data/lib/retab/types/workflow_test_schema_drift.rb +0 -9
  151. data/lib/retab/workflow_test_run_results/pending_workflow_test_run.rb +0 -7
  152. data/lib/retab/workflow_test_run_results/queued_workflow_test_run.rb +0 -7
  153. data/lib/retab/workflow_test_run_results/running_workflow_test_run.rb +0 -7
  154. data/rbi/retab/workflow_test_run.rbi +0 -84
  155. /data/lib/retab/{workflow_test_run_results → workflow_eval_run_results}/assertion_failure.rb +0 -0
  156. /data/lib/retab/{workflow_test_run_results → workflow_eval_run_results}/assertion_result.rb +0 -0
  157. /data/lib/retab/{workflow_experiments → workflow_eval_run_results}/file_handle_input.rb +0 -0
  158. /data/lib/retab/{workflow_experiments → workflow_eval_run_results}/json_handle_input.rb +0 -0
  159. /data/lib/retab/{workflow_test_run_results → workflow_eval_run_results}/verdict_summary.rb +0 -0
  160. /data/lib/retab/{workflow_tests → workflow_evals}/all_items_match_condition.rb +0 -0
  161. /data/lib/retab/{workflow_tests → workflow_evals}/any_item_matches_condition.rb +0 -0
  162. /data/lib/retab/{workflow_tests → workflow_evals}/array_contains_condition.rb +0 -0
  163. /data/lib/retab/{workflow_experiments → workflow_evals}/artifact_drift.rb +0 -0
  164. /data/lib/retab/{workflow_experiments → workflow_evals}/artifact_freshness.rb +0 -0
  165. /data/lib/retab/{workflow_tests → workflow_evals}/assertion_schema_dep.rb +0 -0
  166. /data/lib/retab/{workflow_tests → workflow_evals}/assertion_spec.rb +0 -0
  167. /data/lib/retab/{workflow_tests → workflow_evals}/between_condition.rb +0 -0
  168. /data/lib/retab/{workflow_tests → workflow_evals}/contain_condition.rb +0 -0
  169. /data/lib/retab/{workflow_tests → workflow_evals}/ends_with_condition.rb +0 -0
  170. /data/lib/retab/{workflow_tests → workflow_evals}/equal_condition.rb +0 -0
  171. /data/lib/retab/{workflow_tests → workflow_evals}/exist_condition.rb +0 -0
  172. /data/lib/retab/{workflow_tests → workflow_evals}/json_schema_valid_condition.rb +0 -0
  173. /data/lib/retab/{workflow_tests → workflow_evals}/length_compare_condition.rb +0 -0
  174. /data/lib/retab/{workflow_tests → workflow_evals}/llm_judged_as_condition.rb +0 -0
  175. /data/lib/retab/{workflow_tests → workflow_evals}/llm_not_judged_as_condition.rb +0 -0
  176. /data/lib/retab/{workflow_tests → workflow_evals}/matche_regex_condition.rb +0 -0
  177. /data/lib/retab/{workflow_tests → workflow_evals}/not_contains_condition.rb +0 -0
  178. /data/lib/retab/{workflow_tests → workflow_evals}/not_equals_condition.rb +0 -0
  179. /data/lib/retab/{workflow_tests → workflow_evals}/not_exists_condition.rb +0 -0
  180. /data/lib/retab/{workflow_tests → workflow_evals}/number_compare_condition.rb +0 -0
  181. /data/lib/retab/{workflow_tests → workflow_evals}/object_contains_condition.rb +0 -0
  182. /data/lib/retab/{workflow_tests → workflow_evals}/output_target.rb +0 -0
  183. /data/lib/retab/{workflow_tests → workflow_evals}/similarity_gte_condition.rb +0 -0
  184. /data/lib/retab/{workflow_tests → workflow_evals}/split_iou_condition.rb +0 -0
  185. /data/lib/retab/{workflow_tests → workflow_evals}/start_with_condition.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d50f014e5ec16d2e08abc96e80ba4c0765860ca7f55240dc7ada7eefc712a99
4
- data.tar.gz: 67f1cb50dd4645965370155d9b5ddf3fa1e3310f2ada638c1a46ac1b02f6c5ef
3
+ metadata.gz: 6d8f00bc26ed73aa5d559ff12a8903bc8e0902d16aa47ee5bacdc174face30ad
4
+ data.tar.gz: c152d02486ec700e26c0a59c1ff51e07f15567516bfd06e19899ce1619771e30
5
5
  SHA512:
6
- metadata.gz: d4739b06f5ff47cc2f1042b943a82a8ec376188c83e1b745be1c55deb6bbd687b231abfd1be81010ef8b1fc714bb96c9648a10b6a65e62f491c5e55b2656ea17
7
- data.tar.gz: b5ac3b608829b0ea8c057d28f79ab03e1b352ca86d85282c192bbc719160e635af2d04573b6cc7e170bf25cfa36d73c30ffdf65750e9e71dfbd2efd292f7eb5d
6
+ metadata.gz: b89d753a806f26903c1f1bd3c005a80f92d8b7d940eba048d6f78de16e5241a27a628505eb2c320144dc1eed41579eefd750488007a345ced2368d4e24dec5fa
7
+ data.tar.gz: 4472ad621a070d8e80e703f3f4f4740d212ff7481966ce3094cb082361f74c648a8f0712bd43a1c34997d91ed8205c5146149b614252b4b607124ab33dba6054
@@ -72,11 +72,7 @@ module Retab
72
72
  req["User-Agent"] = @configuration.user_agent
73
73
  if auth
74
74
  key = (request_options[:api_key] || request_options["api_key"] || api_key)
75
- # Retab's API expects the raw key in `Api-Key` (not `Authorization: Bearer ...`).
76
- # Confirmed against the Python SDK's `client.py` and the server response on
77
- # /v1/files: "Provide a valid Bearer token, API Key, ..." — the API Key path
78
- # is the `Api-Key` header.
79
- req["Api-Key"] = key if key
75
+ req["Authorization"] = "Bearer #{key}" if key
80
76
  end
81
77
 
82
78
  if (idem = request_options[:idempotency_key] || request_options["idempotency_key"])
@@ -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
  "categories" => categories,
@@ -74,7 +74,7 @@ module Retab
74
74
  form_fields:,
75
75
  request_options: {}
76
76
  )
77
- document = Retab::MimeData.coerce(document) unless document.nil?
77
+ document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
78
78
  body = {
79
79
  "name" => name,
80
80
  "document" => document,
data/lib/retab/edits.rb CHANGED
@@ -107,7 +107,7 @@ module Retab
107
107
  background: nil,
108
108
  request_options: {}
109
109
  )
110
- document = Retab::MimeData.coerce(document) unless document.nil?
110
+ document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
111
111
  body = {
112
112
  "instructions" => instructions,
113
113
  "document" => document,
@@ -11,7 +11,7 @@ module Retab
11
11
  experiment_id: :experiment_id,
12
12
  stale_reasons: :stale_reasons,
13
13
  last_run: :last_run,
14
- current_config_fingerprint: :current_config_fingerprint,
14
+ current_block_execution_fingerprint: :current_block_execution_fingerprint,
15
15
  message: :message
16
16
  }.freeze
17
17
 
@@ -21,7 +21,7 @@ module Retab
21
21
  :experiment_id,
22
22
  :stale_reasons,
23
23
  :last_run,
24
- :current_config_fingerprint,
24
+ :current_block_execution_fingerprint,
25
25
  :message
26
26
  )
27
27
 
@@ -33,7 +33,7 @@ module Retab
33
33
  @experiment_id = hash[:experiment_id]
34
34
  @stale_reasons = (hash[:stale_reasons] || [])
35
35
  @last_run = hash[:last_run] ? Retab::MetricsStaleErrorLastRun.new(hash[:last_run]) : nil
36
- @current_config_fingerprint = hash[:current_config_fingerprint]
36
+ @current_block_execution_fingerprint = hash[:current_block_execution_fingerprint]
37
37
  @message = hash[:message]
38
38
  end
39
39
  end
@@ -10,7 +10,7 @@ module Retab
10
10
  run_id: :run_id,
11
11
  kind: :kind,
12
12
  view: :view,
13
- definition_fingerprint: :definition_fingerprint,
13
+ block_execution_fingerprint: :block_execution_fingerprint,
14
14
  block_type: :block_type,
15
15
  score: :score,
16
16
  prior_score: :prior_score,
@@ -24,7 +24,7 @@ module Retab
24
24
  :run_id,
25
25
  :kind,
26
26
  :view,
27
- :definition_fingerprint,
27
+ :block_execution_fingerprint,
28
28
  :block_type,
29
29
  :score,
30
30
  :prior_score,
@@ -40,7 +40,7 @@ module Retab
40
40
  @run_id = hash[:run_id]
41
41
  @kind = hash[:kind].nil? ? "summary" : hash[:kind]
42
42
  @view = hash[:view].nil? ? "summary" : hash[:view]
43
- @definition_fingerprint = hash[:definition_fingerprint]
43
+ @block_execution_fingerprint = hash[:block_execution_fingerprint]
44
44
  @block_type = hash[:block_type]
45
45
  @score = hash[:score]
46
46
  @prior_score = hash[:prior_score]
@@ -7,14 +7,14 @@ module Retab
7
7
 
8
8
  HASH_ATTRS = {
9
9
  run_id: :run_id,
10
- definition_fingerprint: :definition_fingerprint,
10
+ block_execution_fingerprint: :block_execution_fingerprint,
11
11
  score: :score,
12
12
  created_at: :created_at
13
13
  }.freeze
14
14
 
15
15
  attr_accessor(
16
16
  :run_id,
17
- :definition_fingerprint,
17
+ :block_execution_fingerprint,
18
18
  :score,
19
19
  :created_at
20
20
  )
@@ -23,7 +23,7 @@ module Retab
23
23
  super()
24
24
  hash = self.class.normalize(json)
25
25
  @run_id = hash[:run_id]
26
- @definition_fingerprint = hash[:definition_fingerprint]
26
+ @block_execution_fingerprint = hash[:block_execution_fingerprint]
27
27
  @score = hash[:score]
28
28
  @created_at = hash[:created_at]
29
29
  end
@@ -3,26 +3,5 @@
3
3
  # This file is auto-generated by oagen. Do not edit.
4
4
 
5
5
  module Retab
6
- class ErrorWorkflowExperimentResult < Retab::Types::BaseModel
7
-
8
- HASH_ATTRS = {
9
- status: :status,
10
- message: :message,
11
- details: :details
12
- }.freeze
13
-
14
- attr_accessor(
15
- :status,
16
- :message,
17
- :details
18
- )
19
-
20
- def initialize(json)
21
- super()
22
- hash = self.class.normalize(json)
23
- @status = hash[:status].nil? ? "error" : hash[:status]
24
- @message = hash[:message].nil? ? "(no message)" : hash[:message]
25
- @details = hash[:details] ? Retab::ErrorDetails.new(hash[:details]) : nil
26
- end
27
- end
6
+ ErrorWorkflowExperimentResult = ErrorWorkflowEvalRun
28
7
  end
@@ -7,12 +7,14 @@ module Retab
7
7
 
8
8
  HASH_ATTRS = {
9
9
  experiment_id: :experiment_id,
10
- workflow_id: :workflow_id
10
+ workflow_id: :workflow_id,
11
+ plan_token: :plan_token
11
12
  }.freeze
12
13
 
13
14
  attr_accessor(
14
15
  :experiment_id,
15
- :workflow_id
16
+ :workflow_id,
17
+ :plan_token
16
18
  )
17
19
 
18
20
  def initialize(json)
@@ -20,6 +22,7 @@ module Retab
20
22
  hash = self.class.normalize(json)
21
23
  @experiment_id = hash[:experiment_id]
22
24
  @workflow_id = hash[:workflow_id]
25
+ @plan_token = hash[:plan_token]
23
26
  end
24
27
  end
25
28
  end
@@ -3,5 +3,5 @@
3
3
  # This file is auto-generated by oagen. Do not edit.
4
4
 
5
5
  module Retab
6
- ErrorWorkflowExperimentRun = ErrorWorkflowExperimentResult
6
+ ErrorWorkflowExperimentRun = ErrorWorkflowEvalRun
7
7
  end
@@ -20,7 +20,7 @@ module Retab
20
20
  block_version_id: :block_version_id,
21
21
  metrics_validity_fingerprint: :metrics_validity_fingerprint,
22
22
  metrics_validity_fingerprint_version: :metrics_validity_fingerprint_version,
23
- definition_fingerprint: :definition_fingerprint,
23
+ block_execution_fingerprint: :block_execution_fingerprint,
24
24
  documents_fingerprint: :documents_fingerprint,
25
25
  score: :score,
26
26
  total_document_count: :total_document_count,
@@ -44,7 +44,7 @@ module Retab
44
44
  :block_version_id,
45
45
  :metrics_validity_fingerprint,
46
46
  :metrics_validity_fingerprint_version,
47
- :definition_fingerprint,
47
+ :block_execution_fingerprint,
48
48
  :documents_fingerprint,
49
49
  :score,
50
50
  :total_document_count,
@@ -87,7 +87,7 @@ module Retab
87
87
  @block_version_id = hash[:block_version_id]
88
88
  @metrics_validity_fingerprint = hash[:metrics_validity_fingerprint]
89
89
  @metrics_validity_fingerprint_version = hash[:metrics_validity_fingerprint_version]
90
- @definition_fingerprint = hash[:definition_fingerprint]
90
+ @block_execution_fingerprint = hash[:block_execution_fingerprint]
91
91
  @documents_fingerprint = hash[:documents_fingerprint]
92
92
  @score = hash[:score]
93
93
  @total_document_count = hash[:total_document_count]
@@ -106,16 +106,19 @@ module Retab
106
106
  # Create Experiment Run Flat
107
107
  # @param experiment_id [String] The experiment to create a run for.
108
108
  # @param workflow_id [String, nil] Optional. When omitted, the workflow is derived from the experiment record. When supplied, must match the experiment's workflow_id (404 otherwise).
109
+ # @param plan_token [String, nil] Optional short-lived token returned by the run-plan preview. When supplied, run creation rejects if the current plan no longer matches the preview.
109
110
  # @param request_options [Hash] (see Retab::Types::RequestOptions)
110
111
  # @return [Retab::ExperimentRun]
111
112
  def create(
112
113
  experiment_id:,
113
114
  workflow_id: nil,
115
+ plan_token: nil,
114
116
  request_options: {}
115
117
  )
116
118
  body = {
117
119
  "experiment_id" => experiment_id,
118
- "workflow_id" => workflow_id
120
+ "workflow_id" => workflow_id,
121
+ "plan_token" => plan_token
119
122
  }.compact
120
123
  response = @client.request(
121
124
  method: :post,
@@ -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,
@@ -28,7 +27,6 @@ module Retab
28
27
  :model,
29
28
  :json_schema,
30
29
  :n_consensus,
31
- :image_resolution_dpi,
32
30
  :instructions,
33
31
  :output,
34
32
  :status,
@@ -47,7 +45,6 @@ module Retab
47
45
  @model = hash[:model]
48
46
  @json_schema = hash[:json_schema] || {}
49
47
  @n_consensus = hash[:n_consensus]
50
- @image_resolution_dpi = hash[:image_resolution_dpi]
51
48
  @instructions = hash[:instructions]
52
49
  @output = hash[:output] || {}
53
50
  @status = hash[:status].nil? ? "pending" : hash[:status]
@@ -9,7 +9,6 @@ module Retab
9
9
  document: :document,
10
10
  json_schema: :json_schema,
11
11
  model: :model,
12
- image_resolution_dpi: :image_resolution_dpi,
13
12
  instructions: :instructions,
14
13
  n_consensus: :n_consensus,
15
14
  metadata: :metadata,
@@ -24,7 +23,6 @@ module Retab
24
23
  :document,
25
24
  :json_schema,
26
25
  :model,
27
- :image_resolution_dpi,
28
26
  :instructions,
29
27
  :n_consensus,
30
28
  :metadata,
@@ -41,7 +39,6 @@ module Retab
41
39
  @document = hash[:document] ? Retab::MimeData.new(hash[:document]) : nil
42
40
  @json_schema = hash[:json_schema] || {}
43
41
  @model = hash[:model].nil? ? "retab-small" : hash[:model]
44
- @image_resolution_dpi = hash[:image_resolution_dpi]
45
42
  @instructions = hash[:instructions]
46
43
  @n_consensus = hash[:n_consensus]
47
44
  @metadata = hash[:metadata] || {}
@@ -102,7 +102,6 @@ module Retab
102
102
  # @param document [Retab::MimeData, Pathname, IO, String, Hash]
103
103
  # @param json_schema [Hash{String => Object}] JSON schema describing the structured output
104
104
  # @param model [String, nil] The model to use for the extraction
105
- # @param image_resolution_dpi [Integer, nil] Resolution of the image sent to the LLM
106
105
  # @param instructions [String, nil] Free-form instructions appended to the system prompt to steer the extraction.
107
106
  # @param n_consensus [Integer, nil] Number of consensus extraction runs to perform. Uses deterministic single-pass when set to 1.
108
107
  # @param metadata [Hash{String => String}, nil] User-defined metadata to associate with this extraction
@@ -117,7 +116,6 @@ module Retab
117
116
  document:,
118
117
  json_schema:,
119
118
  model: nil,
120
- image_resolution_dpi: nil,
121
119
  instructions: nil,
122
120
  n_consensus: nil,
123
121
  metadata: nil,
@@ -128,12 +126,11 @@ module Retab
128
126
  chunking_keys: nil,
129
127
  request_options: {}
130
128
  )
131
- document = Retab::MimeData.coerce(document) unless document.nil?
129
+ document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
132
130
  body = {
133
131
  "document" => document,
134
132
  "json_schema" => json_schema,
135
133
  "model" => model,
136
- "image_resolution_dpi" => image_resolution_dpi,
137
134
  "instructions" => instructions,
138
135
  "n_consensus" => n_consensus,
139
136
  "metadata" => metadata,
@@ -159,6 +156,58 @@ module Retab
159
156
  result
160
157
  end
161
158
 
159
+ # Create Extraction Stream
160
+ # @param document [Retab::MimeData, Pathname, IO, String, Hash]
161
+ # @param json_schema [Hash{String => Object}] JSON schema describing the structured output
162
+ # @param model [String, nil] The model to use for the extraction
163
+ # @param instructions [String, nil] Free-form instructions appended to the system prompt to steer the extraction.
164
+ # @param n_consensus [Integer, nil] Number of consensus extraction runs to perform. Uses deterministic single-pass when set to 1.
165
+ # @param metadata [Hash{String => String}, nil] User-defined metadata to associate with this extraction
166
+ # @param additional_messages [Array<Hash{String => Object}>, nil] Additional chat messages forwarded to the extraction model.
167
+ # @param bust_cache [Boolean, nil] If true, skip the LLM cache and force a fresh completion
168
+ # @param stream [Boolean, nil]
169
+ # @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.
170
+ # @param chunking_keys [Hash{String => String}, nil]
171
+ # @param request_options [Hash] (see Retab::Types::RequestOptions)
172
+ # @return [void]
173
+ def create_stream(
174
+ document:,
175
+ json_schema:,
176
+ model: nil,
177
+ instructions: nil,
178
+ n_consensus: nil,
179
+ metadata: nil,
180
+ additional_messages: nil,
181
+ bust_cache: nil,
182
+ stream: nil,
183
+ background: nil,
184
+ chunking_keys: nil,
185
+ request_options: {}
186
+ )
187
+ document = Retab::MimeData.coerce(document, client: @client) unless document.nil?
188
+ body = {
189
+ "document" => document,
190
+ "json_schema" => json_schema,
191
+ "model" => model,
192
+ "instructions" => instructions,
193
+ "n_consensus" => n_consensus,
194
+ "metadata" => metadata,
195
+ "additional_messages" => additional_messages,
196
+ "bust_cache" => bust_cache,
197
+ "stream" => stream,
198
+ "background" => background,
199
+ "chunking_keys" => chunking_keys
200
+ }.compact
201
+ @client.request(
202
+ method: :post,
203
+ path: "/v1/extractions/stream",
204
+ auth: true,
205
+ body: body,
206
+ request_options: request_options
207
+ )
208
+ nil
209
+ end
210
+
162
211
  # Get Extraction
163
212
  # @param extraction_id [String]
164
213
  # @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
@@ -7,15 +7,15 @@ module Retab
7
7
 
8
8
  HASH_ATTRS = {
9
9
  file_id: :file_id,
10
- mode: :mode,
11
10
  intent: :intent,
11
+ mode: :mode,
12
12
  background: :background
13
13
  }.freeze
14
14
 
15
15
  attr_accessor(
16
16
  :file_id,
17
- :mode,
18
17
  :intent,
18
+ :mode,
19
19
  :background
20
20
  )
21
21
 
@@ -23,8 +23,8 @@ module Retab
23
23
  super()
24
24
  hash = self.class.normalize(json)
25
25
  @file_id = hash[:file_id]
26
- @mode = hash[:mode]
27
26
  @intent = hash[:intent]
27
+ @mode = hash[:mode]
28
28
  @background = hash[:background].nil? ? false : hash[:background]
29
29
  end
30
30
  end
@@ -9,28 +9,28 @@ module Retab
9
9
  object: :object,
10
10
  id: :id,
11
11
  file: :file,
12
- mode: :mode,
13
12
  intent: :intent,
14
13
  output: :output,
15
14
  status: :status,
16
15
  error: :error,
17
16
  created_at: :created_at,
18
17
  started_at: :started_at,
19
- completed_at: :completed_at
18
+ completed_at: :completed_at,
19
+ mode: :mode
20
20
  }.freeze
21
21
 
22
22
  attr_accessor(
23
23
  :object,
24
24
  :id,
25
25
  :file,
26
- :mode,
27
26
  :intent,
28
27
  :output,
29
28
  :status,
30
29
  :error,
31
30
  :created_at,
32
31
  :started_at,
33
- :completed_at
32
+ :completed_at,
33
+ :mode
34
34
  )
35
35
 
36
36
  def initialize(json)
@@ -39,7 +39,6 @@ module Retab
39
39
  @object = hash[:object].nil? ? "file.blueprint" : hash[:object]
40
40
  @id = hash[:id]
41
41
  @file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
42
- @mode = hash[:mode]
43
42
  @intent = hash[:intent]
44
43
  @output = hash[:output] || {}
45
44
  @status = hash[:status].nil? ? "pending" : hash[:status]
@@ -47,6 +46,7 @@ module Retab
47
46
  @created_at = hash[:created_at]
48
47
  @started_at = hash[:started_at]
49
48
  @completed_at = hash[:completed_at]
49
+ @mode = hash[:mode]
50
50
  end
51
51
  end
52
52
  end
data/lib/retab/files.rb CHANGED
@@ -90,22 +90,22 @@ module Retab
90
90
 
91
91
  # Create File Blueprint
92
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
93
  # @param intent [String, nil] Optional user intent used to guide the blueprint analysis.
94
+ # @param mode [Retab::Types::CreateFileBlueprintRequestMode, nil] Legacy compatibility field. Blueprint analysis always runs a single pass.
95
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
96
  # @param request_options [Hash] (see Retab::Types::RequestOptions)
97
97
  # @return [Retab::FileBlueprint]
98
98
  def create_blueprint(
99
99
  file_id:,
100
- mode: nil,
101
100
  intent: nil,
101
+ mode: nil,
102
102
  background: nil,
103
103
  request_options: {}
104
104
  )
105
105
  body = {
106
106
  "file_id" => file_id,
107
- "mode" => mode,
108
107
  "intent" => intent,
108
+ "mode" => mode,
109
109
  "background" => background
110
110
  }.compact
111
111
  response = @client.request(
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
- def self.coerce(input)
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 do |document|
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 true if defined?(Retab::FileRef) && input.is_a?(Retab::FileRef)
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.
@@ -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]