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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b3d66712c9a2fd460abf00c29b056b87ff8cdd08c8b38d69ece0755d8c76578
4
- data.tar.gz: f0fdf7b20e3f3cc3c4e2bee6d21b68bd917d9267c9f1297dec91f2f8bccc71e9
3
+ metadata.gz: df4f1096ec0d74c8ab26e5cfc8db4902009d1bb398ed9913e801b31203d1ae66
4
+ data.tar.gz: 9cff5f3ecdc6a540bbbd3ca6501dbd07585a1f9dfe8127a09ee6421a51f79c2f
5
5
  SHA512:
6
- metadata.gz: 98c6c3380181aaf7ad858968b998adab49f8cd200d94755ff6cf79423378dd401c4c538147aeb416b023c47fe7f1806a8742a9486429e90bcc487eb8944cba52
7
- data.tar.gz: f251bb7436e9536275a285508f63964693a067378f55a72b3cf01fb9cb801f55ef96fd8a64c9b4e5790c6c400ee6adcee64f6dc5dc413e92b42d5f869afce45f
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 then @stream << chunk
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.flush if @stream.is_a?(IO)
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: OmniAI::Chat::Role::USER, content: }
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
@@ -21,6 +21,7 @@ module OmniAI
21
21
 
22
22
  loop do
23
23
  @stdout.print('# ')
24
+ @stdout.flush
24
25
  prompt = @stdin.gets&.chomp
25
26
 
26
27
  break if prompt.nil? || prompt.match?(/\A(exit|quit)\z/i)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = '1.4.0'
4
+ VERSION = '1.4.2'
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.4.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre