omniai-google 3.18.0 → 3.18.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10f903f10526a5e5b609434b87ab652142e7298e5fa881fbd9bba342baeae696
4
- data.tar.gz: 0b9a117af8acd962fc427a88472f7d5f749e9cfa4848371e723eee191b034ded
3
+ metadata.gz: c07c0c6fcf73437ef30346dd7123a6f78855631ce160d590dc0331b48a24097a
4
+ data.tar.gz: 60c2e3f6f9130116a8a34d65935588fffb04e8922c7c3df85dc01ce61734c955
5
5
  SHA512:
6
- metadata.gz: b5ba5463d9357d4cf12910d26beb99f4300b123c2efa44b9d0b52e1410acfc698cbf8e601e6a2f730664e946b9178522d736c72cabc661524c2adc01b494f4fc
7
- data.tar.gz: 99d73d1e2a2ba26424e3cb0ad302fea0ad51e944864ac8d3e14d8770220618386f20c59b1b1ec62a7d50bae3ad15343b1140e2b80b14faebeeb235dbc3460aa1
6
+ metadata.gz: 180ec343c726b29490fd2a0720b1ce2b1d321bf263badfc113908d7b7d5f1aa3857f395fdc9c415fc59cd4ce925fc5583ef2e0842388316da47137f19a1790b5
7
+ data.tar.gz: b3a3d233bbcbe4a753bca419edc63482e2aba1143d3323e8be7dffdd6a23678e423e7db0e4f69af8a8b585cd9683537425424065c995fd088a93efb8feab895e
data/README.md CHANGED
@@ -134,6 +134,8 @@ OmniAI::Google.configure do |config|
134
134
  end
135
135
  ```
136
136
 
137
+ The key must be a **symbol**. `chat_options["max_tokens"]` is neither read nor withheld from the payload, so it reaches Gemini as an unknown top-level field and the request fails with a 400.
138
+
137
139
  The value is passed through unchanged — no floor is imposed, so the number you ask for is the number that reaches the wire. When the cap is hit, `response.finish_reason.reason` is `:length`.
138
140
 
139
141
  **Size it as thinking headroom plus expected answer.** Unlike Anthropic's answer-only ceiling, Gemini spends this budget on thinking *before* emitting an answer. A cap sized to the expected answer alone gets consumed by thinking on any request the model reasons about:
@@ -69,9 +69,6 @@ module OmniAI
69
69
  #
70
70
  # @return [OmniAI::Transcribe::Transcription]
71
71
  def process_async!
72
- # Track if we uploaded the file for cleanup
73
- uploaded_gcs_uri = nil
74
-
75
72
  # Start the batch recognition job
76
73
  response = request_batch!
77
74
 
@@ -80,14 +77,7 @@ module OmniAI
80
77
  operation_data = response.parse
81
78
  operation_name = operation_data["name"]
82
79
 
83
- raise HTTPError, "No operation name returned from batch recognition request" unless operation_name
84
-
85
- # Extract GCS URI for cleanup if we uploaded it
86
- if operation_data.dig("metadata", "batchRecognizeRequest", "files")
87
- file_uri = operation_data.dig("metadata", "batchRecognizeRequest", "files", 0, "uri")
88
- # Only mark for cleanup if it's not a user-provided GCS URI
89
- uploaded_gcs_uri = file_uri unless @io.is_a?(String) && @io.start_with?("gs://")
90
- end
80
+ raise OmniAI::Error, "No operation name returned from batch recognition request" unless operation_name
91
81
 
92
82
  # Poll for completion
93
83
  result = poll_operation!(operation_name)
@@ -95,10 +85,11 @@ module OmniAI
95
85
  # Extract transcript from completed operation
96
86
  transcript_data = extract_batch_transcript(result)
97
87
 
98
- # Clean up uploaded file if we created it
99
- cleanup_gcs_file(uploaded_gcs_uri) if uploaded_gcs_uri
100
-
101
88
  Transcription.parse(model: @model, format: @format, data: transcript_data)
89
+ ensure
90
+ # Delete our upload even when the request fails or polling times out
91
+ cleanup_gcs_file(@uploaded_gcs_uri) if @uploaded_gcs_uri
92
+ @uploaded_gcs_uri = nil
102
93
  end
103
94
 
104
95
  protected
@@ -194,8 +194,8 @@ module OmniAI
194
194
  audio_uri = if @io.is_a?(String) && @io.start_with?("gs://")
195
195
  @io
196
196
  else
197
- # Force GCS upload for batch recognition
198
- Bucket.process!(client: @client, io: @io)
197
+ # Force GCS upload for batch recognition; process_async! deletes it
198
+ @uploaded_gcs_uri ||= Bucket.process!(client: @client, io: @io)
199
199
  end
200
200
 
201
201
  {
@@ -237,7 +237,7 @@ module OmniAI
237
237
  # Check for errors
238
238
  if operation_data["error"]
239
239
  error_message = operation_data.dig("error", "message") || "Unknown error"
240
- raise HTTPError, "Operation failed: #{error_message}"
240
+ raise OmniAI::Error, "Operation failed: #{error_message}"
241
241
  end
242
242
 
243
243
  # Check if done
@@ -288,6 +288,11 @@ module OmniAI
288
288
  file_result = batch_results.values.first
289
289
  return empty_transcript_data unless file_result
290
290
 
291
+ # A done operation can still carry a per-file failure (e.g. unsupported encoding)
292
+ if (error = file_result["error"])
293
+ raise OmniAI::Error, "Transcription failed (code #{error['code']}): #{error['message']}"
294
+ end
295
+
291
296
  transcript_segments = file_result.dig("transcript", "results")
292
297
  return empty_transcript_data unless transcript_segments&.any?
293
298
 
@@ -475,7 +480,7 @@ module OmniAI
475
480
 
476
481
  file = bucket.file(object_name)
477
482
  file&.delete
478
- rescue ::Google::Cloud::Error => e
483
+ rescue StandardError => e # never mask the transcript or the original error
479
484
  @client.logger&.warn("Failed to cleanup GCS file #{gcs_uri}: #{e.message}")
480
485
  end
481
486
 
@@ -492,7 +497,8 @@ module OmniAI
492
497
  estimated_duration_seconds = (file_size_bytes * 8.0) / assumed_bitrate_bps
493
498
  estimated_processing_seconds = estimated_duration_seconds * 0.3
494
499
  total_wait_seconds = estimated_processing_seconds + 90
495
- final_wait_seconds = total_wait_seconds.clamp(180, 10_800)
500
+ # Batch jobs can queue for minutes regardless of audio length
501
+ final_wait_seconds = total_wait_seconds.clamp(600, 10_800)
496
502
  (final_wait_seconds / 15).ceil
497
503
  end
498
504
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "3.18.0"
5
+ VERSION = "3.18.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.18.0
4
+ version: 3.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre