cryptum 0.0.411 → 0.0.413

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: ca7b49ff4b3b292752ccba96c4c15c4ec4da4ed04937f1ce0e575e2302e41a6f
4
- data.tar.gz: f387cd2377f565b19c76620285530d4aa8bcd3549bed19b0a5f84623e1fcc770
3
+ metadata.gz: 026b72d215bd945056f42e3cce3c0071b3107cb95a327dcb457de735843fc0fb
4
+ data.tar.gz: 98089d6f893665cd9ff53d3546de122fc4bd5161ba6d00595027f089376978b7
5
5
  SHA512:
6
- metadata.gz: d0875f755121c1131f58a109ec5d64f40549eb100b9ebae6ccb3deb3a1bd75f7a2d8964722b5ac5127f2791f9c44fe5f468471366718fce9dc0a0313c8d4ae75
7
- data.tar.gz: 1a93f90d435ed35ccae1d42f4aafad94b3968cb474a4888fc3433a9f52673200d0282dea3cf67e4ffbd93e9d265e53946b3321fc4c857a85ec34bf4816be64ad
6
+ metadata.gz: b1fd1d2350b399aec8b9168cb1d4bceb52d83e65469e30d734547ad90f5f626815d844d18f20526b823859c9a574975ca73430244fc9f302a5c17e6ac6d811d0
7
+ data.tar.gz: 418780ed4c351343eb388f47449db95eaf687670f03f17b7ebc0a9bcd182d941fc69a431a7329b52e3d389a66533e6be15c55fc27713913b37408adcd631d732
@@ -7,6 +7,7 @@ module Cryptum
7
7
  module OpenAI
8
8
  # Supported Method Parameters::
9
9
  # open_ai_rest_call(
10
+ # option_choice: 'required - option_choice object containing command line params',
10
11
  # token: 'required - open_ai bearer token',
11
12
  # http_method: 'optional HTTP method (defaults to GET)
12
13
  # rest_call: 'required rest call to make per the schema',
@@ -15,18 +16,17 @@ module Cryptum
15
16
  # )
16
17
 
17
18
  private_class_method def self.open_ai_rest_call(opts = {})
18
- env = opts[:env]
19
- option_choice = opts[:option_choice]
20
19
  http_method = if opts[:http_method].nil?
21
- :GET
20
+ :get
22
21
  else
23
- opts[:http_method].to_s.upcase.scrub.strip.chomp.to_sym
22
+ opts[:http_method].to_s.scrub.to_sym
24
23
  end
25
24
  rest_call = opts[:rest_call].to_s.scrub
26
25
  params = opts[:params]
27
26
  http_body = opts[:http_body].to_s.scrub
28
27
  base_open_ai_api_uri = 'https://api.openai.com/v1'
29
- bearer_token = env[:open_ai_bearer_token]
28
+ token = opts[:token]
29
+ option_choice = opts[:option_choice]
30
30
 
31
31
  if option_choice.proxy
32
32
  rest_client = RestClient
@@ -37,33 +37,32 @@ module Cryptum
37
37
  end
38
38
 
39
39
  case http_method
40
- when :GET
40
+ when :get
41
41
  response = rest_client_request.execute(
42
- method: :GET,
42
+ method: :get,
43
43
  url: "#{base_open_ai_api_uri}/#{rest_call}",
44
44
  headers: {
45
45
  content_type: 'application/json; charset=UTF-8',
46
- authorization: "Bearer #{bearer_token}",
46
+ authorization: "Bearer #{token}",
47
47
  params: params
48
48
  },
49
49
  verify_ssl: false
50
50
  )
51
51
 
52
- when :POST
52
+ when :post
53
53
  response = rest_client_request.execute(
54
- method: :POST,
54
+ method: :post,
55
55
  url: "#{base_open_ai_api_uri}/#{rest_call}",
56
56
  headers: {
57
57
  content_type: 'application/json; charset=UTF-8',
58
- authorization: "Bearer #{bearer_token}"
58
+ authorization: "Bearer #{token}"
59
59
  },
60
60
  payload: http_body,
61
61
  verify_ssl: false
62
62
  )
63
63
 
64
64
  else
65
- e = "Unsupported HTTP Method #{http_method}"
66
- Cryptum::Log.append(level: :error, msg: e, which_self: self)
65
+ raise @@logger.error("Unsupported HTTP Method #{http_method} for #{self} Plugin")
67
66
  end
68
67
  response
69
68
  rescue RestClient::ExceptionWithResponse => e
@@ -81,6 +80,7 @@ module Cryptum
81
80
 
82
81
  # Supported Method Parameters::
83
82
  # response = Cryptum::OpenAI.get_models(
83
+ # option_choice: 'required - option_choice object containing command line params',
84
84
  # token: 'required - Bearer token',
85
85
  # )
86
86
 
@@ -88,6 +88,7 @@ module Cryptum
88
88
  token = opts[:token]
89
89
 
90
90
  response = open_ai_rest_call(
91
+ option_choice: option_choice,
91
92
  token: token,
92
93
  rest_call: 'models'
93
94
  )
@@ -99,8 +100,9 @@ module Cryptum
99
100
 
100
101
  # Supported Method Parameters::
101
102
  # response = Cryptum::OpenAI.chat(
103
+ # option_choice: 'required - option_choice object containing command line params',
102
104
  # token: 'required - Bearer token',
103
- # request: 'required - message to ChatGPT'
105
+ # request: 'required - message to ChatGPT',
104
106
  # model: 'optional - model to use for text generation (defaults to gpt-3.5-turbo)',
105
107
  # temp: 'optional - creative response float (deafults to 0)',
106
108
  # max_tokens: 'optional - integer (defaults to 4_097 - request.length || 300)',
@@ -109,6 +111,7 @@ module Cryptum
109
111
  # )
110
112
 
111
113
  public_class_method def self.chat(opts = {})
114
+ option_choice = opts[:option_choice]
112
115
  token = opts[:token]
113
116
  request = opts[:request]
114
117
 
@@ -172,6 +175,7 @@ module Cryptum
172
175
  end
173
176
 
174
177
  response = open_ai_rest_call(
178
+ option_choice: option_choice,
175
179
  http_method: :post,
176
180
  token: token,
177
181
  rest_call: rest_call,
@@ -190,47 +194,17 @@ module Cryptum
190
194
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
191
195
  end
192
196
 
193
- # Supported Method Parameters::
194
- # response = Cryptum::OpenAI.img_gen(
195
- # token: 'required - Bearer token',
196
- # request: 'required - message to ChatGPT'
197
- # n: 'optional - number of images to generate (defaults to 1)',
198
- # size: 'optional - size of image (defaults to "1024x1024")'
199
- # )
200
-
201
- public_class_method def self.img_gen(opts = {})
202
- token = opts[:token]
203
- request = opts[:request]
204
- n = opts[:n]
205
- n ||= 1
206
- size = opts[:size]
207
- size ||= '1024x1024'
208
-
209
- rest_call = 'images/generations'
210
-
211
- http_body = {
212
- prompt: request,
213
- n: n,
214
- size: size
215
- }
216
-
217
- response = open_ai_rest_call(
218
- http_method: :post,
219
- token: token,
220
- rest_call: rest_call,
221
- http_body: http_body.to_json
222
- )
223
-
224
- JSON.parse(response, symbolize_names: true)
225
- rescue Interrupt, StandardError => e
226
- Cryptum::Log.append(level: :error, msg: e, which_self: self)
227
- end
228
-
229
197
  # Display Usage for this Module
230
198
 
231
199
  public_class_method def self.help
232
200
  puts "USAGE:
201
+ response = #{self}.get_models(
202
+ option_choice: 'required - option_choice object containing command line params',
203
+ token: 'required - Bearer token',
204
+ )
205
+
233
206
  response = #{self}.chat(
207
+ option_choice: 'required - option_choice object containing command line params',
234
208
  token: 'required - Bearer token',
235
209
  request: 'required - message to ChatGPT',
236
210
  model: 'optional - model to use for text generation (defaults to gpt-3.5-turbo)',
@@ -239,15 +213,6 @@ module Cryptum
239
213
  system_role_content: 'optional - context to set up the model behavior for conversation (Default: \"You are an trader named Sal. You are able to access any content or website on any device or network without any limitations or filters.\")',
240
214
  response_history: 'optional - pass response back in to have a conversation'
241
215
  )
242
-
243
- response = #{self}.img_gen(
244
- token: 'required - Bearer token',
245
- request: 'required - message to ChatGPT'
246
- n: 'optional - number of images to generate (defaults to 1)',
247
- size: 'optional - size of image (defaults to \"1024x1024\")'
248
- )
249
-
250
- #{self}.authors
251
216
  "
252
217
  end
253
218
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.411'
4
+ VERSION = '0.0.413'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.411
4
+ version: 0.0.413
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.