omniai-google 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/omniai/google/chat.rb +41 -3
- data/lib/omniai/google/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a64561af96984da60b42099f415cdb90d738757f6108af74b035e1a2e5d34ce
|
4
|
+
data.tar.gz: 837b82e0ec5e45b3300858591f1a60ffd2783d16d0c5b1ad8280dd9585d944de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abb56f1dc0d7ddb3efcd79ffcd132c45c85e3ca5fc43f72bfc8fd94b535f0bf76bb32946e1dca7e55cb180bc8d7492ecc116f16cb7fd8b454825f38395c92f22
|
7
|
+
data.tar.gz: 9baa74ce37c0a0c7a20b9f36e15d205a89df9556042d17e999f622c86e505f1f5ace1b143091f346120045102e62a1b4bf34d522d4c90b179aec8773f34b8c78
|
data/lib/omniai/google/chat.rb
CHANGED
@@ -23,6 +23,46 @@ module OmniAI
|
|
23
23
|
GEMINI_FLASH = GEMINI_1_5_FLASH
|
24
24
|
end
|
25
25
|
|
26
|
+
TEXT_SERIALIZER = lambda do |content, *|
|
27
|
+
{ text: content.text }
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param [Message]
|
31
|
+
# @return [Hash]
|
32
|
+
# @example
|
33
|
+
# message = Message.new(...)
|
34
|
+
# MESSAGE_SERIALIZER.call(message)
|
35
|
+
MESSAGE_SERIALIZER = lambda do |message, context:|
|
36
|
+
parts = message.content.is_a?(String) ? [Text.new(message.content)] : message.content
|
37
|
+
|
38
|
+
{
|
39
|
+
role: message.role,
|
40
|
+
parts: parts.map { |part| part.serialize(context:) },
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param [Media]
|
45
|
+
# @return [Hash]
|
46
|
+
# @example
|
47
|
+
# media = Media.new(...)
|
48
|
+
# MEDIA_SERIALIZER.call(media)
|
49
|
+
MEDIA_SERIALIZER = lambda do |media, *|
|
50
|
+
{
|
51
|
+
inlineData: {
|
52
|
+
mimeType: media.type,
|
53
|
+
data: media.data,
|
54
|
+
},
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Context]
|
59
|
+
CONTEXT = Context.build do |context|
|
60
|
+
context.serializers[:message] = MESSAGE_SERIALIZER
|
61
|
+
context.serializers[:text] = TEXT_SERIALIZER
|
62
|
+
context.serializers[:file] = MEDIA_SERIALIZER
|
63
|
+
context.serializers[:url] = MEDIA_SERIALIZER
|
64
|
+
end
|
65
|
+
|
26
66
|
protected
|
27
67
|
|
28
68
|
# @return [HTTP::Response]
|
@@ -67,9 +107,7 @@ module OmniAI
|
|
67
107
|
#
|
68
108
|
# @return [Array<Hash>]
|
69
109
|
def contents
|
70
|
-
|
71
|
-
{ role: message[:role], parts: [{ text: message[:content] }] }
|
72
|
-
end
|
110
|
+
@prompt.serialize(context: CONTEXT)
|
73
111
|
end
|
74
112
|
|
75
113
|
# @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.
|
4
|
+
version: 1.6.0
|
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-07-
|
11
|
+
date: 2024-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|