chatgpt_assistant 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env_sample +1 -1
- data/.rubocop.yml +4 -4
- data/Gemfile +18 -6
- data/Gemfile.lock +62 -59
- data/README.md +14 -13
- data/docker-compose.prod.yml +1 -1
- data/docker-compose.yml +18 -0
- data/exe/chatgpt_bot +3 -0
- data/lib/bots/application_bot.rb +15 -5
- data/lib/bots/discord_bot.rb +6 -9
- data/lib/bots/helpers/authentication_helper.rb +3 -2
- data/lib/bots/helpers/discord_helper.rb +4 -4
- data/lib/bots/helpers/messenger_helper.rb +14 -15
- data/lib/bots/helpers/search_helper.rb +3 -3
- data/lib/bots/helpers/telegram_helper.rb +3 -7
- data/lib/bots/helpers/validation_helper.rb +1 -1
- data/lib/bots/helpers/visit_helper.rb +4 -0
- data/lib/bots/jobs/new_chat_job.rb +17 -0
- data/lib/bots/jobs/register_job.rb +16 -0
- data/lib/bots/jobs/voice_connect_job.rb +14 -0
- data/lib/bots/services/new_chat_service.rb +34 -0
- data/lib/bots/services/register_service.rb +36 -0
- data/lib/bots/services/voice_connect_service.rb +29 -0
- data/lib/bots/telegram_bot.rb +70 -39
- data/lib/chatgpt_assistant/config.rb +23 -1
- data/lib/chatgpt_assistant/default_messages.rb +72 -30
- data/lib/chatgpt_assistant/error.rb +219 -0
- data/lib/chatgpt_assistant/models.rb +18 -13
- data/lib/chatgpt_assistant/sidekiq.rb +7 -0
- data/lib/chatgpt_assistant/sidekiq.yml +10 -0
- data/lib/chatgpt_assistant/version.rb +1 -1
- data/lib/chatgpt_assistant.rb +3 -12
- data/prompts-data/{awesome-chatgpt-prompts.csv → awesome-en-prompts.csv} +164 -164
- data/prompts-data/awesome-pt-prompts.csv +164 -0
- metadata +14 -5
- data/lib/bots/helpers/logger_action_helper.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9317ab1f4742c358a91f3e8ec363d8ed72147c2a31e0a312ec6c5ad54215c8db
|
4
|
+
data.tar.gz: e3a6a3f6099a4dcb47b262fb388f5f783a2f48466b1946f2e140e1a1b4c25767
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea5f6b13b7db43f7261d9a726257bdf9e37a45bda2d34149bf7c35c659eee8092aec29a3dc7db8dc3222c005c65941f10f6b24f589f20ab0786a91e69290f27
|
7
|
+
data.tar.gz: 46e7e83be3e53a7ece0fbaf0c59d67054270e05e0d6fad8b4fb09194f57a2de82d136203110fb9de20d11a1160c8b29dd2be19a026567528c898224a08452f67
|
data/.env_sample
CHANGED
data/.rubocop.yml
CHANGED
@@ -11,22 +11,22 @@ Style/StringLiteralsInInterpolation:
|
|
11
11
|
EnforcedStyle: double_quotes
|
12
12
|
|
13
13
|
Layout/LineLength:
|
14
|
-
Max:
|
14
|
+
Max: 200
|
15
15
|
|
16
16
|
Metrics/ModuleLength:
|
17
17
|
Max: 120
|
18
18
|
|
19
19
|
Metrics/MethodLength:
|
20
|
-
Max:
|
20
|
+
Max: 250
|
21
21
|
|
22
22
|
Metrics/BlockLength:
|
23
|
-
Max:
|
23
|
+
Max: 250
|
24
24
|
|
25
25
|
Metrics/ClassLength:
|
26
26
|
Max: 300
|
27
27
|
|
28
28
|
Metrics/AbcSize:
|
29
|
-
Max:
|
29
|
+
Max: 35
|
30
30
|
|
31
31
|
Layout/AccessModifierIndentation:
|
32
32
|
EnforcedStyle: indent
|
data/Gemfile
CHANGED
@@ -6,15 +6,27 @@ gem "bcrypt"
|
|
6
6
|
|
7
7
|
gem "rake", "~> 13.0"
|
8
8
|
|
9
|
-
gem "rspec", "~> 3.
|
9
|
+
gem "rspec", "~> 3.12", group: :test
|
10
|
+
|
11
|
+
gem "rspec-rails", "~> 6.0", group: :test
|
10
12
|
|
11
13
|
gem "simplecov", "~> 0.21", group: :test
|
12
14
|
|
13
15
|
gem "vcr", "~> 6.0", group: :test
|
14
16
|
|
15
|
-
gem "
|
17
|
+
gem "shoulda-matchers", "~> 5.3", group: :test
|
18
|
+
|
19
|
+
gem "factory_bot_rails", "~> 6.0", group: :test
|
20
|
+
|
21
|
+
gem "faker", "~> 2.0", group: :test
|
22
|
+
|
23
|
+
gem "database_cleaner", "~> 2.0", group: :test
|
16
24
|
|
17
|
-
gem "
|
25
|
+
gem "dotenv", "~> 2.0", group: :test
|
26
|
+
|
27
|
+
gem "rubocop", "~> 1.50"
|
28
|
+
|
29
|
+
gem "rubocop-rspec", "~> 2.20"
|
18
30
|
|
19
31
|
gem "telegram-bot-ruby", "~> 0.16"
|
20
32
|
|
@@ -28,8 +40,6 @@ gem "activerecord"
|
|
28
40
|
|
29
41
|
gem "activesupport"
|
30
42
|
|
31
|
-
gem "actionmailer"
|
32
|
-
|
33
43
|
gem "redis"
|
34
44
|
|
35
45
|
gem "sidekiq"
|
@@ -48,4 +58,6 @@ gem "ibm_watson"
|
|
48
58
|
|
49
59
|
gem "aws-sdk-polly"
|
50
60
|
|
51
|
-
gem "awesome_chatgpt_actors"
|
61
|
+
gem "awesome_chatgpt_actors"
|
62
|
+
|
63
|
+
gem "sidekiq-expiring-jobs"
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,6 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (7.0.4.3)
|
5
|
-
actionpack (= 7.0.4.3)
|
6
|
-
actionview (= 7.0.4.3)
|
7
|
-
activejob (= 7.0.4.3)
|
8
|
-
activesupport (= 7.0.4.3)
|
9
|
-
mail (~> 2.5, >= 2.5.4)
|
10
|
-
net-imap
|
11
|
-
net-pop
|
12
|
-
net-smtp
|
13
|
-
rails-dom-testing (~> 2.0)
|
14
4
|
actionpack (7.0.4.3)
|
15
5
|
actionview (= 7.0.4.3)
|
16
6
|
activesupport (= 7.0.4.3)
|
@@ -24,9 +14,6 @@ GEM
|
|
24
14
|
erubi (~> 1.4)
|
25
15
|
rails-dom-testing (~> 2.0)
|
26
16
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
-
activejob (7.0.4.3)
|
28
|
-
activesupport (= 7.0.4.3)
|
29
|
-
globalid (>= 0.3.6)
|
30
17
|
activemodel (7.0.4.3)
|
31
18
|
activesupport (= 7.0.4.3)
|
32
19
|
activerecord (7.0.4.3)
|
@@ -39,14 +26,13 @@ GEM
|
|
39
26
|
i18n (>= 1.6, < 2)
|
40
27
|
minitest (>= 5.1)
|
41
28
|
tzinfo (~> 2.0)
|
42
|
-
addressable (2.8.
|
29
|
+
addressable (2.8.4)
|
43
30
|
public_suffix (>= 2.0.2, < 6.0)
|
44
31
|
ast (2.4.2)
|
45
|
-
awesome_chatgpt_actors (0.1.
|
46
|
-
csv
|
47
|
-
ruby-openai
|
32
|
+
awesome_chatgpt_actors (0.1.3)
|
33
|
+
csv (~> 3.1)
|
48
34
|
aws-eventstream (1.2.0)
|
49
|
-
aws-partitions (1.
|
35
|
+
aws-partitions (1.748.0)
|
50
36
|
aws-sdk-core (3.171.0)
|
51
37
|
aws-eventstream (~> 1, >= 1.0.2)
|
52
38
|
aws-partitions (~> 1, >= 1.651.0)
|
@@ -69,7 +55,12 @@ GEM
|
|
69
55
|
connection_pool (2.4.0)
|
70
56
|
crass (1.0.6)
|
71
57
|
csv (3.2.6)
|
72
|
-
|
58
|
+
database_cleaner (2.0.2)
|
59
|
+
database_cleaner-active_record (>= 2, < 3)
|
60
|
+
database_cleaner-active_record (2.1.0)
|
61
|
+
activerecord (>= 5.a)
|
62
|
+
database_cleaner-core (~> 2.0.0)
|
63
|
+
database_cleaner-core (2.0.1)
|
73
64
|
descendants_tracker (0.0.4)
|
74
65
|
thread_safe (~> 0.3, >= 0.3.1)
|
75
66
|
diff-lcs (1.5.0)
|
@@ -84,19 +75,27 @@ GEM
|
|
84
75
|
docile (1.4.0)
|
85
76
|
domain_name (0.5.20190701)
|
86
77
|
unf (>= 0.0.5, < 1.0.0)
|
78
|
+
dotenv (2.8.1)
|
87
79
|
dry-inflector (1.0.0)
|
88
80
|
erubi (1.12.0)
|
89
81
|
et-orbi (1.2.7)
|
90
82
|
tzinfo
|
91
83
|
event_emitter (0.2.6)
|
92
84
|
eventmachine (1.2.7)
|
85
|
+
factory_bot (6.2.1)
|
86
|
+
activesupport (>= 5.0.0)
|
87
|
+
factory_bot_rails (6.2.0)
|
88
|
+
factory_bot (~> 6.2.0)
|
89
|
+
railties (>= 5.0.0)
|
90
|
+
faker (2.23.0)
|
91
|
+
i18n (>= 1.8.11, < 2)
|
93
92
|
faraday (2.7.4)
|
94
93
|
faraday-net_http (>= 2.0, < 3.1)
|
95
94
|
ruby2_keywords (>= 0.0.4)
|
96
95
|
faraday-multipart (1.0.4)
|
97
96
|
multipart-post (~> 2)
|
98
97
|
faraday-net_http (3.0.2)
|
99
|
-
faye-websocket (0.11.
|
98
|
+
faye-websocket (0.11.2)
|
100
99
|
eventmachine (>= 0.12.0)
|
101
100
|
websocket-driver (>= 0.5.1)
|
102
101
|
ffi (1.15.5)
|
@@ -106,8 +105,6 @@ GEM
|
|
106
105
|
fugit (1.8.1)
|
107
106
|
et-orbi (~> 1, >= 1.2.7)
|
108
107
|
raabro (~> 1.4)
|
109
|
-
globalid (1.1.0)
|
110
|
-
activesupport (>= 5.0)
|
111
108
|
http (4.4.1)
|
112
109
|
addressable (~> 2.3)
|
113
110
|
http-cookie (~> 1.0)
|
@@ -119,9 +116,6 @@ GEM
|
|
119
116
|
http-form_data (2.3.0)
|
120
117
|
http-parser (1.2.3)
|
121
118
|
ffi-compiler (>= 1.0, < 2.0)
|
122
|
-
httparty (0.21.0)
|
123
|
-
mini_mime (>= 1.0.0)
|
124
|
-
multi_xml (>= 0.5.2)
|
125
119
|
i18n (1.12.0)
|
126
120
|
concurrent-ruby (~> 1.0)
|
127
121
|
ibm_cloud_sdk_core (1.1.3)
|
@@ -139,42 +133,27 @@ GEM
|
|
139
133
|
jmespath (1.6.2)
|
140
134
|
json (2.6.3)
|
141
135
|
jwt (2.2.3)
|
142
|
-
loofah (2.
|
136
|
+
loofah (2.20.0)
|
143
137
|
crass (~> 1.0.2)
|
144
138
|
nokogiri (>= 1.5.9)
|
145
139
|
lucy_dockerunner (0.1.9)
|
146
|
-
|
147
|
-
mini_mime (>= 0.1.1)
|
148
|
-
net-imap
|
149
|
-
net-pop
|
150
|
-
net-smtp
|
140
|
+
method_source (1.0.0)
|
151
141
|
mime-types (3.4.1)
|
152
142
|
mime-types-data (~> 3.2015)
|
153
143
|
mime-types-data (3.2023.0218.1)
|
154
|
-
mini_mime (1.1.2)
|
155
144
|
mini_portile2 (2.8.1)
|
156
145
|
minitest (5.18.0)
|
157
146
|
multi_json (1.15.0)
|
158
|
-
multi_xml (0.6.0)
|
159
147
|
multipart-post (2.3.0)
|
160
|
-
net-imap (0.3.4)
|
161
|
-
date
|
162
|
-
net-protocol
|
163
|
-
net-pop (0.1.2)
|
164
|
-
net-protocol
|
165
|
-
net-protocol (0.2.1)
|
166
|
-
timeout
|
167
|
-
net-smtp (0.3.3)
|
168
|
-
net-protocol
|
169
148
|
netrc (0.11.0)
|
170
|
-
nokogiri (1.14.
|
149
|
+
nokogiri (1.14.3)
|
171
150
|
mini_portile2 (~> 2.8.0)
|
172
151
|
racc (~> 1.4)
|
173
|
-
nokogiri (1.14.
|
152
|
+
nokogiri (1.14.3-x86_64-linux)
|
174
153
|
racc (~> 1.4)
|
175
154
|
opus-ruby (1.0.1)
|
176
155
|
ffi
|
177
|
-
parallel (1.
|
156
|
+
parallel (1.23.0)
|
178
157
|
parser (3.2.2.0)
|
179
158
|
ast (~> 2.4.1)
|
180
159
|
pg (1.4.6)
|
@@ -189,13 +168,20 @@ GEM
|
|
189
168
|
nokogiri (>= 1.6)
|
190
169
|
rails-html-sanitizer (1.5.0)
|
191
170
|
loofah (~> 2.19, >= 2.19.1)
|
171
|
+
railties (7.0.4.3)
|
172
|
+
actionpack (= 7.0.4.3)
|
173
|
+
activesupport (= 7.0.4.3)
|
174
|
+
method_source
|
175
|
+
rake (>= 12.2)
|
176
|
+
thor (~> 1.0)
|
177
|
+
zeitwerk (~> 2.5)
|
192
178
|
rainbow (3.1.1)
|
193
179
|
rake (13.0.6)
|
194
180
|
redis (5.0.6)
|
195
181
|
redis-client (>= 0.9.0)
|
196
|
-
redis-client (0.14.
|
182
|
+
redis-client (0.14.1)
|
197
183
|
connection_pool
|
198
|
-
regexp_parser (2.
|
184
|
+
regexp_parser (2.8.0)
|
199
185
|
rest-client (2.1.0)
|
200
186
|
http-accept (>= 1.7.0, < 2.0)
|
201
187
|
http-cookie (>= 1.0.2, < 2.0)
|
@@ -211,11 +197,19 @@ GEM
|
|
211
197
|
rspec-expectations (3.12.2)
|
212
198
|
diff-lcs (>= 1.2.0, < 2.0)
|
213
199
|
rspec-support (~> 3.12.0)
|
214
|
-
rspec-mocks (3.12.
|
200
|
+
rspec-mocks (3.12.5)
|
215
201
|
diff-lcs (>= 1.2.0, < 2.0)
|
216
202
|
rspec-support (~> 3.12.0)
|
203
|
+
rspec-rails (6.0.1)
|
204
|
+
actionpack (>= 6.1)
|
205
|
+
activesupport (>= 6.1)
|
206
|
+
railties (>= 6.1)
|
207
|
+
rspec-core (~> 3.11)
|
208
|
+
rspec-expectations (~> 3.11)
|
209
|
+
rspec-mocks (~> 3.11)
|
210
|
+
rspec-support (~> 3.11)
|
217
211
|
rspec-support (3.12.0)
|
218
|
-
rubocop (1.
|
212
|
+
rubocop (1.50.2)
|
219
213
|
json (~> 2.3)
|
220
214
|
parallel (~> 1.10)
|
221
215
|
parser (>= 3.2.0.0)
|
@@ -229,20 +223,22 @@ GEM
|
|
229
223
|
parser (>= 3.2.1.0)
|
230
224
|
rubocop-capybara (2.17.1)
|
231
225
|
rubocop (~> 1.41)
|
232
|
-
rubocop-rspec (2.
|
226
|
+
rubocop-rspec (2.20.0)
|
233
227
|
rubocop (~> 1.33)
|
234
228
|
rubocop-capybara (~> 2.17)
|
235
|
-
ruby-openai (3.7.0)
|
236
|
-
httparty (>= 0.18.1)
|
237
229
|
ruby-progressbar (1.13.0)
|
238
230
|
ruby2_keywords (0.0.5)
|
239
231
|
rufus-scheduler (3.8.2)
|
240
232
|
fugit (~> 1.1, >= 1.1.6)
|
241
|
-
|
233
|
+
shoulda-matchers (5.3.0)
|
234
|
+
activesupport (>= 5.2.0)
|
235
|
+
sidekiq (7.0.8)
|
242
236
|
concurrent-ruby (< 2)
|
243
237
|
connection_pool (>= 2.3.0)
|
244
238
|
rack (>= 2.2.4)
|
245
239
|
redis-client (>= 0.11.0)
|
240
|
+
sidekiq-expiring-jobs (0.1.0)
|
241
|
+
sidekiq (>= 6.0)
|
246
242
|
sidekiq-scheduler (5.0.2)
|
247
243
|
rufus-scheduler (~> 3.2)
|
248
244
|
sidekiq (>= 6, < 8)
|
@@ -260,9 +256,9 @@ GEM
|
|
260
256
|
faraday (~> 2.0)
|
261
257
|
faraday-multipart (~> 1.0)
|
262
258
|
virtus (~> 2.0)
|
259
|
+
thor (1.2.1)
|
263
260
|
thread_safe (0.3.6)
|
264
261
|
tilt (2.1.0)
|
265
|
-
timeout (0.3.2)
|
266
262
|
tzinfo (2.0.6)
|
267
263
|
concurrent-ruby (~> 1.0)
|
268
264
|
unf (0.1.4)
|
@@ -281,13 +277,13 @@ GEM
|
|
281
277
|
websocket-driver (0.7.5)
|
282
278
|
websocket-extensions (>= 0.1.0)
|
283
279
|
websocket-extensions (0.1.5)
|
280
|
+
zeitwerk (2.6.7)
|
284
281
|
|
285
282
|
PLATFORMS
|
286
283
|
ruby
|
287
284
|
x86_64-linux
|
288
285
|
|
289
286
|
DEPENDENCIES
|
290
|
-
actionmailer
|
291
287
|
activemodel
|
292
288
|
activerecord
|
293
289
|
activerecord-import
|
@@ -295,17 +291,24 @@ DEPENDENCIES
|
|
295
291
|
awesome_chatgpt_actors
|
296
292
|
aws-sdk-polly
|
297
293
|
bcrypt
|
294
|
+
database_cleaner (~> 2.0)
|
298
295
|
discordrb (~> 3.4)
|
296
|
+
dotenv (~> 2.0)
|
297
|
+
factory_bot_rails (~> 6.0)
|
298
|
+
faker (~> 2.0)
|
299
299
|
faraday
|
300
300
|
ibm_watson
|
301
301
|
lucy_dockerunner
|
302
302
|
pg
|
303
303
|
rake (~> 13.0)
|
304
304
|
redis
|
305
|
-
rspec (~> 3.
|
306
|
-
|
307
|
-
rubocop
|
305
|
+
rspec (~> 3.12)
|
306
|
+
rspec-rails (~> 6.0)
|
307
|
+
rubocop (~> 1.50)
|
308
|
+
rubocop-rspec (~> 2.20)
|
309
|
+
shoulda-matchers (~> 5.3)
|
308
310
|
sidekiq
|
311
|
+
sidekiq-expiring-jobs
|
309
312
|
sidekiq-scheduler
|
310
313
|
simplecov (~> 0.21)
|
311
314
|
streamio-ffmpeg
|
@@ -313,4 +316,4 @@ DEPENDENCIES
|
|
313
316
|
vcr (~> 6.0)
|
314
317
|
|
315
318
|
BUNDLED WITH
|
316
|
-
2.
|
319
|
+
2.4.10
|
data/README.md
CHANGED
@@ -6,15 +6,14 @@
|
|
6
6
|
|
7
7
|
This Ruby gem provides an easy way to initialize a client for Telegram and Discord bots using the ChatGPT API, audio transcription, IBM Cloud Text to Speech, and AWS Polly, creating an assistant that can answer questions in text and voice and have a conversation with the user.
|
8
8
|
|
9
|
-
#### Languages supported currently: en, pt
|
10
|
-
You can contribute by adding your language to the DefaultMessages class in lib/chatgpt_assistant/default_messages.rb. You can also add your language to the list of languages in the README.md file.
|
11
|
-
Pull request from language/YOUR_LANGUAGE to main, remember to name your pull request as "Add YOUR_LANGUAGE support".
|
9
|
+
#### Languages supported currently: en, pt
|
12
10
|
|
13
11
|
Other contributions are welcome too!
|
14
12
|
Remember to give a star to this repo if you like it!
|
15
13
|
## Requirements
|
16
14
|
|
17
|
-
- Ruby > 2.6.0
|
15
|
+
- Ruby > 2.6.0 - for the gem who can create bots projects in your machine
|
16
|
+
- Ruby 3.2.2 - inside the docker contianer or for run the bots in your machine
|
18
17
|
- Docker
|
19
18
|
- Docker Compose
|
20
19
|
- PostgreSQL
|
@@ -63,6 +62,11 @@ Remember to edit docker-compose.prod.yml when deploying to production.
|
|
63
62
|
rake compose:up && sudo docker compose run --rm telegram exe/chatgpt_bot migrate
|
64
63
|
```
|
65
64
|
|
65
|
+
## Install [Awesome Chatgpt Actors](https://github.com/JesusGautamah/awesome-chatgpt-actors)
|
66
|
+
```bash
|
67
|
+
rake chatgpt_actors:install
|
68
|
+
```
|
69
|
+
|
66
70
|
## Usage
|
67
71
|
|
68
72
|
You can start the Docker Compose services required for the gem using the rake tasks provided by the Lucy Dockerunner gem. These tasks include compose:up, compose:down, compose:status, compose:shell, compose:restart, and others listed previously.
|
@@ -87,26 +91,23 @@ After starting the Docker Compose services, you can use the features of the gem
|
|
87
91
|
## Discord Bot Commands
|
88
92
|
|
89
93
|
The discord commands prefix can be changed in the .env file.
|
90
|
-
The default prefix is
|
94
|
+
The default prefix is !!
|
91
95
|
|
92
96
|
- dgpt!start - shows the welcome message
|
93
97
|
- dgpt!help - shows the help message
|
94
|
-
- dgpt!login email:password - logs in the user
|
95
|
-
- dgpt!register email:password - registers a new user
|
98
|
+
- dgpt!login email:password - logs in the user. Remember to use private messages to register or login and share a server with right permissions with the bot to message it.
|
99
|
+
- dgpt!register email:password - registers a new user, email is not verfied yet, so you can use any email, the password is encrypted with bcrypt and stored in the database with salt.
|
96
100
|
- dgpt!list - lists the user created chatbots
|
97
101
|
- dgpt!sl_chat CHAT TITLE - starts a chat with the chatbot with the given title
|
98
102
|
- dgpt!new_chat CHAT TITLE - creates a new chatbot with the given title
|
99
103
|
- dgpt!ask TEXT - sends a text to the chatbot
|
100
|
-
- dgpt!connect - connects the chat bot to the current channel
|
101
|
-
- dgpt!disconnect - disconnects the chat bot from the current channel
|
102
|
-
- dgpt!speak TEXT - sends a text to the chatbot and gets the response in voice
|
103
104
|
|
104
105
|
## Telegram Bot Commands
|
105
106
|
|
106
107
|
- /start - shows the welcome message
|
107
108
|
- /help - shows the help message
|
108
|
-
- login/email:password - logs in the user
|
109
|
-
- register/email:password - registers a new user
|
109
|
+
- login/email:password - logs in the user. Remember to use private messages to register or login.
|
110
|
+
- register/email:password - registers a new user, email is not verfied yet, so you can use any email, the password is encrypted with bcrypt and stored in the database with salt. Remember to use private messages to register or login.
|
110
111
|
- list - lists the user created chatbots
|
111
112
|
- sl_chat/CHAT TITLE - starts a chat with the chatbot with the given title
|
112
113
|
- new_chat/CHAT TITLE - creates a new chatbot with the given title
|
@@ -146,4 +147,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
146
147
|
|
147
148
|
## Code of Conduct
|
148
149
|
|
149
|
-
Everyone interacting in the ChatgptAssistant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/JesusGautamah/chatgpt_assistant/blob/master/CODE_OF_CONDUCT.md).
|
150
|
+
Everyone interacting in the ChatgptAssistant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/JesusGautamah/chatgpt_assistant/blob/master/CODE_OF_CONDUCT.md).
|
data/docker-compose.prod.yml
CHANGED
data/docker-compose.yml
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
version: "3.3"
|
2
2
|
services:
|
3
|
+
redis:
|
4
|
+
image: redis:6-alpine
|
5
|
+
ports:
|
6
|
+
- "6379:6379"
|
7
|
+
volumes:
|
8
|
+
- ./redis_data:/data
|
3
9
|
db:
|
4
10
|
image: postgres:12.2
|
5
11
|
ports:
|
@@ -30,5 +36,17 @@ services:
|
|
30
36
|
- .env
|
31
37
|
depends_on:
|
32
38
|
- db
|
39
|
+
sidekiq:
|
40
|
+
build: .
|
41
|
+
command: bash -c "exe/chatgpt_bot sidekiq"
|
42
|
+
volumes:
|
43
|
+
- .:/chatgpt_assistant
|
44
|
+
environment:
|
45
|
+
POSTGRES_HOST: db
|
46
|
+
env_file:
|
47
|
+
- .env
|
48
|
+
depends_on:
|
49
|
+
- db
|
50
|
+
- redis
|
33
51
|
volumes:
|
34
52
|
postgres:
|
data/exe/chatgpt_bot
CHANGED
@@ -11,6 +11,9 @@ when "telegram"
|
|
11
11
|
ChatgptAssistant::Main.new("telegram").start
|
12
12
|
when "discord"
|
13
13
|
ChatgptAssistant::Main.new("discord").start
|
14
|
+
when "sidekiq"
|
15
|
+
# start sidekiq with the lib/chatgpt_assistant/sidekiq.rb
|
16
|
+
system "bundle exec sidekiq -r ./lib/chatgpt_assistant/sidekiq.rb -C ./lib/chatgpt_assistant/sidekiq.yml"
|
14
17
|
when "migrate"
|
15
18
|
ChatgptAssistant::Config.new.migrate
|
16
19
|
end
|
data/lib/bots/application_bot.rb
CHANGED
@@ -1,21 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# helpers
|
3
4
|
require_relative "helpers/messenger_helper"
|
4
5
|
require_relative "helpers/authentication_helper"
|
5
6
|
require_relative "helpers/visit_helper"
|
6
7
|
require_relative "helpers/audio_helper"
|
7
|
-
require_relative "helpers/logger_action_helper"
|
8
8
|
require_relative "helpers/search_helper"
|
9
9
|
require_relative "helpers/validation_helper"
|
10
10
|
require_relative "helpers/file_helper"
|
11
|
+
|
12
|
+
# jobs
|
13
|
+
require_relative "jobs/register_job"
|
14
|
+
require_relative "jobs/new_chat_job"
|
15
|
+
require_relative "jobs/voice_connect_job"
|
16
|
+
|
17
|
+
# services
|
18
|
+
require_relative "services/register_service"
|
19
|
+
require_relative "services/new_chat_service"
|
20
|
+
require_relative "services/voice_connect_service"
|
21
|
+
|
11
22
|
module ChatgptAssistant
|
12
|
-
# This class is responsible to contain the shared
|
23
|
+
# This class is responsible to contain the shared attributes and methods
|
13
24
|
class ApplicationBot
|
14
25
|
include MessengerHelper
|
15
26
|
include AuthenticationHelper
|
16
27
|
include VisitHelper
|
17
28
|
include AudioHelper
|
18
|
-
include LoggerActionHelper
|
19
29
|
include SearchHelper
|
20
30
|
include ValidationHelper
|
21
31
|
include FileHelper
|
@@ -30,7 +40,7 @@ module ChatgptAssistant
|
|
30
40
|
@discord_prefix = @config.discord_prefix
|
31
41
|
@database = @config.db_connection
|
32
42
|
@mode = @config.mode
|
33
|
-
@
|
43
|
+
@common_messages = default_msg.common_messages
|
34
44
|
@error_messages = default_msg.error_messages
|
35
45
|
@success_messages = default_msg.success_messages
|
36
46
|
@help_messages = default_msg.help_messages
|
@@ -38,7 +48,7 @@ module ChatgptAssistant
|
|
38
48
|
|
39
49
|
attr_reader :openai_api_key, :telegram_token, :database, :default_msg,
|
40
50
|
:mode, :config, :discord_token, :discord_client_id,
|
41
|
-
:discord_prefix, :
|
51
|
+
:discord_prefix, :common_messages, :error_messages, :success_messages,
|
42
52
|
:help_messages
|
43
53
|
attr_accessor :msg, :evnt, :bot, :audio_url, :visitor, :user, :chat, :chat_id
|
44
54
|
|
data/lib/bots/discord_bot.rb
CHANGED
@@ -16,9 +16,6 @@ module ChatgptAssistant
|
|
16
16
|
new_chat_event
|
17
17
|
sl_chat_event
|
18
18
|
ask_event
|
19
|
-
voice_connect_event
|
20
|
-
disconnect_event
|
21
|
-
speak_event
|
22
19
|
private_message_event
|
23
20
|
bot_init
|
24
21
|
end
|
@@ -44,7 +41,7 @@ module ChatgptAssistant
|
|
44
41
|
bot.command :login do |event|
|
45
42
|
@message = event.message.content.split[1]
|
46
43
|
@evnt = event
|
47
|
-
message.nil? ? event.respond(
|
44
|
+
message.nil? ? event.respond(common_messages[:login]) : login_action
|
48
45
|
"OK"
|
49
46
|
end
|
50
47
|
end
|
@@ -53,7 +50,7 @@ module ChatgptAssistant
|
|
53
50
|
bot.command :register do |event|
|
54
51
|
@message = event.message.content.split[1]
|
55
52
|
@evnt = event
|
56
|
-
message.nil? ? event.respond(
|
53
|
+
message.nil? ? event.respond(common_messages[:register]) : register_action
|
57
54
|
"OK"
|
58
55
|
end
|
59
56
|
end
|
@@ -70,9 +67,8 @@ module ChatgptAssistant
|
|
70
67
|
def hist_event
|
71
68
|
bot.command :hist do |event|
|
72
69
|
@evnt = event
|
73
|
-
|
74
|
-
|
75
|
-
@chat = user.chat_by_title(title)
|
70
|
+
@user = find_user(discord_id: event.user.id)
|
71
|
+
@chat = user.current_chat
|
76
72
|
event.respond error_messages[:chat_not_found] if chat.nil? && user
|
77
73
|
hist_action if user && chat
|
78
74
|
"OK"
|
@@ -130,7 +126,7 @@ module ChatgptAssistant
|
|
130
126
|
@chat = Chat.where(id: user.current_chat_id).last
|
131
127
|
voice_connect_checker_action
|
132
128
|
voice_connection_checker_action
|
133
|
-
|
129
|
+
VoiceConnectJob.perform_async(event.user.voice_channel.id)
|
134
130
|
else
|
135
131
|
event.respond error_messages[:user_not_logged_in]
|
136
132
|
end
|
@@ -164,6 +160,7 @@ module ChatgptAssistant
|
|
164
160
|
def private_message_event
|
165
161
|
bot.message do |event|
|
166
162
|
@evnt = event
|
163
|
+
@visitor = discord_visited?(@evnt.user.id)
|
167
164
|
next if discord_next_action?
|
168
165
|
|
169
166
|
@message = event.message.content
|
@@ -18,12 +18,13 @@ module ChatgptAssistant
|
|
18
18
|
|
19
19
|
hash = new_access.password_hash
|
20
20
|
salt = new_access.password_salt
|
21
|
-
valid_password?(password, hash, salt) ? telegram_user_access(
|
21
|
+
valid_password?(password, hash, salt) ? telegram_user_access(visitor_access, new_access) : "wrong password"
|
22
22
|
end
|
23
23
|
|
24
24
|
def telegram_user_access(visitor, new_access)
|
25
25
|
other_access = where_user(telegram_id: visitor.telegram_id)
|
26
|
-
other_access&.each { |access| access.update(telegram_id: nil) }
|
26
|
+
other_access&.each { |access| access.update(telegram_id: nil) } if other_access&.class == Array
|
27
|
+
other_access&.update(telegram_id: nil) if other_access&.class == User
|
27
28
|
new_access.update(telegram_id: visitor.telegram_id)
|
28
29
|
new_access.email
|
29
30
|
end
|
@@ -12,8 +12,8 @@ module ChatgptAssistant
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def start_action
|
15
|
-
send_message
|
16
|
-
send_message
|
15
|
+
send_message common_messages[:start_helper].gsub("register/", "gpt!register ")
|
16
|
+
send_message common_messages[:start_sec_helper].gsub("login/", "gpt!login ")
|
17
17
|
end
|
18
18
|
|
19
19
|
def login_action
|
@@ -46,7 +46,7 @@ module ChatgptAssistant
|
|
46
46
|
|
47
47
|
def list_action
|
48
48
|
chats_title = user.chats.map(&:title)
|
49
|
-
send_message
|
49
|
+
send_message common_messages[:chat_list]
|
50
50
|
send_message chats_title.join("\n")
|
51
51
|
end
|
52
52
|
|
@@ -95,7 +95,7 @@ module ChatgptAssistant
|
|
95
95
|
return send_message "chat title already exists" if user.chat_by_title(title)
|
96
96
|
|
97
97
|
actor_name = actors[mode.to_i - 1] if mode
|
98
|
-
actor = AwesomeChatgptActors::Actor.new(
|
98
|
+
actor = AwesomeChatgptActors::Actor.new(role: actor_name, language: config.language) if actor_name
|
99
99
|
chat = Chat.new(user_id: user.id, status: 0, title: title, actor: actor_name, prompt: actor.prompt) if actor
|
100
100
|
chat = Chat.new(user_id: user.id, status: 0, title: title) unless actor
|
101
101
|
return send_message "Something went wrong", msg.chat.id unless chat
|