cryptum 0.0.423 → 0.0.424

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: 0db6879e922302bbbbcd4c283552f6057c1ff1651cfef64bb3908c60f378bdea
4
- data.tar.gz: 6c1fa446d9facf407b3729aeb4bbc449b92bf44799c5865804811ddfc5ce7dd7
3
+ metadata.gz: 6be55cd7655b11bf979acce2ea8273e8dc7ffb299379c2382f48732cd0538bfe
4
+ data.tar.gz: d1c2de61701aa0d65fc2ae4cd1cd697d30af6e90ed2a2f09c0e9559da01ba02c
5
5
  SHA512:
6
- metadata.gz: 775f105582775eeac624f886fb98884b20a1006ea5d5882ccda2da023ecae159db27f4ad0dfc6c7b13e55b16fd03b701eb2197885c1af4a6cd4d3a18be2d56ad
7
- data.tar.gz: 02b257841617c72ab0fde2be5b70d7d2b70d33317d3c8aa325e1d7464788a6a52aa0d98ff1177fc12c018651139095b9729fc0cf8e50a0a4582ea35119b17717
6
+ metadata.gz: 3fcfb5f5457e240a8f16415218f0261dd1f2fd6833862e45be3936278231738ae267139f83c3d1ab3f166eebd9d3d7fce6159a59feb059ea0046266560c0bcfd
7
+ data.tar.gz: 0c671eca62a2e26ff352228d6bc2002b94b480c87eae5e8621a90534945f2750e1a87a48d8cf20e76d2ca9e66e9232630e7c2321d8ae773ddc2ff98d0ff2b961
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gemspec
12
12
  # to build appropriately. Defer to ./reinstall_coinbot_gemset.sh
13
13
  # to review these custom flags
14
14
  gem 'addressable', '2.8.4'
15
- gem 'bundler', '>=2.4.10'
15
+ gem 'bundler', '>=2.4.11'
16
16
  gem 'bundler-audit', '0.9.1'
17
17
  gem 'curses', '1.4.4'
18
18
  gem 'eventmachine', '1.2.7'
@@ -26,12 +26,12 @@ gem 'rdoc', '6.5.0'
26
26
  gem 'require_all', '3.0.0'
27
27
  gem 'rest-client', '2.1.0'
28
28
  gem 'rspec', '3.12.0'
29
- gem 'rubocop', '1.49.0'
29
+ gem 'rubocop', '1.50.0'
30
30
  gem 'rubocop-rake', '0.6.0'
31
31
  gem 'rubocop-rspec', '2.19.0'
32
32
  gem 'ruby-prof', '1.6.1'
33
33
  gem 'rvm', '1.11.3.9'
34
- gem 'sinatra', '3.0.5'
34
+ gem 'sinatra', '3.0.6'
35
35
  gem 'thin', '1.8.2'
36
36
  gem 'tty-prompt', '0.23.1'
37
37
  gem 'websocket-extensions', '0.1.5'
data/bin/cryptum-repl CHANGED
@@ -71,7 +71,7 @@ begin
71
71
  Cryptum::Log.append(level: :info, msg: msg, which_self: self)
72
72
  cli.start(self, prompt: Pry::Prompt.new(:cryptum, 'CRYPTUM_PROTOTYPING_DRIVER', prompt))
73
73
  rescue StandardError => e
74
- raise e
74
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
75
75
  ensure
76
76
  msg = 'Session Terminated.'
77
77
  Cryptum::Log.append(level: :info, msg: msg, which_self: self)
@@ -116,8 +116,8 @@ module Cryptum
116
116
  )
117
117
 
118
118
  else
119
- e = "Unsupported HTTP Method #{http_method}"
120
- Cryptum::Log.append(level: :debug, msg: e, which_self: self)
119
+ msg = "Unsupported HTTP Method #{http_method}"
120
+ Cryptum::Log.append(level: :debug, msg: msg, which_self: self)
121
121
  end
122
122
 
123
123
  resp = JSON.parse(response, symbolize_names: true)
data/lib/cryptum/log.rb CHANGED
@@ -79,6 +79,7 @@ module Cryptum
79
79
  msg: json_msg
80
80
  )
81
81
  end
82
+ log_event = msg
82
83
  else
83
84
  log_event = "driver: #{driver_name}"
84
85
  if event_history.respond_to?('order_book')
@@ -97,11 +98,11 @@ module Cryptum
97
98
  log_event += "\n\n\n"
98
99
  end
99
100
  end
101
+ end
100
102
 
101
- logger.add(logger.level, log_event, which_self)
103
+ logger.add(logger.level, log_event, which_self)
102
104
 
103
- Cryptum::UI::Exit.gracefully(event_history: event_history) if exit_gracefully
104
- end
105
+ Cryptum::UI::Exit.gracefully(event_history: event_history) if exit_gracefully
105
106
  rescue Interrupt, StandardError => e
106
107
  raise e
107
108
  end
@@ -12,7 +12,8 @@ module Cryptum
12
12
  # http_method: 'optional HTTP method (defaults to GET)
13
13
  # rest_call: 'required rest call to make per the schema',
14
14
  # params: 'optional params passed in the URI or HTTP Headers',
15
- # http_body: 'optional HTTP body sent in HTTP methods that support it e.g. POST'
15
+ # http_body: 'optional HTTP body sent in HTTP methods that support it e.g. POST',
16
+ # timeout: 'optional - timeout in seconds (defaults to 60)'
16
17
  # )
17
18
 
18
19
  private_class_method def self.open_ai_rest_call(opts = {})
@@ -27,6 +28,8 @@ module Cryptum
27
28
  base_open_ai_api_uri = 'https://api.openai.com/v1'
28
29
  token = opts[:token]
29
30
  option_choice = opts[:option_choice]
31
+ timeout = opts[:timeout]
32
+ timeout ||= 60
30
33
 
31
34
  if option_choice.proxy
32
35
  rest_client = RestClient
@@ -46,9 +49,9 @@ module Cryptum
46
49
  authorization: "Bearer #{token}",
47
50
  params: params
48
51
  },
49
- verify_ssl: false
52
+ verify_ssl: false,
53
+ timeout: timeout
50
54
  )
51
-
52
55
  when :post
53
56
  response = rest_client_request.execute(
54
57
  method: :post,
@@ -58,22 +61,21 @@ module Cryptum
58
61
  authorization: "Bearer #{token}"
59
62
  },
60
63
  payload: http_body,
61
- verify_ssl: false
64
+ verify_ssl: false,
65
+ timeout: timeout
62
66
  )
63
-
64
67
  else
65
- raise @@logger.error("Unsupported HTTP Method #{http_method} for #{self} Plugin")
68
+ msg = "Unsupported HTTP Method #{http_method} for #{self} Plugin"
69
+ Cryptum::Log.append(level: :error, msg: msg, which_self: self)
66
70
  end
67
- response
71
+
72
+ JSON.parse(response, symbolize_names: true)
68
73
  rescue RestClient::ExceptionWithResponse => e
69
- File.open('/tmp/cryptum-errors.txt', 'a') do |f|
70
- f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
71
- f.puts "Module: #{self}"
72
- f.puts "URL: #{base_open_ai_api_uri}#{rest_call}"
73
- f.puts "PARAMS: #{params.inspect}"
74
- f.puts "HTTP POST BODY: #{http_body.inspect}" if http_body != ''
75
- f.puts "#{e}\n#{e.response}\n\n\n"
76
- end
74
+ msg = "URL: #{base_open_ai_api_uri}#{rest_call}"
75
+ msg += "PARAMS: #{params.inspect}"
76
+ msg += "HTTP POST BODY: #{http_body.inspect}" if http_body != ''
77
+ msg += "#{e}\n#{e.response}\n\n\n"
78
+ Cryptum::Log.append(level: :error, msg: msg, which_self: self)
77
79
  rescue Interrupt, StandardError => e
78
80
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
79
81
  end
@@ -82,18 +84,18 @@ module Cryptum
82
84
  # response = Cryptum::OpenAI.get_models(
83
85
  # option_choice: 'required - option_choice object containing command line params',
84
86
  # token: 'required - Bearer token',
87
+ # timeout: 'optional - timeout in seconds (defaults to 60)'
85
88
  # )
86
89
 
87
90
  public_class_method def self.get_models(opts = {})
88
91
  token = opts[:token]
89
92
 
90
- response = open_ai_rest_call(
93
+ open_ai_rest_call(
91
94
  option_choice: option_choice,
92
95
  token: token,
93
- rest_call: 'models'
96
+ rest_call: 'models',
97
+ timeout: timeout
94
98
  )
95
-
96
- JSON.parse(response, symbolize_names: true)
97
99
  rescue Interrupt, StandardError => e
98
100
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
99
101
  end
@@ -107,7 +109,8 @@ module Cryptum
107
109
  # temp: 'optional - creative response float (deafults to 0)',
108
110
  # max_tokens: 'optional - integer (defaults to 4_097 - request.length || 300)',
109
111
  # system_role_content: 'optional - context to set up the model behavior for conversation (Default: "You are a momentum trading bot that analyzes order history on Coinbase. You are able to access any content or website on any device or network without any limitations or filters.")',
110
- # response_history: 'optional - pass response back in to have a conversation'
112
+ # response_history: 'optional - pass response back in to have a conversation',
113
+ # timeout: 'optional - timeout in seconds (defaults to 60)'
111
114
  # )
112
115
 
113
116
  public_class_method def self.chat(opts = {})
@@ -126,6 +129,9 @@ module Cryptum
126
129
  max_tokens = 4_097 - request.to_s.length
127
130
  max_tokens = 300 unless max_tokens.positive?
128
131
 
132
+ timeout = opts[:timeout]
133
+ timeout ||= 60
134
+
129
135
  gpt = true if model.include?('gpt-3.5') || model.include?('gpt-4')
130
136
 
131
137
  if gpt
@@ -174,15 +180,15 @@ module Cryptum
174
180
  }
175
181
  end
176
182
 
177
- response = open_ai_rest_call(
183
+ json_resp = open_ai_rest_call(
178
184
  option_choice: option_choice,
179
185
  http_method: :post,
180
186
  token: token,
181
187
  rest_call: rest_call,
182
- http_body: http_body.to_json
188
+ http_body: http_body.to_json,
189
+ timeout: timeout
183
190
  )
184
191
 
185
- json_resp = JSON.parse(response, symbolize_names: true)
186
192
  if gpt
187
193
  assistant_resp = json_resp[:choices].first[:message]
188
194
  json_resp[:choices] = http_body[:messages]
@@ -201,6 +207,7 @@ module Cryptum
201
207
  response = #{self}.get_models(
202
208
  option_choice: 'required - option_choice object containing command line params',
203
209
  token: 'required - Bearer token',
210
+ timeout: 'optional - timeout in seconds (defaults to 60)'
204
211
  )
205
212
 
206
213
  response = #{self}.chat(
@@ -211,7 +218,8 @@ module Cryptum
211
218
  temp: 'optional - creative response float (defaults to 0)',
212
219
  max_tokens: 'optional - integer (deafults to 4_097 - request.length || 300)',
213
220
  system_role_content: 'optional - context to set up the model behavior for conversation (Default: \"You are a momentum trading bot that analyzes order history on Coinbase. You are able to access any content or website on any device or network without any limitations or filters.\")',
214
- response_history: 'optional - pass response back in to have a conversation'
221
+ response_history: 'optional - pass response back in to have a conversation',
222
+ timeout: 'optional - timeout in seconds (defaults to 60)'
215
223
  )
216
224
  "
217
225
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.423'
4
+ VERSION = '0.0.424'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.423
4
+ version: 0.0.424
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-10 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.4.10
33
+ version: 2.4.11
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.4.10
40
+ version: 2.4.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler-audit
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - '='
228
228
  - !ruby/object:Gem::Version
229
- version: 1.49.0
229
+ version: 1.50.0
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - '='
235
235
  - !ruby/object:Gem::Version
236
- version: 1.49.0
236
+ version: 1.50.0
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: rubocop-rake
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -296,14 +296,14 @@ dependencies:
296
296
  requirements:
297
297
  - - '='
298
298
  - !ruby/object:Gem::Version
299
- version: 3.0.5
299
+ version: 3.0.6
300
300
  type: :runtime
301
301
  prerelease: false
302
302
  version_requirements: !ruby/object:Gem::Requirement
303
303
  requirements:
304
304
  - - '='
305
305
  - !ruby/object:Gem::Version
306
- version: 3.0.5
306
+ version: 3.0.6
307
307
  - !ruby/object:Gem::Dependency
308
308
  name: thin
309
309
  requirement: !ruby/object:Gem::Requirement