omniai 1.6.5 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/omniai/chat/content.rb +8 -0
- data/lib/omniai/chat/media.rb +5 -0
- data/lib/omniai/chat/message.rb +8 -0
- data/lib/omniai/chat/prompt.rb +5 -0
- data/lib/omniai/chat/text.rb +5 -0
- data/lib/omniai/chat/url.rb +5 -0
- data/lib/omniai/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc92ec17e5ca87590eca2181453b6a3e54c2d15bb6dda0c80c604a443e59660
|
4
|
+
data.tar.gz: e4eb4ad22437711fbac2c538edc644861107985662f24a236b317d229802f7b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b7b695353ec0899b786ee057beaedcd8ab21ba15efca6f3a21c4e22730dc73b7676fbdfece11f624a1dce77638ad2d7cc4a6ff054c2180edb8f423b20ca6ee
|
7
|
+
data.tar.gz: 9c7ab97db7e4d8085774c9fd76803b8abfe53905b6d9b6d141caed311d019347d3f0e880e957597b529de8e479d1b69415213e82ca1daba34bf00d7049eddbae
|
data/lib/omniai/chat/content.rb
CHANGED
@@ -4,6 +4,14 @@ module OmniAI
|
|
4
4
|
class Chat
|
5
5
|
# A placeholder for parts of a message. Any subclass must implement the serializable interface.
|
6
6
|
class Content
|
7
|
+
# @return [String]
|
8
|
+
def self.summarize(content)
|
9
|
+
return content.map { |entry| summarize(entry) }.join("\n\n") if content.is_a?(Array)
|
10
|
+
return content if content.is_a?(String)
|
11
|
+
|
12
|
+
content.summarize
|
13
|
+
end
|
14
|
+
|
7
15
|
# @param context [Context] optional
|
8
16
|
#
|
9
17
|
# @return [String]
|
data/lib/omniai/chat/media.rb
CHANGED
data/lib/omniai/chat/message.rb
CHANGED
@@ -31,6 +31,14 @@ module OmniAI
|
|
31
31
|
"#<#{self.class} role=#{@role.inspect} content=#{@content.inspect}>"
|
32
32
|
end
|
33
33
|
|
34
|
+
# @return [String]
|
35
|
+
def summarize
|
36
|
+
<<~TEXT
|
37
|
+
#{@role}
|
38
|
+
#{Content.summarize(@content)}
|
39
|
+
TEXT
|
40
|
+
end
|
41
|
+
|
34
42
|
# Usage:
|
35
43
|
#
|
36
44
|
# Message.deserialize({ role: :user, content: 'Hello!' }) # => #<Message ...>
|
data/lib/omniai/chat/prompt.rb
CHANGED
@@ -62,6 +62,11 @@ module OmniAI
|
|
62
62
|
"#<#{self.class.name} messages=#{@messages.inspect}>"
|
63
63
|
end
|
64
64
|
|
65
|
+
# @return [String]
|
66
|
+
def summarize
|
67
|
+
@messages.map(&:summarize).join("\n\n")
|
68
|
+
end
|
69
|
+
|
65
70
|
# Usage:
|
66
71
|
#
|
67
72
|
# prompt.serialize # => [{ content: "What is the capital of Canada?", role: :user }]
|
data/lib/omniai/chat/text.rb
CHANGED
data/lib/omniai/chat/url.rb
CHANGED
data/lib/omniai/version.rb
CHANGED