omniai 1.0.4 → 1.0.5
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/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: dddfc4d4ac08e936e1b2443e37ff93b4256428579aa1280b6ede769a01365f04
|
4
|
+
data.tar.gz: 235c5f109e0e3526d2abfa2cf7d6c3a3d1e00749da70beaf884a2a1bcb9ba8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae66992c4f0a399ecbe795a39901e73caea1554861e23894fd005daab9b26e23cd6a110cca9cde9b9c9ce73af174037626b3505074bb4bd23477677a286b3ef
|
7
|
+
data.tar.gz: 5f604bcdc4ca4b748e523eff6cb4b383cd9211188673c768d2295a7f9e43c1f043ac9c8b14ff86b9dabb85a99b50a005ce40b920cdbcdf19f9f1ef05b4f33ca5
|
@@ -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/version.rb
CHANGED