omniai 1.0.4 → 1.0.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/completion.rb +1 -9
- data/lib/omniai/chat/usage.rb +14 -0
- data/lib/omniai/chat.rb +1 -1
- 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: 172ad18b8fbe97f2e8d23bf8624efea92591910f6d05eed5295789555f60e6d7
|
4
|
+
data.tar.gz: dc415cd3f63f293bc2d64cff39c3ee3c094f734d7a0fb330a1b25adf772f7016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dc885877d697bf3c2053e8facbdc1a7329a8b3ae0804753e0e1daefcc9f37bcc7dd19de11c748fccdf4cc9be032cbbb1128558a8d437a125ab41ca44402d7ce
|
7
|
+
data.tar.gz: cb96cde1ff5203f08646217bfae1c0032a25f492cbb6b1565f34ea9a5a905c0626b6bfab5e651793cd853b34eaf0a95130ad8a41e2f8a77429c9faf0feb58cc5
|
@@ -35,15 +35,7 @@ module OmniAI
|
|
35
35
|
def usage
|
36
36
|
return unless @data['usage']
|
37
37
|
|
38
|
-
|
39
|
-
output_tokens = @data['usage']['output_tokens'] || @data['usage']['completion_tokens']
|
40
|
-
total_tokens = @data['usage']['total_tokens'] || (input_tokens + output_tokens)
|
41
|
-
|
42
|
-
@usage ||= Usage.new(
|
43
|
-
input_tokens:,
|
44
|
-
output_tokens:,
|
45
|
-
total_tokens:
|
46
|
-
)
|
38
|
+
@usage ||= Usage.for(data: @data['usage'])
|
47
39
|
end
|
48
40
|
|
49
41
|
# @return [Array<OmniAI::Chat::Choice>]
|
data/lib/omniai/chat/usage.rb
CHANGED
@@ -6,6 +6,20 @@ module OmniAI
|
|
6
6
|
class Usage
|
7
7
|
attr_accessor :input_tokens, :output_tokens, :total_tokens
|
8
8
|
|
9
|
+
# @param data [Hash]
|
10
|
+
# @return [OmniAI::Chat::Usage]
|
11
|
+
def self.for(data:)
|
12
|
+
input_tokens = data['input_tokens'] || data['prompt_tokens']
|
13
|
+
output_tokens = data['output_tokens'] || data['completion_tokens']
|
14
|
+
total_tokens = data['total_tokens'] || (input_tokens + output_tokens)
|
15
|
+
|
16
|
+
new(
|
17
|
+
input_tokens:,
|
18
|
+
output_tokens:,
|
19
|
+
total_tokens:
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
9
23
|
# @param input_tokens [Integer]
|
10
24
|
# @param output_tokens [Integer]
|
11
25
|
# @param total_tokens [Integer]
|
data/lib/omniai/chat.rb
CHANGED
data/lib/omniai/version.rb
CHANGED