omniai-google 3.17.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc3b952ff375db770509f12502a396e2a7cbdd9675467f76f3e83c6eb8e0ce23
|
|
4
|
+
data.tar.gz: 9f7c3394ad70dd14035ed1fe3dd60b9b2097d4708c8f744601e66bfee5fc09d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:
|
|
@@ -5,17 +5,21 @@ module OmniAI
|
|
|
5
5
|
class Chat
|
|
6
6
|
# Overrides tool-call result serialize / deserialize.
|
|
7
7
|
module ToolCallResultSerializer
|
|
8
|
+
# A result whose content is media (e.g. an image) is sent as a multimodal function response part.
|
|
9
|
+
#
|
|
8
10
|
# @param tool_call_response [OmniAI::Chat::ToolCallResult]
|
|
9
11
|
# @return [Hash]
|
|
10
12
|
def self.serialize(tool_call_response, *)
|
|
13
|
+
name = tool_call_response.tool_call_id
|
|
14
|
+
content = tool_call_response.content
|
|
15
|
+
|
|
11
16
|
result = {
|
|
12
|
-
functionResponse:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
content:
|
|
17
|
-
|
|
18
|
-
},
|
|
17
|
+
functionResponse:
|
|
18
|
+
if content.is_a?(OmniAI::Chat::Media)
|
|
19
|
+
{ name:, response: { name: }, parts: [MediaSerializer.serialize(content)] }
|
|
20
|
+
else
|
|
21
|
+
{ name:, response: { name:, content: } }
|
|
22
|
+
end,
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
thought_signature = tool_call_response.options[:thought_signature]
|
|
@@ -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
|
|
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
|
-
|
|
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
|