omniai-google 2.6.2 → 2.6.4

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: cb64970aa23a098c48810b8d2d299665c383d188d7a908c1d331375235083dc5
4
- data.tar.gz: 10161c3268426a21701d82ecf7a87f24b4afc901f17e283eeeb999ad717d96c0
3
+ metadata.gz: 9b4a06d7346381cd281088f6e95cb85cf0142f286ff16a26e6681447ba5a0401
4
+ data.tar.gz: 5ada4e7eb1e51bbbb01e1981917ccc3331500a847e45586b4a3618b51d26992a
5
5
  SHA512:
6
- metadata.gz: a261a66b7a8ddfb723a2327dda567a8494bba59420626a6f57dbd4f76838b9f603ef5c619b08af245ecb2a72865d7a9bf905c320d6bd1d4df943bf60141fc649
7
- data.tar.gz: 9ff5956e21aeefa6fe4829dfe5f629a94ddb35b49e24fad1e5e5f48b065c58c393265aeb7b1bbfa2a4b9136dcfb74798f904bc960c05f14870b69987a1d4160d
6
+ metadata.gz: 9d929c63f5008bc8c23261d2cdde88f56aca8b17ce1524443915b4181d590fa6b6778b02719ed03f6342eec94c406e64c5b76b411900884e3dae5349a0eb1edf
7
+ data.tar.gz: 1f68746ee88d7c17804a125b4d48c49b0309438408e555172889e28b7e408b9823bd63226d091d2c5159046a973a8d8e932f1ae4dcc64a3a62ebe68c979c2834
@@ -53,11 +53,7 @@ module OmniAI
53
53
  # @yieldparam delta [OmniAI::Chat::Delta]
54
54
  #
55
55
  # @param candidate [Hash]
56
- # @param index [Integer]
57
56
  def process_candidate!(candidate:, index:, &block)
58
- parts = candidate["content"]["parts"]
59
- return unless parts
60
-
61
57
  candidate["content"]["parts"].each do |part|
62
58
  block&.call(OmniAI::Chat::Delta.new(text: part["text"])) if part["text"]
63
59
  end
@@ -71,19 +67,23 @@ module OmniAI
71
67
  if @data["candidates"][index].nil?
72
68
  @data["candidates"][index] = candidate
73
69
  else
74
- merge_parts!(content: @data["candidates"][index]["content"], parts: candidate["content"]["parts"])
70
+ merge_parts!(parts: candidate["content"]["parts"], candidate: @data["candidates"][index])
75
71
  end
76
72
  end
77
73
 
78
- # @param content [Hash]
79
74
  # @param parts [Array<Hash>]
80
- def merge_parts!(content:, parts:)
81
- parts.each_with_index do |part, index|
82
- if content["parts"][index].nil?
83
- content["parts"][index] = part
84
- else
85
- content["parts"][index]["text"] += part["text"]
86
- end
75
+ # @param candidate [Hash]
76
+ def merge_parts!(parts:, candidate:)
77
+ parts.each { |part| merge_part!(part:, candidate:) }
78
+ end
79
+
80
+ # @param part [Hash]
81
+ # @param into [Hash]
82
+ def merge_part!(part:, candidate:)
83
+ if candidate["content"]["parts"][-1]&.key?("text") && part["text"]
84
+ candidate["content"]["parts"][-1]["text"] += part["text"]
85
+ else
86
+ candidate["content"]["parts"] << part
87
87
  end
88
88
  end
89
89
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "2.6.2"
5
+ VERSION = "2.6.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-12 00:00:00.000000000 Z
10
+ date: 2025-05-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: event_stream_parser