chatgpt2023 0.2.2 → 0.3.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: 9ec634a55d06fe1dbbeec12535c076677953903146f57aad99bdb1090fdb1c5c
4
- data.tar.gz: 53b6db1a22dabbc4d21948e9d257d93dae12814bf13ef98e6d795f45b9a14ab8
3
+ metadata.gz: 9e1847e43e89e75aec42261b773b2f46909463c0a05be57bb532ac2682421088
4
+ data.tar.gz: 751d498aeaaa3eb3b68d977ecbb415385d606282584afa9612fdaf03349f7e59
5
5
  SHA512:
6
- metadata.gz: 35a5f4aa64030d07af1b053a3adaeb827aaa2ad8d0b545df5cef516ab07d6574cf4715029481ba283dbe40a83cb8ed2b09738c1f916656818f42ec97c3e9a303
7
- data.tar.gz: 96a6868c366028eacaf522b8d8a795034b56f473f0b3aab801b672d779f2de1b694ce295232f2dc2e9c4b2a49e02f55dd56e5a16ab3c537652b9b48ae3bc8a93
6
+ metadata.gz: 9c3f02bfa4ba351dbfde5d60bc0d74cb8970c46a11d5632ab79b221445549e075cc4abcb03b8a479d7912c919e4a8257239d4f8f117144ea0eede97f7a26df80
7
+ data.tar.gz: 5cbd01a39b78cf3b927ce5a9729c6aabbcf4ff98c5e4e02b90acad8a414102e3c5910887395837bcc76f678ebf5fbd9db094ae3003d80f3f3bd1b887930214d0
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/chatgpt2023.rb CHANGED
@@ -6,6 +6,7 @@ require 'net/http'
6
6
  require 'uri'
7
7
  require 'json'
8
8
  require 'down'
9
+ require 'dynarex-daily'
9
10
 
10
11
 
11
12
  # description: 1st experiment at playing with the ChatGPT API.
@@ -200,3 +201,50 @@ class ChatGpt2023
200
201
  end
201
202
 
202
203
  end
204
+
205
+ class CGRecorder < ChatGpt2023
206
+
207
+ def initialize(apikey: nil, indexfile: 'cgindex.xml',
208
+ logfile: 'chatgpt.xml', debug: false)
209
+
210
+ super(apikey: apikey, debug: debug)
211
+ @dx = DynarexDaily.new filename: logfile, fields: %i(prompt result),
212
+ autosave: true, order: 'descending', debug: false
213
+ @index = Dynarex.new(indexfile, schema: 'entries[title]/entry(prompt, ' \
214
+ + 'tags)', order: 'descending', autosave: true)
215
+ @index.title = 'ChatGPT prompt log'
216
+
217
+ end
218
+
219
+ def code_completion(s, tags=nil, temperature: 1, max_tokens: 32)
220
+
221
+ r = code_completions(s, temperature: temperature, max_tokens: max_tokens)\
222
+ .first[:text].strip
223
+ log(s, r, tags)
224
+
225
+ return r
226
+
227
+ end
228
+
229
+ def completion(s, tags=nil, temperature: 1, max_tokens: 32)
230
+
231
+ r = completions(s, temperature: temperature, max_tokens: max_tokens)\
232
+ .first[:text].strip
233
+ log(s, r, tags)
234
+
235
+ return r
236
+
237
+ end
238
+
239
+ alias complete completion
240
+ alias ask completion
241
+
242
+ private
243
+
244
+ def log(prompt, result, tags)
245
+
246
+ @index.create({prompt: prompt, tags: tags})
247
+ @dx.create({prompt: prompt, result: result})
248
+
249
+ end
250
+ end
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.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -58,6 +58,26 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 5.4.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: dynarex-daily
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.7'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 0.7.0
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.7'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 0.7.0
61
81
  description:
62
82
  email: digital.robertson@gmail.com
63
83
  executables: []
@@ -87,5 +107,5 @@ requirements: []
87
107
  rubygems_version: 3.4.4
88
108
  signing_key:
89
109
  specification_version: 4
90
- summary: 1st experiment at playing with the ChatGPT API
110
+ summary: 'A ChatGPT API wrapper. #experimental'
91
111
  test_files: []
metadata.gz.sig CHANGED
Binary file