ruby-openai 3.4.0 → 3.5.0

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: f3d2b8f98be44b7f33fce40f271bccc3dc1c72237df7ad64baed43f4ea79fb51
4
- data.tar.gz: f19cc5e7155b47e6f7ccb7c5642679e5d8f7a6600e6d4f9e592ebc16313b74f0
3
+ metadata.gz: dfe7d331fc5d5a16f74089b9395232cd1abf0d6b05bd78be4db91e1b65d71a4c
4
+ data.tar.gz: 610d363ebf1d6a53f015aeaf20cd551c1020731fd423ba4074ff3eb044239fa1
5
5
  SHA512:
6
- metadata.gz: 8f2c05fae48718593ea7990c480f6108844a698a943c8db2e3e01f3e31e95ede1ca2a5bd0dec5364a9b1730698c3802e24eecec585d20e59b03e1a421c8a3c4e
7
- data.tar.gz: 303d6df6cea50a4f9ac50f8cab7329e585e201aeb2532709b161b830896cc1e733e0c48dfa6ebff22d13d930c3a0ff76425b8e0294c7e175a1bc4e07b84710a2
6
+ metadata.gz: '08b25f159fc149ccd09034da891cf5e77c999964a6d06ea6d916c62ad3e4a9ba2b1aa73757b617c0152ca1760f386514da081e978a6ca9963706f3f385814b78'
7
+ data.tar.gz: 144bd11f3791fa818193eaab7d8eeb6b04c33f4b99342ca573acea76f0ffcef4604033daaea54b2ae43411abf84e572db97304f7195c08116a55fedd1524d2aa
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.5.0] - 2023-03-02
9
+
10
+ ### Added
11
+
12
+ - Add Client#transcribe and Client translate endpoints - Whisper over the wire! Thanks to [@Clemalfroy](https://github.com/Clemalfroy)
13
+
8
14
  ## [3.4.0] - 2023-03-01
9
15
 
10
16
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (3.4.0)
4
+ ruby-openai (3.5.0)
5
5
  httparty (>= 0.18.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Use the [OpenAI API](https://openai.com/blog/openai-api/) with Ruby! 🤖❤️
9
9
 
10
- Generate text with ChatGPT, create images with DALL·E, or write code with Codex...
10
+ Generate text with ChatGPT, transcribe or translate audio with Whisper, create images with DALL·E, or write code with Codex...
11
11
 
12
12
  ## Installation
13
13
 
@@ -267,6 +267,38 @@ Pass a string to check if it violates OpenAI's Content Policy:
267
267
  => 5.505014632944949e-05
268
268
  ```
269
269
 
270
+ ### Whisper
271
+
272
+ Whisper is a speech to text model that can be used to generate text based on an audio files:
273
+
274
+ #### Translate
275
+
276
+ The translations API takes as input the audio file in any of the supported languages and transcribes the audio into English.
277
+
278
+ ```ruby
279
+ response = client.translate(
280
+ parameters: {
281
+ model: "whisper-1",
282
+ file: File.open('path_to_file'),
283
+ })
284
+ puts response.parsed_body['text']
285
+ => "Translation of the text"
286
+ ```
287
+
288
+ #### Transcribe
289
+
290
+ The transcriptions API takes as input the audio file you want to transcribe and returns the text in the desired output file format.
291
+
292
+ ```ruby
293
+ response = client.transcribe(
294
+ parameters: {
295
+ model: "whisper-1",
296
+ file: File.open('path_to_file'),
297
+ })
298
+ puts response.parsed_body['text']
299
+ => "Transcription of the text"
300
+ ```
301
+
270
302
  ## Development
271
303
 
272
304
  After checking out the repo, run `bin/setup` to install dependencies. You can run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/openai/client.rb CHANGED
@@ -43,6 +43,14 @@ module OpenAI
43
43
  OpenAI::Client.json_post(path: "/moderations", parameters: parameters)
44
44
  end
45
45
 
46
+ def transcribe(parameters: {})
47
+ OpenAI::Client.multipart_post(path: "/audio/transcriptions", parameters: parameters)
48
+ end
49
+
50
+ def translate(parameters: {})
51
+ OpenAI::Client.multipart_post(path: "/audio/translations", parameters: parameters)
52
+ end
53
+
46
54
  def self.get(path:)
47
55
  HTTParty.get(
48
56
  uri(path: path),
@@ -1,3 +1,3 @@
1
1
  module OpenAI
2
- VERSION = "3.4.0".freeze
2
+ VERSION = "3.5.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-01 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty