omniai-google 3.7.1 → 3.7.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 +4 -4
- data/lib/omniai/google/chat/stream.rb +30 -2
- data/lib/omniai/google/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8f0e603d848a10021b4039331d5ace03d9fcebdc6ff0657128bc9cb1da5b8a4d
|
|
4
|
+
data.tar.gz: 53712cee681975309f887148fd7bf68e7c8b73030feff12287d3b46f7b6af7e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef4e3f492ed3c3be562ed3f1137b8264126e7b4e80134195800661bb0341b77bdce81d38ccc12ca254752f80e594e4e83adcc09afd24edff5eccf42addb51aa2
|
|
7
|
+
data.tar.gz: fcd20b06d373fb62752e26cfc89ca8bdac82a9bcfad1a2d6cb8d6c520a1c698d6dfcf606038f03bafd322695b20d6eba43d2e391ca860fc8ce57ca1ef78ca3ca
|
|
@@ -86,13 +86,41 @@ module OmniAI
|
|
|
86
86
|
parts = candidate["content"]["parts"] ||= []
|
|
87
87
|
last_part = parts.last
|
|
88
88
|
|
|
89
|
-
if (last_part
|
|
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
|