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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d9011a55d57b9dd0923f4d7edd70001c3f9ee5b8211e98d59f9d001687af044
4
- data.tar.gz: 204e2f0ec0a44f65cba11cb49819e7f5c4e933a92d6bc1b48c4d630dee180ecd
3
+ metadata.gz: 0bc92ec17e5ca87590eca2181453b6a3e54c2d15bb6dda0c80c604a443e59660
4
+ data.tar.gz: e4eb4ad22437711fbac2c538edc644861107985662f24a236b317d229802f7b7
5
5
  SHA512:
6
- metadata.gz: 724827923255adade8f19bd9b43806d1af116d9c4dd6105713f0ba0b16c3d6cd5e5cbafdc2d324912a669523e565ba1ce190ed26035cdc1645a4505f2c6991a9
7
- data.tar.gz: 5944ef3f285359662fc6105fd2a3aba7a44a279c5062ec0c1bdf194ddecd6842a33b1cd9b20cd4f5b36641b67cd8bc046e677260170d06dd2d5e3b37db37f356
6
+ metadata.gz: 75b7b695353ec0899b786ee057beaedcd8ab21ba15efca6f3a21c4e22730dc73b7676fbdfece11f624a1dce77638ad2d7cc4a6ff054c2180edb8f423b20ca6ee
7
+ data.tar.gz: 9c7ab97db7e4d8085774c9fd76803b8abfe53905b6d9b6d141caed311d019347d3f0e880e957597b529de8e479d1b69415213e82ca1daba34bf00d7049eddbae
@@ -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]
@@ -15,6 +15,11 @@ module OmniAI
15
15
  @type = type
16
16
  end
17
17
 
18
+ # @return [String]
19
+ def summarize
20
+ "[#{filename}]"
21
+ end
22
+
18
23
  # @return [Boolean]
19
24
  def text?
20
25
  @type.match?(%r{^text/})
@@ -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 ...>
@@ -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 }]
@@ -18,6 +18,11 @@ module OmniAI
18
18
  "#<#{self.class} text=#{@text.inspect}>"
19
19
  end
20
20
 
21
+ # @return [String]
22
+ def summarize
23
+ @text
24
+ end
25
+
21
26
  # @param data [Hash]
22
27
  def self.deserialize(data, context: nil)
23
28
  deserialize = context&.deserializers&.[](:text)
@@ -16,6 +16,11 @@ module OmniAI
16
16
  @uri = uri
17
17
  end
18
18
 
19
+ # @return [String]
20
+ def summarize
21
+ "[#{filename}]"
22
+ end
23
+
19
24
  # @return [String]
20
25
  def inspect
21
26
  "#<#{self.class} uri=#{@uri.inspect}>"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = '1.6.5'
4
+ VERSION = '1.6.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.5
4
+ version: 1.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre