omniai-google 3.7.1 → 3.8.0

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: 74848884db95fef34b6c7306b2814ecf8d50797963e690a93b77e69c93cc7d3a
4
- data.tar.gz: 9fbb92e5fe4fe36d9086182391ae383180607b5e97b36a17e458dc200bef73e1
3
+ metadata.gz: f8c007176bac8a2c1f07b5fb231997b9fdef9480cc75242145bdc628cde9d954
4
+ data.tar.gz: 4fbb50ea8ee2c1fae8a091712a70a89f872320483d946d0351e70d383683c2e8
5
5
  SHA512:
6
- metadata.gz: c92c79303ec17e46832115d075aa29760ba8d1f52111286d51d370c49c5266bb2e0ec9956e058a133de69bd0bb28c8ea4fa52efab34edea64f9cdc896397069e
7
- data.tar.gz: 5fc61a87b13a8bd3ba73bc6b8c150c7da1d77aef938d7c826f9eac541b78ea288fb0698bbaf9a7609d7a19a85607b3d04d97e82cd013a46f64c319c86329ea60
6
+ metadata.gz: 38c769edd5f51804ab9cd3c88505681d109d3c4e078ec00813cea2074fb53952c9caea2e55751d22ca35ad23d158e086ae87aab4790b090c85350dd75ad30211
7
+ data.tar.gz: 3c5a7eca99512ff6ed4e4d2f2c51422154302d0ea89d9c13238ee8680771f497ffc05998b6fcb849b1b7ea9f89c89523826d10df28fc64913a77ed909c2bad9b
data/README.md CHANGED
@@ -87,7 +87,7 @@ completion.text # 'The capital of Canada is Ottawa.'
87
87
 
88
88
  #### Model
89
89
 
90
- `model` takes an optional string (default is `gemini-3-flash-preview`):
90
+ `model` takes an optional string (default is `gemini-3.5-flash`):
91
91
 
92
92
  ```ruby
93
93
  completion = client.chat('How fast is a cheetah?', model: OmniAI::Google::Chat::Model::GEMINI_FLASH)
@@ -86,13 +86,41 @@ module OmniAI
86
86
  parts = candidate["content"]["parts"] ||= []
87
87
  last_part = parts.last
88
88
 
89
- if (last_part&.key?("text") && part.key?("text")) ||
90
- (last_part&.key?("thought") && part.key?("thought"))
89
+ if can_concatenate?(last_part, part)
91
90
  last_part["text"] += part["text"]
92
91
  else
93
92
  parts << part
94
93
  end
95
94
  end
95
+
96
+ # True when `part` should concatenate into `last_part` rather than appear
97
+ # as a new part. Two parts merge only when they're the same kind: both
98
+ # text parts AND they agree on whether they're a reasoning (thought) chunk
99
+ # or an answer chunk. Without the thought-state check, an answer chunk
100
+ # arriving after thought chunks would coalesce into the trailing thought,
101
+ # marking the visible answer as `thought: true` and causing callers to see
102
+ # an empty `response.text`.
103
+ #
104
+ # @param last_part [Hash, nil]
105
+ # @param part [Hash]
106
+ # @return [Boolean]
107
+ def can_concatenate?(last_part, part)
108
+ return false if last_part.nil?
109
+ return false unless last_part.key?("text") && part.key?("text")
110
+
111
+ thought_part?(last_part) == thought_part?(part)
112
+ end
113
+
114
+ # Gemini may omit the "thought" key entirely on answer parts (so it's nil),
115
+ # or set it explicitly to `false`, or `true` for thought parts. Normalize to
116
+ # a single boolean so the comparison in can_concatenate? treats nil and false
117
+ # as equivalent (both = "this is an answer part, not a thought part").
118
+ #
119
+ # @param part [Hash]
120
+ # @return [Boolean]
121
+ def thought_part?(part)
122
+ part["thought"] == true
123
+ end
96
124
  end
97
125
  end
98
126
  end
@@ -22,11 +22,12 @@ module OmniAI
22
22
  GEMINI_2_0_FLASH = "gemini-2.0-flash"
23
23
  GEMINI_2_5_FLASH = "gemini-2.5-flash"
24
24
  GEMINI_3_FLASH = "gemini-3-flash-preview"
25
+ GEMINI_3_5_FLASH = "gemini-3.5-flash"
25
26
  GEMINI_PRO = GEMINI_3_1_PRO
26
- GEMINI_FLASH = GEMINI_3_FLASH
27
+ GEMINI_FLASH = GEMINI_3_5_FLASH
27
28
  end
28
29
 
29
- DEFAULT_MODEL = Model::GEMINI_3_FLASH
30
+ DEFAULT_MODEL = Model::GEMINI_3_5_FLASH
30
31
 
31
32
  module ResponseMimeType
32
33
  JSON = "application/json"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "3.7.1"
5
+ VERSION = "3.8.0"
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.7.1
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre