omniai 1.2.2 → 1.2.3
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/chunk.rb +2 -2
- data/lib/omniai/chat/completion.rb +3 -3
- data/lib/omniai/chat/delta_choice.rb +26 -0
- data/lib/omniai/chat/message_choice.rb +26 -0
- data/lib/omniai/version.rb +1 -1
- metadata +4 -3
- data/lib/omniai/chat/choice.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2820bc43050fa4484a25e1a967b3d12ac71a3d5659e735f5904040990acf47b8
|
4
|
+
data.tar.gz: 8894714bf0c8055ca173176d8eeb078ce6f93a0481c19df3fd2dae911fbb264d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2658cb0bf197315f3679225a214871ffdbf670cabb65f3126b4a1e7ccd40b6f38810e9fea828b71eb1c9fae819f94e824dedc65ed69cc7531e496d9ae027896
|
7
|
+
data.tar.gz: 3f525900c8c319076549235713418e7cc7e87167151668900e3073530004b9bb1561469a9b02914dfac63eff4f35b67fbf9ca66171b5471cf24c665e280f3d23
|
data/lib/omniai/chat/chunk.rb
CHANGED
@@ -31,9 +31,9 @@ module OmniAI
|
|
31
31
|
@data['model']
|
32
32
|
end
|
33
33
|
|
34
|
-
# @return [Array<OmniAI::Chat::
|
34
|
+
# @return [Array<OmniAI::Chat::DeltaChoice>]
|
35
35
|
def choices
|
36
|
-
@choices ||= @data['choices'].map { |data|
|
36
|
+
@choices ||= @data['choices'].map { |data| DeltaChoice.for(data:) }
|
37
37
|
end
|
38
38
|
|
39
39
|
# @param index [Integer]
|
@@ -38,13 +38,13 @@ module OmniAI
|
|
38
38
|
@usage ||= Usage.for(data: @data['usage'])
|
39
39
|
end
|
40
40
|
|
41
|
-
# @return [Array<OmniAI::Chat::
|
41
|
+
# @return [Array<OmniAI::Chat::MessageChoice>]
|
42
42
|
def choices
|
43
|
-
@choices ||= @data['choices'].map { |data|
|
43
|
+
@choices ||= @data['choices'].map { |data| MessageChoice.for(data:) }
|
44
44
|
end
|
45
45
|
|
46
46
|
# @param index [Integer] optional - default is 0
|
47
|
-
# @return [OmniAI::Chat::
|
47
|
+
# @return [OmniAI::Chat::MessageChoice]
|
48
48
|
def choice(index: 0)
|
49
49
|
choices[index]
|
50
50
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OmniAI
|
4
|
+
class Chat
|
5
|
+
# A delta choice returned by the API.
|
6
|
+
class DeltaChoice
|
7
|
+
attr_accessor :index, :delta
|
8
|
+
|
9
|
+
# @param data [Hash]
|
10
|
+
# @return [OmniAI::Chat::Choice]
|
11
|
+
def self.for(data:)
|
12
|
+
index = data['index']
|
13
|
+
delta = Delta.for(data: data['delta'])
|
14
|
+
|
15
|
+
new(index:, delta:)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param index [Integer]
|
19
|
+
# @param delta [Delta]
|
20
|
+
def initialize(index:, delta:)
|
21
|
+
@index = index
|
22
|
+
@delta = delta
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OmniAI
|
4
|
+
class Chat
|
5
|
+
# A choice returned by the API.
|
6
|
+
class MessageChoice
|
7
|
+
attr_accessor :index, :message
|
8
|
+
|
9
|
+
# @param data [Hash]
|
10
|
+
# @return [OmniAI::Chat::Choice]
|
11
|
+
def self.for(data:)
|
12
|
+
index = data['index']
|
13
|
+
message = Message.for(data: data['message'])
|
14
|
+
|
15
|
+
new(index:, message:)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param index [Integer]
|
19
|
+
# @param message [OmniAI::Chat::Message]
|
20
|
+
def initialize(index:, message:)
|
21
|
+
@index = index
|
22
|
+
@message = message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/omniai/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
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-06-
|
11
|
+
date: 2024-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- bin/setup
|
67
67
|
- lib/omniai.rb
|
68
68
|
- lib/omniai/chat.rb
|
69
|
-
- lib/omniai/chat/choice.rb
|
70
69
|
- lib/omniai/chat/chunk.rb
|
71
70
|
- lib/omniai/chat/completion.rb
|
72
71
|
- lib/omniai/chat/content/file.rb
|
@@ -74,7 +73,9 @@ files:
|
|
74
73
|
- lib/omniai/chat/content/text.rb
|
75
74
|
- lib/omniai/chat/content/url.rb
|
76
75
|
- lib/omniai/chat/delta.rb
|
76
|
+
- lib/omniai/chat/delta_choice.rb
|
77
77
|
- lib/omniai/chat/message.rb
|
78
|
+
- lib/omniai/chat/message_choice.rb
|
78
79
|
- lib/omniai/chat/stream.rb
|
79
80
|
- lib/omniai/chat/usage.rb
|
80
81
|
- lib/omniai/client.rb
|
data/lib/omniai/chat/choice.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OmniAI
|
4
|
-
class Chat
|
5
|
-
# A choice returned by the API.
|
6
|
-
class Choice
|
7
|
-
attr_accessor :index, :delta, :message
|
8
|
-
|
9
|
-
# @param data [Hash]
|
10
|
-
# @return [OmniAI::Chat::Choice]
|
11
|
-
def self.for(data:)
|
12
|
-
index = data['index']
|
13
|
-
delta = Delta.for(data: data['delta']) if data['delta']
|
14
|
-
message = Message.for(data: data['message']) if data['message']
|
15
|
-
|
16
|
-
new(index:, delta:, message:)
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param index [Integer]
|
20
|
-
# @param delta [OmniAI::Chat::Delta] optional
|
21
|
-
# @param message [OmniAI::Chat::Message] optional
|
22
|
-
def initialize(index:, delta:, message:)
|
23
|
-
@index = index
|
24
|
-
@delta = delta
|
25
|
-
@message = message
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|