chatgpt2023 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/chatgpt2023.rb +49 -8
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec634a55d06fe1dbbeec12535c076677953903146f57aad99bdb1090fdb1c5c
|
4
|
+
data.tar.gz: 53b6db1a22dabbc4d21948e9d257d93dae12814bf13ef98e6d795f45b9a14ab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a5f4aa64030d07af1b053a3adaeb827aaa2ad8d0b545df5cef516ab07d6574cf4715029481ba283dbe40a83cb8ed2b09738c1f916656818f42ec97c3e9a303
|
7
|
+
data.tar.gz: 96a6868c366028eacaf522b8d8a795034b56f473f0b3aab801b672d779f2de1b694ce295232f2dc2e9c4b2a49e02f55dd56e5a16ab3c537652b9b48ae3bc8a93
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/chatgpt2023.rb
CHANGED
@@ -24,6 +24,7 @@ require 'down'
|
|
24
24
|
# -d '{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}'
|
25
25
|
|
26
26
|
# ChatGpt documentation: https://beta.openai.com/docs/introduction/overview
|
27
|
+
# ChatGpt web page: https://chat.openai.com/chat
|
27
28
|
|
28
29
|
# Usage:
|
29
30
|
# require 'chatgpt2023'
|
@@ -46,18 +47,40 @@ class ChatGpt2023
|
|
46
47
|
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
# Example
|
51
|
+
# c = ChatGpt2023.new(apikey: 'yourapikey')
|
52
|
+
# s = '
|
53
|
+
# # Ruby
|
54
|
+
# # Ask the user for their name and say "Hello"
|
55
|
+
# '
|
56
|
+
# r = c.code_completions s, temperature: 0.2
|
57
|
+
# puts r.first[:text]
|
58
|
+
|
59
|
+
def code_completions(s, temperature: 1, max_tokens: 32, n: 1)
|
60
|
+
|
61
|
+
r = go_code(s, temperature: temperature,
|
62
|
+
max_tokens: max_tokens, n: n)
|
63
|
+
puts 'code r: ' + r.inspect if @debug
|
64
|
+
r[:choices]
|
50
65
|
|
51
|
-
|
52
|
-
|
66
|
+
end
|
67
|
+
|
68
|
+
def code_completion(s, temperature: 1, max_tokens: 32)
|
69
|
+
code_completions(s, temperature: temperature, max_tokens: max_tokens)\
|
70
|
+
.first[:text].strip
|
71
|
+
end
|
72
|
+
|
73
|
+
def completions(s, temperature: 1, max_tokens: 32, n: 1)
|
53
74
|
|
75
|
+
r = go_completions(s, temperature: temperature,
|
76
|
+
max_tokens: max_tokens, n: n)
|
54
77
|
puts 'completions r: ' + r.inspect if @debug
|
55
78
|
r[:choices]
|
56
79
|
|
57
80
|
end
|
58
81
|
|
59
|
-
def completion(s, temperature:
|
60
|
-
|
82
|
+
def completion(s, temperature: 1, max_tokens: 32)
|
83
|
+
completions(s, temperature: temperature, max_tokens: max_tokens)\
|
61
84
|
.first[:text].strip
|
62
85
|
end
|
63
86
|
|
@@ -84,14 +107,29 @@ class ChatGpt2023
|
|
84
107
|
end
|
85
108
|
|
86
109
|
private
|
110
|
+
|
111
|
+
def go_code(s, temperature: 0, max_tokens: 7, n: 1)
|
87
112
|
|
88
|
-
|
113
|
+
h = {
|
114
|
+
"model" => 'code-davinci-002',
|
115
|
+
"prompt" => s,
|
116
|
+
"temperature" => temperature,
|
117
|
+
"max_tokens" => max_tokens,
|
118
|
+
"n" => n
|
119
|
+
}
|
120
|
+
|
121
|
+
submit('completions', h)
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
def go_completions(s, temperature: 0, max_tokens: 7, n: 1)
|
89
126
|
|
90
127
|
h = {
|
91
128
|
"model" => 'text-davinci-003',
|
92
129
|
"prompt" => s,
|
93
130
|
"temperature" => temperature,
|
94
|
-
"max_tokens" => max_tokens
|
131
|
+
"max_tokens" => max_tokens,
|
132
|
+
"n" => n
|
95
133
|
}
|
96
134
|
|
97
135
|
submit('completions', h)
|
@@ -155,7 +193,10 @@ class ChatGpt2023
|
|
155
193
|
http.request(request)
|
156
194
|
end
|
157
195
|
|
158
|
-
JSON.parse(response.body, symbolize_names: true)
|
196
|
+
h = JSON.parse(response.body, symbolize_names: true)
|
197
|
+
raise ChatGpt2023Error, h[:error][:message].inspect if h.has_key? :error
|
198
|
+
|
199
|
+
return h
|
159
200
|
end
|
160
201
|
|
161
202
|
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.
|
4
|
+
version: 0.2.2
|
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-02-
|
39
|
+
date: 2023-02-13 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: down
|
metadata.gz.sig
CHANGED
Binary file
|