omniai-google 2.6.2 → 2.6.3

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: 1f578af1eb17aad95c7d8d95241481ea6fa606f9dbdca2bfb098e664874cbfe1
4
+ data.tar.gz: 8ffb8c563e0e1464aeaecd38d7b764227b3a13302a130c43d5a1989f9abb6cfc
5
5
  SHA512:
6
- metadata.gz: a261a66b7a8ddfb723a2327dda567a8494bba59420626a6f57dbd4f76838b9f603ef5c619b08af245ecb2a72865d7a9bf905c320d6bd1d4df943bf60141fc649
7
- data.tar.gz: 9ff5956e21aeefa6fe4829dfe5f629a94ddb35b49e24fad1e5e5f48b065c58c393265aeb7b1bbfa2a4b9136dcfb74798f904bc960c05f14870b69987a1d4160d
6
+ metadata.gz: 8db2a30f2424c265690d6d9d7910c1de1774ddc452405c64a37a323fcaa1a9f0571128ceb03d47dda98ba5c943708b26a127f881c954d533977d2ca81c377401
7
+ data.tar.gz: 3a6245e97f79785079a3490eed18cdc32f5da909863959fbef281f40df7a5da2dff4416725dd56b173c73a7dd0c06b945a52143d37a229c539e4a4eed9ea5d3d
@@ -44,8 +44,8 @@ module OmniAI
44
44
  @data[key] = value unless key.eql?("candidates")
45
45
  end
46
46
 
47
- data["candidates"].each_with_index do |candidate, index|
48
- process_candidate!(candidate:, index:, &block)
47
+ data["candidates"].each do |candidate|
48
+ process_candidate!(candidate:, &block)
49
49
  end
50
50
  end
51
51
 
@@ -53,37 +53,39 @@ module OmniAI
53
53
  # @yieldparam delta [OmniAI::Chat::Delta]
54
54
  #
55
55
  # @param candidate [Hash]
56
- # @param index [Integer]
57
- def process_candidate!(candidate:, index:, &block)
58
- parts = candidate["content"]["parts"]
59
- return unless parts
60
-
56
+ def process_candidate!(candidate:, &block)
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
64
60
 
65
- merge_candidate!(candidate:, index:)
61
+ merge_candidate!(candidate:)
66
62
  end
67
63
 
68
64
  # @param candidate [Hash]
69
- # @param index [Integer]
70
- def merge_candidate!(candidate:, index:)
65
+ def merge_candidate!(candidate:)
66
+ index = candidate["index"]
67
+ raise candidate.inspect if index.nil?
68
+
71
69
  if @data["candidates"][index].nil?
72
70
  @data["candidates"][index] = candidate
73
71
  else
74
- merge_parts!(content: @data["candidates"][index]["content"], parts: candidate["content"]["parts"])
72
+ merge_parts!(parts: candidate["content"]["parts"], candidate: @data["candidates"][index])
75
73
  end
76
74
  end
77
75
 
78
- # @param content [Hash]
79
76
  # @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
77
+ # @param candidate [Hash]
78
+ def merge_parts!(parts:, candidate:)
79
+ parts.each { |part| merge_part!(part:, candidate:) }
80
+ end
81
+
82
+ # @param part [Hash]
83
+ # @param into [Hash]
84
+ def merge_part!(part:, candidate:)
85
+ if candidate["content"]["parts"][-1]&.key?("text") && part["text"]
86
+ candidate["content"]["parts"][-1]["text"] += part["text"]
87
+ else
88
+ candidate["content"]["parts"] << part
87
89
  end
88
90
  end
89
91
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "2.6.2"
5
+ VERSION = "2.6.3"
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.3
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