chatgpt_assistant 0.1.3 → 0.1.4
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 +4 -4
- data/.rubocop.yml +1 -0
- data/Dockerfile +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -6
- data/SECURITY.md +15 -0
- data/exe/chatgpt_bot +1 -1
- data/lib/bots/discord_bot.rb +6 -6
- data/lib/bots/helpers/discord_helper.rb +1 -1
- data/lib/bots/helpers/messenger_helper.rb +4 -2
- data/lib/chatgpt_assistant/audio_recognition.rb +4 -6
- data/lib/chatgpt_assistant/audio_synthesis.rb +2 -6
- data/lib/chatgpt_assistant/config.rb +17 -17
- data/lib/chatgpt_assistant/migrations.rb +1 -1
- data/lib/chatgpt_assistant/models.rb +0 -2
- data/lib/chatgpt_assistant/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23b30dcd5724b3978f30a1ac8ebabce7c47b2013302282248a9a10e67904d631
|
4
|
+
data.tar.gz: a4cb01e4548897b34152a63ca600eb1b9fa72c3a2131dbb950b95cb998328cc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7d4daf964b6566c3a703b971090924b20d3d818b886533deae985eeac719860c40dfefef63983069f57cb991b4e02611e0f86f98fb7fdff9d288287f222513
|
7
|
+
data.tar.gz: 228a9a7799d596c5da4e53e0a9f8a505587f15f99af4928fef1824a88449a7e0febc64289406c29f2c67a038440fb19e054ccb2a389eec6831be041031af5bf6
|
data/.rubocop.yml
CHANGED
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -167,7 +167,7 @@ GEM
|
|
167
167
|
opus-ruby (1.0.1)
|
168
168
|
ffi
|
169
169
|
parallel (1.22.1)
|
170
|
-
parser (3.2.
|
170
|
+
parser (3.2.2.0)
|
171
171
|
ast (~> 2.4.1)
|
172
172
|
pg (1.4.6)
|
173
173
|
public_suffix (5.0.1)
|
@@ -207,24 +207,24 @@ GEM
|
|
207
207
|
diff-lcs (>= 1.2.0, < 2.0)
|
208
208
|
rspec-support (~> 3.12.0)
|
209
209
|
rspec-support (3.12.0)
|
210
|
-
rubocop (1.
|
210
|
+
rubocop (1.49.0)
|
211
211
|
json (~> 2.3)
|
212
212
|
parallel (~> 1.10)
|
213
213
|
parser (>= 3.2.0.0)
|
214
214
|
rainbow (>= 2.2.2, < 4.0)
|
215
215
|
regexp_parser (>= 1.8, < 3.0)
|
216
216
|
rexml (>= 3.2.5, < 4.0)
|
217
|
-
rubocop-ast (>= 1.
|
217
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
218
218
|
ruby-progressbar (~> 1.7)
|
219
219
|
unicode-display_width (>= 2.4.0, < 3.0)
|
220
|
-
rubocop-ast (1.
|
220
|
+
rubocop-ast (1.28.0)
|
221
221
|
parser (>= 3.2.1.0)
|
222
222
|
rubocop-capybara (2.17.1)
|
223
223
|
rubocop (~> 1.41)
|
224
224
|
rubocop-rspec (2.19.0)
|
225
225
|
rubocop (~> 1.33)
|
226
226
|
rubocop-capybara (~> 2.17)
|
227
|
-
ruby-progressbar (1.
|
227
|
+
ruby-progressbar (1.13.0)
|
228
228
|
ruby2_keywords (0.0.5)
|
229
229
|
rufus-scheduler (3.8.2)
|
230
230
|
fugit (~> 1.1, >= 1.1.6)
|
@@ -292,7 +292,7 @@ DEPENDENCIES
|
|
292
292
|
rake (~> 13.0)
|
293
293
|
redis
|
294
294
|
rspec (~> 3.0)
|
295
|
-
rubocop (~> 1.
|
295
|
+
rubocop (~> 1.49)
|
296
296
|
rubocop-rspec (~> 2.4)
|
297
297
|
sidekiq
|
298
298
|
sidekiq-scheduler
|
data/SECURITY.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
| Version | Supported |
|
6
|
+
| ------- | ------------------ |
|
7
|
+
| 0.1.4 | :white_check_mark: |
|
8
|
+
| 0.1.3 | :x: |
|
9
|
+
| 0.1.2 | :x: |
|
10
|
+
| 0.1.1 | :x: |
|
11
|
+
| 0.1.0 | :x: |
|
12
|
+
|
13
|
+
## Reporting a Vulnerability
|
14
|
+
|
15
|
+
You can open an security vulnerability issue
|
data/exe/chatgpt_bot
CHANGED
data/lib/bots/discord_bot.rb
CHANGED
@@ -40,7 +40,7 @@ module ChatgptAssistant
|
|
40
40
|
|
41
41
|
def login_event
|
42
42
|
bot.command :login do |event|
|
43
|
-
@message = event.message.content.split
|
43
|
+
@message = event.message.content.split[1]
|
44
44
|
@evnt = event
|
45
45
|
message.nil? ? event.respond(commom_messages[:login]) : login_action
|
46
46
|
end
|
@@ -48,7 +48,7 @@ module ChatgptAssistant
|
|
48
48
|
|
49
49
|
def register_event
|
50
50
|
bot.command :register do |event|
|
51
|
-
@message = event.message.content.split
|
51
|
+
@message = event.message.content.split[1]
|
52
52
|
@evnt = event
|
53
53
|
message.nil? ? event.respond(commom_messages[:register]) : register_action
|
54
54
|
end
|
@@ -68,7 +68,7 @@ module ChatgptAssistant
|
|
68
68
|
bot.command :hist do |event|
|
69
69
|
@evnt = event
|
70
70
|
event.respond error_messages[:user_not_logged_in] if user.nil?
|
71
|
-
title = event.message.content.split
|
71
|
+
title = event.message.content.split[1..].join(" ")
|
72
72
|
@chat = user.chat_by_title(title)
|
73
73
|
event.respond error_messages[:chat_not_found] if chat.nil? && user
|
74
74
|
hist_action if user && chat
|
@@ -94,7 +94,7 @@ module ChatgptAssistant
|
|
94
94
|
def sl_chat_event
|
95
95
|
bot.command :sl_chat do |event|
|
96
96
|
@evnt = event
|
97
|
-
chat_to_select = event.message.content.split
|
97
|
+
chat_to_select = event.message.content.split[1..].join(" ")
|
98
98
|
@user = find_user(discord_id: event.user.id)
|
99
99
|
event.respond error_messages[:user_not_logged_in] if user.nil?
|
100
100
|
|
@@ -105,7 +105,7 @@ module ChatgptAssistant
|
|
105
105
|
def ask_event
|
106
106
|
bot.command :ask do |event|
|
107
107
|
@evnt = event
|
108
|
-
@message = event.message.content.split
|
108
|
+
@message = event.message.content.split[1..].join(" ")
|
109
109
|
@user = find_user(discord_id: event.user.id)
|
110
110
|
event.respond error_messages[:user_not_logged_in] if user.nil?
|
111
111
|
ask_action if user
|
@@ -135,7 +135,7 @@ module ChatgptAssistant
|
|
135
135
|
def speak_event
|
136
136
|
bot.command :speak do |event|
|
137
137
|
@evnt = event
|
138
|
-
@message = event.message.content.split
|
138
|
+
@message = event.message.content.split[1..].join(" ")
|
139
139
|
@user = find_user(discord_id: event.user.id)
|
140
140
|
@chat = user.current_chat
|
141
141
|
speak_connect_checker_action
|
@@ -76,7 +76,7 @@ module ChatgptAssistant
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def create_chat_action
|
79
|
-
chat_title = evnt.message.content.split
|
79
|
+
chat_title = evnt.message.content.split[1..].join(" ")
|
80
80
|
@chat = Chat.new(user_id: user.id, title: chat_title, status: 0)
|
81
81
|
chat.save ? respond_with_success : send_message(error_messages[:chat_creation])
|
82
82
|
end
|
@@ -30,11 +30,13 @@ module ChatgptAssistant
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def telegram_send_message(text, chat_id)
|
33
|
-
|
33
|
+
messages = parse_message(text, 4096)
|
34
|
+
messages.each { |m| bot.api.send_message(chat_id: chat_id, text: m) }
|
34
35
|
end
|
35
36
|
|
36
37
|
def discord_send_message(text)
|
37
|
-
|
38
|
+
messages = parse_message(text, 2000)
|
39
|
+
messages.each { |m| evnt.respond m }
|
38
40
|
end
|
39
41
|
|
40
42
|
def discord_help_message
|
@@ -29,9 +29,7 @@ module ChatgptAssistant
|
|
29
29
|
|
30
30
|
def download_audio(audio_url)
|
31
31
|
audio_conn = Faraday.new(url: audio_url)
|
32
|
-
File.
|
33
|
-
file.write(audio_conn.get.body)
|
34
|
-
end
|
32
|
+
File.binwrite(dl_file_name, audio_conn.get.body)
|
35
33
|
FFMPEG::Movie.new(dl_file_name).transcode(file_name)
|
36
34
|
File.delete(dl_file_name)
|
37
35
|
end
|
@@ -39,14 +37,14 @@ module ChatgptAssistant
|
|
39
37
|
def header
|
40
38
|
{
|
41
39
|
"Content-Type": "multipart/form-data",
|
42
|
-
|
40
|
+
Authorization: "Bearer #{openai_api_key}"
|
43
41
|
}
|
44
42
|
end
|
45
43
|
|
46
44
|
def payload
|
47
45
|
{
|
48
|
-
|
49
|
-
|
46
|
+
file: Faraday::UploadIO.new(file_name, "audio/mp3"),
|
47
|
+
model: "whisper-1"
|
50
48
|
}
|
51
49
|
end
|
52
50
|
|
@@ -61,9 +61,7 @@ module ChatgptAssistant
|
|
61
61
|
engine: "neural"
|
62
62
|
)
|
63
63
|
|
64
|
-
File.
|
65
|
-
file.write(response.audio_stream.read)
|
66
|
-
end
|
64
|
+
File.binwrite("voice/aws-#{time}.mp3", response.audio_stream.read)
|
67
65
|
"voice/aws-#{time}.mp3"
|
68
66
|
end
|
69
67
|
|
@@ -86,9 +84,7 @@ module ChatgptAssistant
|
|
86
84
|
voice: voice
|
87
85
|
).result
|
88
86
|
|
89
|
-
File.
|
90
|
-
audio_file.write(audio)
|
91
|
-
end
|
87
|
+
File.binwrite("voice/ibm-#{time}.mp3", audio)
|
92
88
|
"voice/ibm-#{time}.mp3"
|
93
89
|
end
|
94
90
|
|
@@ -9,23 +9,23 @@ module ChatgptAssistant
|
|
9
9
|
# This class is responsible for the configuration of the Chatgpt Assistant
|
10
10
|
class Config
|
11
11
|
def initialize
|
12
|
-
@env_type = ENV
|
13
|
-
@language = ENV
|
14
|
-
@mode = ENV
|
15
|
-
@database_host = ENV
|
16
|
-
@database_name = ENV
|
17
|
-
@database_username = ENV
|
18
|
-
@database_password = ENV
|
19
|
-
@openai_api_key = ENV
|
20
|
-
@telegram_token = ENV
|
21
|
-
@discord_token = ENV
|
22
|
-
@discord_client_id = ENV
|
23
|
-
@ibm_api_key = ENV
|
24
|
-
@ibm_url = ENV
|
25
|
-
@aws_access_key_id = ENV
|
26
|
-
@aws_secret_access_key = ENV
|
27
|
-
@aws_region = ENV
|
28
|
-
@discord_prefix = ENV
|
12
|
+
@env_type = ENV.fetch("ENV_TYPE", nil)
|
13
|
+
@language = ENV.fetch("LANGUAGE", nil)
|
14
|
+
@mode = ENV.fetch("MODE", nil)
|
15
|
+
@database_host = ENV.fetch("POSTGRES_HOST", nil)
|
16
|
+
@database_name = ENV.fetch("POSTGRES_DB", nil)
|
17
|
+
@database_username = ENV.fetch("POSTGRES_USER", nil)
|
18
|
+
@database_password = ENV.fetch("POSTGRES_PASSWORD", nil)
|
19
|
+
@openai_api_key = ENV.fetch("OPENAI_API_KEY", nil)
|
20
|
+
@telegram_token = ENV.fetch("TELEGRAM_TOKEN", nil)
|
21
|
+
@discord_token = ENV.fetch("DISCORD_TOKEN", nil)
|
22
|
+
@discord_client_id = ENV.fetch("DISCORD_CLIENT_ID", nil)
|
23
|
+
@ibm_api_key = ENV.fetch("IBM_API_KEY", nil)
|
24
|
+
@ibm_url = ENV.fetch("IBM_URL", nil)
|
25
|
+
@aws_access_key_id = ENV.fetch("AWS_ACCESS_KEY_ID", nil)
|
26
|
+
@aws_secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY", nil)
|
27
|
+
@aws_region = ENV.fetch("AWS_REGION", nil)
|
28
|
+
@discord_prefix = ENV.fetch("DISCORD_PREFIX", nil)
|
29
29
|
end
|
30
30
|
|
31
31
|
attr_reader :openai_api_key, :telegram_token, :discord_token, :ibm_api_key, :ibm_url,
|
@@ -13,7 +13,7 @@ class VisitorMigration < ActiveRecord::Migration[5.2]
|
|
13
13
|
t.string :discord_id, limit: 100
|
14
14
|
t.integer :platform, null: false, default: 0
|
15
15
|
t.string :name, null: false
|
16
|
-
t.integer :current_user_id,
|
16
|
+
t.integer :current_user_id, default: 0
|
17
17
|
t.timestamps
|
18
18
|
end
|
19
19
|
end
|
@@ -7,8 +7,6 @@ class Visitor < ActiveRecord::Base
|
|
7
7
|
has_many :visitor_actions
|
8
8
|
# has_one :tel_user, foreign_key: "telegram_id", class_name: "User"
|
9
9
|
# has_one :dis_user, foreign_key: "discord_id", class_name: "User"
|
10
|
-
validates :telegram_id, uniqueness: true
|
11
|
-
validates :discord_id, uniqueness: true
|
12
10
|
validates :name, presence: true
|
13
11
|
validates :platform, presence: true
|
14
12
|
enum platform: { telegram: 0, discord: 1 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatgpt_assistant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JesusGautamah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
This gem has the intention to facilitate the creation of chatbots with Chatgpt,
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- LICENSE.txt
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
|
+
- SECURITY.md
|
40
41
|
- deploy.sh
|
41
42
|
- deploy_and_build.sh
|
42
43
|
- docker-compose.prod.yml
|
@@ -79,6 +80,7 @@ metadata:
|
|
79
80
|
homepage_uri: https://github.com/JesusGautamah/chatgpt_assistant
|
80
81
|
source_code_uri: https://github.com/JesusGautamah/chatgpt_assistant.git
|
81
82
|
changelog_uri: https://github.com/JesusGautamah/chatgpt_assistant/releases
|
83
|
+
rubygems_mfa_required: 'true'
|
82
84
|
post_install_message:
|
83
85
|
rdoc_options: []
|
84
86
|
require_paths:
|