omniai-google 2.3.1 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 904b9944d8f92b2dd343568a5185c0adf8151d84e57698a85542187f88e5b469
4
- data.tar.gz: fbcac301f2f80c16b3ad2d1c3e1d812ea52c9ea7f5ba5ca0ba22c2f2e7b5a594
3
+ metadata.gz: 3f36d76cb11dd6560ced4cdc09989f40fe0c0461b27c67caf17a7620990d888d
4
+ data.tar.gz: c08242def01cf99eba317b78310b5cb9f7c88346893d1c929a23d89fb4b32f6d
5
5
  SHA512:
6
- metadata.gz: ac86234994438b8197e88ce447479aab12aaddef77e2d50e04c58560af2d83c0f18af34512de2e19524ae383203194dd42fb4264510bd01aed26a60bc8e77cf8
7
- data.tar.gz: 9a212401e92a2ab193fab62db2b01da7f7012c42ba4e1f95a5446b921a57946c816347248138f98c0a8f387cbe2fcef359fc0a8189363388aff0c2ffd76aa2d8
6
+ metadata.gz: a3c01b3dd839b845944621e328c091d132ef104a01d7d4c1c59b6277211a05f7a68156d971ce9d632f08270b0b161bbc54d18ea4430902539c1c880c897bf8e6
7
+ data.tar.gz: 353201b366071ac3d4eac2b96c5c24acb3d5a73b09f04e13e2642e96f8eaec9d4ed8c67f50758dfb117221ea3d54d6478a9d4c7eb4f2360711b84598c53d3db2
@@ -28,6 +28,12 @@ module OmniAI
28
28
  data["predictions"].map { |prediction| prediction["embeddings"]["values"] }
29
29
  end
30
30
 
31
+ VERTEX_USAGE_DESERIALIZER = proc do |data, *|
32
+ tokens = data["predictions"].map { |prediction| prediction["embeddings"]["statistics"]["token_count"] }.sum
33
+
34
+ Usage.new(prompt_tokens: tokens, total_tokens: tokens)
35
+ end
36
+
31
37
  # @return [Context]
32
38
  DEFAULT_CONTEXT = Context.build do |context|
33
39
  context.deserializers[:embeddings] = DEFAULT_EMBEDDINGS_DESERIALIZER
@@ -36,6 +42,7 @@ module OmniAI
36
42
  # @return [Context]
37
43
  VERTEX_CONTEXT = Context.build do |context|
38
44
  context.deserializers[:embeddings] = VERTEX_EMBEDDINGS_DESERIALIZER
45
+ context.deserializers[:usage] = VERTEX_USAGE_DESERIALIZER
39
46
  end
40
47
 
41
48
  protected
@@ -50,12 +57,6 @@ module OmniAI
50
57
  vertex? ? VERTEX_CONTEXT : DEFAULT_CONTEXT
51
58
  end
52
59
 
53
- # @param response [HTTP::Response]
54
- # @return [Response]
55
- def parse!(response:)
56
- Response.new(data: response.parse, context:)
57
- end
58
-
59
60
  # @return [Array[Hash]]
60
61
  def instances
61
62
  arrayify(@input).map { |content| { content: } }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "2.3.1"
5
+ VERSION = "2.3.2"
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: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre