omniai 1.4.0 → 1.4.2
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.rb +7 -5
- data/lib/omniai/cli/chat_handler.rb +1 -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: df4f1096ec0d74c8ab26e5cfc8db4902009d1bb398ed9913e801b31203d1ae66
|
4
|
+
data.tar.gz: 9cff5f3ecdc6a540bbbd3ca6501dbd07585a1f9dfe8127a09ee6421a51f79c2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db82f7cf3e8b43f55080c1ae1af2f6f9767dec7870bf23e2424eee8a272671b565f279829d9768fbb447eec8821fcd7da22058da8a4016b4de271a389a115c1c
|
7
|
+
data.tar.gz: 84362d233dbafa2dd6403b3d65056c7b836eb0b2ce420f4395c86188887f12ba7cb59caead7cfbc44d80bfa03ad2ef342b62f8235ace58afd0284e8e25b5c243
|
data/lib/omniai/chat.rb
CHANGED
@@ -89,7 +89,7 @@ module OmniAI
|
|
89
89
|
|
90
90
|
# @param response [OmniAI::Chat::Completion]
|
91
91
|
def complete!(response:)
|
92
|
-
Completion.new(data: response.parse)
|
92
|
+
self.class::Completion.new(data: response.parse)
|
93
93
|
end
|
94
94
|
|
95
95
|
# @param response [HTTP::Response]
|
@@ -97,21 +97,23 @@ module OmniAI
|
|
97
97
|
def stream!(response:)
|
98
98
|
raise Error, "#{self.class.name}#stream! unstreamable" unless @stream
|
99
99
|
|
100
|
-
Stream.new(response:).stream! do |chunk|
|
100
|
+
self.class::Stream.new(response:).stream! do |chunk|
|
101
101
|
case @stream
|
102
|
-
when IO
|
102
|
+
when IO
|
103
|
+
@stream << chunk.choice.delta.content
|
104
|
+
@stream.flush
|
103
105
|
else @stream.call(chunk)
|
104
106
|
end
|
105
107
|
end
|
106
108
|
|
107
|
-
@stream.
|
109
|
+
@stream.puts if @stream.is_a?(IO)
|
108
110
|
end
|
109
111
|
|
110
112
|
# @return [Array<Hash>]
|
111
113
|
def messages
|
112
114
|
arrayify(@messages).map do |content|
|
113
115
|
case content
|
114
|
-
when String then { role:
|
116
|
+
when String then { role: Role::USER, content: }
|
115
117
|
when Hash then content
|
116
118
|
else raise Error, "Unsupported content=#{content.inspect}"
|
117
119
|
end
|
data/lib/omniai/version.rb
CHANGED