gpt-function 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdeb301d12f6247b694accec4654d4d65bab0ca071cb4bf7ae73631bf540bc56
4
- data.tar.gz: dd5cb067931ac6411a545641b96f40ef81d929bd1d388cfe93808d5c76b6e2ec
3
+ metadata.gz: 4382f4c9861d57510b154ab5179854eee8fad548dd849f3b283d870f736e599e
4
+ data.tar.gz: 498b2499d3d6ecdb03847a6b5c15f9d2f99c231d59655f3cf8a602898d525102
5
5
  SHA512:
6
- metadata.gz: 665474c59064f7ae3401b0fea4e8ca562cfa2e91ff285523bbcdff9b367480f2d137b619b15d30c396df92a07c506bd73ed121bd8c54292d301785957486aa37
7
- data.tar.gz: f1072362a33e579c4f52eda7b8abbadc3970807eaca91c5aa39010ca130c3e935a9ee5194b207a8c4de8b11c2079a68bbc3675d63ddeb74d811f9c2de7c33aac
6
+ metadata.gz: 6ba7a96725e99edb9d87f9467011357fbd8e8e40dc62f902420b480334af7b432bf071e1b63df7ce5e0645611bcb6355caff08d275e9905a21a638ec6033cc06
7
+ data.tar.gz: 680facff33d5f9737fb4dbc6cfc10a08e35f221245cb1e90c82a3e280c4ed32a0f1129d52561e471ca210f984a4c973b671aec01445d7776fdb5815e1d25339b
@@ -28,8 +28,7 @@ class GptFunction
28
28
  attr_reader :request_counts_completed
29
29
  attr_reader :request_counts_failed
30
30
 
31
- attr_reader :metadata_customer_id
32
- attr_reader :metadata_batch_description
31
+ attr_reader :metadata
33
32
 
34
33
  def initialize(hash)
35
34
  @id = hash["id"]
@@ -55,8 +54,7 @@ class GptFunction
55
54
  @request_counts_completed = hash.dig("request_counts", "completed")
56
55
  @request_counts_failed = hash.dig("request_counts", "failed")
57
56
 
58
- @metadata_customer_id = hash.dig("metadata", "customer_id")
59
- @metadata_batch_description = hash.dig("metadata", "batch_description")
57
+ @metadata = hash.dig("metadata")
60
58
  end
61
59
 
62
60
  def to_hash
@@ -82,8 +80,7 @@ class GptFunction
82
80
  request_counts_total: request_counts_total,
83
81
  request_counts_completed: request_counts_completed,
84
82
  request_counts_failed: request_counts_failed,
85
- metadata_customer_id: metadata_customer_id,
86
- metadata_batch_description: metadata_batch_description,
83
+ metadata: metadata
87
84
  }
88
85
  end
89
86
 
@@ -189,7 +186,7 @@ class GptFunction
189
186
  end
190
187
  end
191
188
 
192
- def create(requests)
189
+ def create(requests, metadata: nil)
193
190
  requests = requests.each_with_index.map do |request, index|
194
191
  {
195
192
  custom_id: "request-#{index + 1}",
@@ -206,11 +203,13 @@ class GptFunction
206
203
  uri = URI('https://api.openai.com/v1/batches')
207
204
  request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
208
205
  request['Authorization'] = "Bearer #{GptFunction.api_key}"
209
- request.body = {
206
+ body = {
210
207
  input_file_id: file.id,
211
208
  endpoint: '/v1/chat/completions',
212
209
  completion_window: '24h'
213
- }.to_json
210
+ }
211
+ body[:metadata] = metadata unless metadata.nil?
212
+ request.body = body.to_json
214
213
 
215
214
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
216
215
  http.request(request)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GptFunction
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpt-function
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - etrex kuo