cryptum 0.0.411 → 0.0.412

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: 4ee05b50c2c3b3f1880ad26e773ff289f81f30b5332cc84fbb41759a10b6b58d
4
+ data.tar.gz: 7d162286e0c2226706823902e016d5642ce8753c8221f9397179790f22084313
5
5
  SHA512:
6
- metadata.gz: d0875f755121c1131f58a109ec5d64f40549eb100b9ebae6ccb3deb3a1bd75f7a2d8964722b5ac5127f2791f9c44fe5f468471366718fce9dc0a0313c8d4ae75
7
- data.tar.gz: 1a93f90d435ed35ccae1d42f4aafad94b3968cb474a4888fc3433a9f52673200d0282dea3cf67e4ffbd93e9d265e53946b3321fc4c857a85ec34bf4816be64ad
6
+ metadata.gz: ec23efdbcaa2526b6abdd97dc1205d1cdfd58d9b93264c35d1e02b70f9a414862e2ad2a5a99d8a1e5e4781d1043ff9dbdf939d062fd579cf0e560618d87e78a6
7
+ data.tar.gz: 8f389ce62ca6421fa6ff6ea85c6618ab016d36a61fa076cf87f808b35a0239d887020cea67b3f8a34a9d062f29b2f8738425b0edcfc53da6ab9e9346268c07e9
@@ -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
 
@@ -99,8 +99,9 @@ module Cryptum
99
99
 
100
100
  # Supported Method Parameters::
101
101
  # response = Cryptum::OpenAI.chat(
102
+ # option_choice: 'required - option_choice object containing command line params',
102
103
  # token: 'required - Bearer token',
103
- # request: 'required - message to ChatGPT'
104
+ # request: 'required - message to ChatGPT',
104
105
  # model: 'optional - model to use for text generation (defaults to gpt-3.5-turbo)',
105
106
  # temp: 'optional - creative response float (deafults to 0)',
106
107
  # max_tokens: 'optional - integer (defaults to 4_097 - request.length || 300)',
@@ -109,6 +110,7 @@ module Cryptum
109
110
  # )
110
111
 
111
112
  public_class_method def self.chat(opts = {})
113
+ option_choice = opts[:option_choice]
112
114
  token = opts[:token]
113
115
  request = opts[:request]
114
116
 
@@ -190,47 +192,17 @@ module Cryptum
190
192
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
191
193
  end
192
194
 
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
195
  # Display Usage for this Module
230
196
 
231
197
  public_class_method def self.help
232
198
  puts "USAGE:
199
+ response = #{self}.get_models(
200
+ option_choice: 'required - option_choice object containing command line params',
201
+ token: 'required - Bearer token',
202
+ )
203
+
233
204
  response = #{self}.chat(
205
+ option_choice: 'required - option_choice object containing command line params',
234
206
  token: 'required - Bearer token',
235
207
  request: 'required - message to ChatGPT',
236
208
  model: 'optional - model to use for text generation (defaults to gpt-3.5-turbo)',
@@ -239,15 +211,6 @@ module Cryptum
239
211
  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
212
  response_history: 'optional - pass response back in to have a conversation'
241
213
  )
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
214
  "
252
215
  end
253
216
  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.412'
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.412
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.