chatgpt2023 0.2.0 → 0.2.1

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: 88c1cfbb0ea81bad341b25450770d3f9cd5142047a76f9650ed165cfc4295941
4
- data.tar.gz: f155c706875520f4ffb3d25549b7a8cbde8b1b6c88919eb6b9e85f252486b979
3
+ metadata.gz: 4728e79c0d12f0dd5a5ce7a7970f507d6fd79471727fb205f7416b3326fe8985
4
+ data.tar.gz: 7ca136ca869d4908c9fa70827b4a2a549cff92633026c1c70e8843886c026b59
5
5
  SHA512:
6
- metadata.gz: cb5037feeaeb3181994e6d669bbf0d97c01e3dbaf06ca1f47754e9b9ab136a79c877e5ffb4c477319658fd2bb8594940831278fa02309a0b887ffab8aa0b3692
7
- data.tar.gz: 2c597fa1448e6552e5ddfe58ff008b42de82b3413f05f020df304e6ff3ace7df88890a3a2d25e687ec98de9c988eaf415515d6fecca2ae4b3f27868c0c9ea3fa
6
+ metadata.gz: f403b18eec392d2b1958b1168536ad716f02ddcd7445a3c67fa46916193190ee920020a2902e63c00621135392f580a00e12948b6dfa56a40f5316dd42d591d2
7
+ data.tar.gz: bda567ca1b04f4e4350c475d62cc4576887c36d7762bae951dd918269f149419411eb76e309a6190ad5e34cea71db375dd55a2a0b6cddff86ab0495a74506faf
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/chatgpt2023.rb CHANGED
@@ -32,6 +32,9 @@ require 'down'
32
32
  # chat.completion 'Say this is a test'
33
33
  # #=> This is indeed a test
34
34
 
35
+ class ChatGpt2023Error < Exception
36
+ end
37
+
35
38
  class ChatGpt2023
36
39
 
37
40
  def initialize(apikey: nil, debug: false)
@@ -44,35 +47,40 @@ class ChatGpt2023
44
47
  end
45
48
 
46
49
  def completions(s, temperature: 0, max_tokens: 7)
47
- r = self.go_completions(s, temperature: temperature,
48
- max_tokens: max_tokens)
50
+
51
+ r = go_completions(s, temperature: temperature, max_tokens: max_tokens)
52
+ raise ChatGpt2023Error, r[:error][:message].inspect if r.has_key? :error
53
+
54
+ puts 'completions r: ' + r.inspect if @debug
49
55
  r[:choices]
56
+
50
57
  end
51
58
 
52
- def completion(s)
53
- self.go_completions(s).first[:text].strip
59
+ def completion(s, temperature: 0, max_tokens: 7)
60
+ go_completions(s, temperature: temperature, max_tokens: max_tokens)\
61
+ .first[:text].strip
54
62
  end
55
63
 
56
64
  alias complete completion
65
+ alias ask completion
57
66
 
58
67
  def edits(s, s2)
59
- r = self.go_edits(s, s2)
68
+ r = go_edits(s, s2)
60
69
  end
61
70
 
62
71
  def images(s)
63
- self.go_images_generations(s)
72
+ go_images_generations(s)
64
73
  end
65
74
 
66
75
  def image(s)
67
- r = self.images(s)
68
- img = r[:data].first[:url]
69
- Down.download(img)
76
+ r = images(s)
77
+ Down.download(r[:data].first[:url] )
70
78
  end
71
79
 
72
80
  alias imagine image
73
81
 
74
82
  def images_edit(s, image, mask: nil)
75
- self.go_images_edits(s, image, mask: mask)
83
+ go_images_edits(s, image, mask: mask)
76
84
  end
77
85
 
78
86
  private
@@ -129,9 +137,9 @@ class ChatGpt2023
129
137
 
130
138
  end
131
139
 
132
- def submit(uri, h)
140
+ def submit(uri2, h)
133
141
 
134
- uri = URI.parse(@apiurl + '/' + uri)
142
+ uri = URI.parse(@apiurl + '/' + uri2)
135
143
  request = Net::HTTP::Post.new(uri)
136
144
  request.content_type = "application/json"
137
145
  request["Authorization"] = 'Bearer ' + @apikey
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatgpt2023
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -36,7 +36,7 @@ cert_chain:
36
36
  6FQD1/GISew7VvxUJdptXeuVNIsdNKxvL3RpfLCuFsi1WXyJ4k3odRMTmS0kAfTy
37
37
  J4sZZW9RNfabTMQQY7DIs3tUAn6i+O0r9lo=
38
38
  -----END CERTIFICATE-----
39
- date: 2023-01-25 00:00:00.000000000 Z
39
+ date: 2023-02-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: down
metadata.gz.sig CHANGED
Binary file