omniai-google 3.18.0 → 3.18.1

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: cc3b952ff375db770509f12502a396e2a7cbdd9675467f76f3e83c6eb8e0ce23
4
+ data.tar.gz: 9f7c3394ad70dd14035ed1fe3dd60b9b2097d4708c8f744601e66bfee5fc09d9
5
5
  SHA512:
6
- metadata.gz: b5ba5463d9357d4cf12910d26beb99f4300b123c2efa44b9d0b52e1410acfc698cbf8e601e6a2f730664e946b9178522d736c72cabc661524c2adc01b494f4fc
7
- data.tar.gz: 99d73d1e2a2ba26424e3cb0ad302fea0ad51e944864ac8d3e14d8770220618386f20c59b1b1ec62a7d50bae3ad15343b1140e2b80b14faebeeb235dbc3460aa1
6
+ metadata.gz: daf96548f0e096cd0fa5c7b2cfb2c1dda1e70559dab2f98ba75a69dd00ff00e443969529c634f317b8df84d089b25106640d6478bfd54473034fd082f23a0a25
7
+ data.tar.gz: 56aa7271fc97ac4002c739eedbddb8834bf440f2d4868732b31f68a250425d2a6f1f6b9fe22a1496f08deb115fd66312813c08fa5396042d9b76ea9a360fafe6
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
 
@@ -82,23 +79,17 @@ module OmniAI
82
79
 
83
80
  raise HTTPError, "No operation name returned from batch recognition request" unless operation_name
84
81
 
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
91
-
92
82
  # Poll for completion
93
83
  result = poll_operation!(operation_name)
94
84
 
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
  {
@@ -475,7 +475,7 @@ module OmniAI
475
475
 
476
476
  file = bucket.file(object_name)
477
477
  file&.delete
478
- rescue ::Google::Cloud::Error => e
478
+ rescue StandardError => e # never mask the transcript or the original error
479
479
  @client.logger&.warn("Failed to cleanup GCS file #{gcs_uri}: #{e.message}")
480
480
  end
481
481
 
@@ -492,7 +492,8 @@ module OmniAI
492
492
  estimated_duration_seconds = (file_size_bytes * 8.0) / assumed_bitrate_bps
493
493
  estimated_processing_seconds = estimated_duration_seconds * 0.3
494
494
  total_wait_seconds = estimated_processing_seconds + 90
495
- final_wait_seconds = total_wait_seconds.clamp(180, 10_800)
495
+ # Batch jobs can queue for minutes regardless of audio length
496
+ final_wait_seconds = total_wait_seconds.clamp(600, 10_800)
496
497
  (final_wait_seconds / 15).ceil
497
498
  end
498
499
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "3.18.0"
5
+ VERSION = "3.18.1"
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre