omniai 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/omniai/client.rb +1 -1
- data/lib/omniai/transcribe/transcription.rb +8 -10
- data/lib/omniai/transcribe.rb +2 -2
- 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: facf65abfc03bc2fedc0572bbdebe5baca776da08b3eba9f4bde4b082bf037a7
|
4
|
+
data.tar.gz: 265613b4ab126f34d68d079241d8f4d2eae96c3e5c4f083aa9ff2761003a5678
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a689d6591eabb97d47fea58a73c2b7fcc133c62aea51180bffe846976086b3819099708757cae85e20c5db3e38964b9dc7c0dc1cbc9fa8b076bc322a56dec4cb
|
7
|
+
data.tar.gz: bc80184100a4ca2888fb8a0ee3b93ac8d9d301e875e541e692b9a08564eb85fa59d58fcd88e35c4d72142624621ef73174b276c8da95ae53bfcabd1fc1ae776d
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ messages = [
|
|
80
80
|
'What is the capital of Canada?'
|
81
81
|
]
|
82
82
|
completion = client.chat(messages, model: '...', temperature: 0.7, format: :json)
|
83
|
-
completion.choice.message.content
|
83
|
+
completion.choice.message.content # '...'
|
84
84
|
```
|
85
85
|
|
86
86
|
#### w/ a Collection of Files
|
@@ -100,7 +100,7 @@ message = {
|
|
100
100
|
}
|
101
101
|
|
102
102
|
completion = client.chat(message)
|
103
|
-
completion.choice.message.content
|
103
|
+
completion.choice.message.content # '...'
|
104
104
|
```
|
105
105
|
|
106
106
|
#### Streaming
|
@@ -117,5 +117,6 @@ client.chat('Tell me a joke.', stream:)
|
|
117
117
|
Clients that support chat (e.g. OpenAI w/ "Whisper", etc) convert recordings to text via the following calls:
|
118
118
|
|
119
119
|
```ruby
|
120
|
-
client.transcribe(file.path)
|
120
|
+
transcription = client.transcribe(file.path)
|
121
|
+
transcription.text # '...'
|
121
122
|
```
|
data/lib/omniai/client.rb
CHANGED
@@ -56,7 +56,7 @@ module OmniAI
|
|
56
56
|
# @param format [Symbol] :text, :srt, :vtt, or :json (default)
|
57
57
|
#
|
58
58
|
# @return text [OmniAI::Transcribe::Transcription]
|
59
|
-
def transcribe(file, model:, language: nil, prompt: nil, temperature: nil, format:
|
59
|
+
def transcribe(file, model:, language: nil, prompt: nil, temperature: nil, format: nil)
|
60
60
|
raise NotImplementedError, "#{self.class.name}#speak undefined"
|
61
61
|
end
|
62
62
|
end
|
@@ -4,22 +4,20 @@ module OmniAI
|
|
4
4
|
class Transcribe
|
5
5
|
# A transcription returned by the API.
|
6
6
|
class Transcription
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :text, :model, :format
|
8
8
|
|
9
|
-
# @param
|
10
|
-
|
11
|
-
|
9
|
+
# @param text [String]
|
10
|
+
# @param model [String]
|
11
|
+
# @param format [String]
|
12
|
+
def initialize(text:, model:, format:)
|
13
|
+
@text = text
|
14
|
+
@model = model
|
12
15
|
@format = format
|
13
16
|
end
|
14
17
|
|
15
|
-
# @return [String]
|
16
|
-
def text
|
17
|
-
@data['text']
|
18
|
-
end
|
19
|
-
|
20
18
|
# @return [String]
|
21
19
|
def inspect
|
22
|
-
"#<#{self.class} text=#{text.inspect}
|
20
|
+
"#<#{self.class} text=#{text.inspect}>"
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
data/lib/omniai/transcribe.rb
CHANGED
@@ -119,8 +119,8 @@ module OmniAI
|
|
119
119
|
response = request!
|
120
120
|
raise HTTPError, response.flush unless response.status.ok?
|
121
121
|
|
122
|
-
|
123
|
-
Transcription.new(
|
122
|
+
text = @format.nil? || @format.eql?(Format::JSON) ? response.parse['text'] : String(response.body)
|
123
|
+
Transcription.new(text:, model: @model, format: @format)
|
124
124
|
end
|
125
125
|
|
126
126
|
protected
|
data/lib/omniai/version.rb
CHANGED