omniai-google 1.8.2 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d2e6565a552f5ef5cba00a7eeea116b84c14957418e8b2ffda0e1ca30ba071
|
4
|
+
data.tar.gz: 8a09e23914a82a3716d047a7c95871e4a7483dac53d066a8d93a4dd7c60ca84e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aafa974ceeb3a5a46fc22d4ad8c1350742c86f6468f16e73a0bc689111bd8e4ae9463fb8682d19dd529fcadcce61eeabf8510e5d43231e7df315cbbea774b99f
|
7
|
+
data.tar.gz: bc6d8932b68fd2098f5773fdd8e693dfd9d479c2d2b944a823c6df8cf85c6a38c3f9e0661a8a898164af00572b728063aef03c07a6d2a5a4f64f399de75afccb
|
@@ -14,7 +14,7 @@ module OmniAI
|
|
14
14
|
|
15
15
|
{
|
16
16
|
candidates:,
|
17
|
-
usage_metadata
|
17
|
+
usageMetadata: usage_metadata,
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
@@ -23,7 +23,7 @@ module OmniAI
|
|
23
23
|
# @return [OmniAI::Chat::Payload]
|
24
24
|
def self.deserialize(data, context:)
|
25
25
|
choices = data['candidates'].map { |candidate| OmniAI::Chat::Choice.deserialize(candidate, context:) }
|
26
|
-
usage = OmniAI::Chat::Usage.deserialize(data['
|
26
|
+
usage = OmniAI::Chat::Usage.deserialize(data['usageMetadata'], context:) if data['usageMetadata']
|
27
27
|
|
28
28
|
OmniAI::Chat::Payload.new(choices:, usage:)
|
29
29
|
end
|
@@ -9,18 +9,18 @@ module OmniAI
|
|
9
9
|
# @return [Hash]
|
10
10
|
def self.serialize(usage, *)
|
11
11
|
{
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
promptTokenCount: usage.input_tokens,
|
13
|
+
candidatesTokenCount: usage.output_tokens,
|
14
|
+
totalTokenCount: usage.total_tokens,
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param data [Hash]
|
19
19
|
# @return [OmniAI::Chat::Usage]
|
20
20
|
def self.deserialize(data, *)
|
21
|
-
input_tokens = data['
|
22
|
-
output_tokens = data['
|
23
|
-
total_tokens = data['
|
21
|
+
input_tokens = data['promptTokenCount']
|
22
|
+
output_tokens = data['candidatesTokenCount']
|
23
|
+
total_tokens = data['totalTokenCount']
|
24
24
|
OmniAI::Chat::Usage.new(input_tokens:, output_tokens:, total_tokens:)
|
25
25
|
end
|
26
26
|
end
|
data/lib/omniai/google/chat.rb
CHANGED
@@ -25,6 +25,8 @@ module OmniAI
|
|
25
25
|
|
26
26
|
DEFAULT_MODEL = Model::GEMINI_PRO
|
27
27
|
|
28
|
+
JSON_MIME_TYPE = 'application/json'
|
29
|
+
|
28
30
|
# @return [Context]
|
29
31
|
CONTEXT = Context.build do |context|
|
30
32
|
context.serializers[:text] = TextSerializer.method(:serialize)
|
@@ -98,9 +100,20 @@ module OmniAI
|
|
98
100
|
|
99
101
|
# @return [Hash]
|
100
102
|
def generation_config
|
101
|
-
|
103
|
+
response_mime_type = (JSON_MIME_TYPE if json_mime_type?)
|
104
|
+
|
105
|
+
return unless @temperature || response_mime_type
|
106
|
+
|
107
|
+
{
|
108
|
+
temperature: @temperature,
|
109
|
+
responseMimeType: response_mime_type,
|
110
|
+
}.compact
|
111
|
+
end
|
102
112
|
|
103
|
-
|
113
|
+
# Checks if setting a jsonMimeType is supported
|
114
|
+
# @return [Boolean]
|
115
|
+
def json_mime_type?
|
116
|
+
@client.version == OmniAI::Google::Config::Version::BETA && @format.eql?(:json)
|
104
117
|
end
|
105
118
|
|
106
119
|
# @return [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniai-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sylvestre
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|