ruby-openai 1.2.0 → 1.2.1

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: a958db13dbbf94dbbeeadb2dba89e9c00eb17c40def662e85074410becbca3c5
4
- data.tar.gz: 2ec73b390ef82c2e8f5498d6abf195cf49c40a03e6b446e42f7715df0bfc27fd
3
+ metadata.gz: eb5a5c5d8b8e04ba7f6c22de243bfd1e901b69e28cdc2bb234b8bdc46c58a110
4
+ data.tar.gz: 138fa30d605a4ca116b98a3acb5b74617f27420a8110ef38605ec00f5896fbc3
5
5
  SHA512:
6
- metadata.gz: ed8d2bcedcc30defd2acb28d29be00c2c07bf80b38dd7748323c0661b90f1b09da5c21c7dd7b6014161d7fd966e9da6854d996236c032744d4f0fe70f0a4abb2
7
- data.tar.gz: a846cf9bb2888dd30a89b5796ead927615ccb46647ef803a88cfc281c08e7064857a6ee025f4611d9b7db4b0760198c7504b65257ec1584b88196ca4d27a8423
6
+ metadata.gz: 2cf09eca86b84db3f6dce82589fd5c2ccd36259308e941427a5b5b9498ebccf3797a57cd6802a91879d0b6cdc87e2383e4ae4451b0941ef74beea64e721a120a
7
+ data.tar.gz: f3f9dff8efd9ba3c4a32880940078b460c8d853e9a88b0e12fb360de1e3bcb8c3b88dda695b49de9a1c08f9947d69a421be2021a466b0693b74b252cb84348f9
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
+ ## [1.2.1] - 2021-04-11
9
+
10
+ ### Added
11
+
12
+ - Add validation of JSONL files to make it easier to debug during upload.
13
+
8
14
  ## [1.2.0] - 2021-04-08
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 (1.2.0)
4
+ ruby-openai (1.2.1)
5
5
  dotenv (~> 2.7.6)
6
6
  httparty (~> 0.18.1)
7
7
 
@@ -22,7 +22,7 @@ GEM
22
22
  multi_xml (>= 0.5.2)
23
23
  mime-types (3.3.1)
24
24
  mime-types-data (~> 3.2015)
25
- mime-types-data (3.2020.0512)
25
+ mime-types-data (3.2021.0225)
26
26
  multi_xml (0.6.0)
27
27
  parallel (1.20.1)
28
28
  parser (3.0.0.0)
@@ -18,13 +18,15 @@ module OpenAI
18
18
  end
19
19
 
20
20
  def upload(version: default_version, parameters: {})
21
+ file = validate(file: parameters[:file])
22
+
21
23
  self.class.post(
22
24
  "/#{version}/files",
23
25
  headers: {
24
26
  "Content-Type" => "application/json",
25
27
  "Authorization" => "Bearer #{@access_token}"
26
28
  },
27
- body: parameters.merge(file: File.open(parameters[:file]))
29
+ body: parameters.merge(file: file)
28
30
  )
29
31
  end
30
32
 
@@ -53,5 +55,13 @@ module OpenAI
53
55
  def default_version
54
56
  "v1".freeze
55
57
  end
58
+
59
+ def validate(file:)
60
+ File.open(file).each_line.with_index do |line, index|
61
+ JSON.parse(line)
62
+ rescue JSON::ParserError => e
63
+ raise JSON::ParserError, "#{e.message} - found on line #{index + 1} of #{file}"
64
+ end
65
+ end
56
66
  end
57
67
  end
@@ -1,5 +1,5 @@
1
1
  module Ruby
2
2
  module OpenAI
3
- VERSION = "1.2.0".freeze
3
+ VERSION = "1.2.1".freeze
4
4
  end
5
5
  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: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-08 00:00:00.000000000 Z
11
+ date: 2021-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv