slack-smart-bot 1.15.1 → 1.15.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -1
- data/img/chat_gpt_attach_image.png +0 -0
- data/lib/slack/smart-bot/ai/open_ai/models.rb +19 -10
- data/lib/slack/smart-bot/ai/open_ai/send_gpt_chat.rb +14 -10
- data/lib/slack/smart-bot/comm/dont_understand.rb +23 -6
- data/lib/slack/smart-bot/comm/get_user_info.rb +9 -10
- data/lib/slack/smart-bot/comm/respond.rb +56 -28
- data/lib/slack/smart-bot/comm/send_file.rb +17 -6
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat.rb +885 -129
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_add_collaborator.rb +3 -3
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_copy_session.rb +132 -15
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_delete_session.rb +1 -1
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_get_prompts.rb +50 -12
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_list_sessions.rb +99 -34
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_share_session.rb +12 -2
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_use_model.rb +36 -25
- data/lib/slack/smart-bot/commands/general/bot_help.rb +29 -24
- data/lib/slack/smart-bot/commands/general/poster.rb +0 -1
- data/lib/slack/smart-bot/commands/general/see_announcements.rb +1 -1
- data/lib/slack/smart-bot/commands/general/summarize.rb +22 -8
- data/lib/slack/smart-bot/commands/general_bot_commands.rb +156 -55
- data/lib/slack/smart-bot/commands/on_bot/general/bot_stats.rb +13 -11
- data/lib/slack/smart-bot/commands/on_extended/bot_rules.rb +21 -17
- data/lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb +2 -2
- data/lib/slack/smart-bot/commands.rb +19 -19
- data/lib/slack/smart-bot/process_first.rb +38 -35
- data/lib/slack/smart-bot/treat_message.rb +57 -56
- data/lib/slack/smart-bot/utils/download_http_content.rb +91 -0
- data/lib/slack/smart-bot/utils/get_authorizations.rb +41 -0
- data/lib/slack/smart-bot/utils/get_keywords.rb +33 -0
- data/lib/slack/smart-bot/utils/get_openai_sessions.rb +46 -6
- data/lib/slack/smart-bot/utils/get_teams.rb +9 -1
- data/lib/slack/smart-bot/utils/save_stats.rb +13 -5
- data/lib/slack/smart-bot/utils/transform_to_slack_markdown.rb +36 -0
- data/lib/slack/smart-bot/utils/update_openai_sessions.rb +9 -4
- data/lib/slack/smart-bot/utils.rb +48 -44
- data/lib/slack-smart-bot.rb +10 -9
- data/whats_new.txt +27 -1
- metadata +63 -2
@@ -23,17 +23,22 @@ class SlackSmartBot
|
|
23
23
|
file.flock(File::LOCK_UN)
|
24
24
|
}
|
25
25
|
@datetime_open_ai_file[file_name] = File.mtime(file_name)
|
26
|
-
if session_name != ''
|
26
|
+
if session_name.to_s != ''
|
27
27
|
if !@open_ai[team_id_user][:chat_gpt][:sessions].key?(session_name) #delete file if session is not longer available
|
28
28
|
if File.exist?(File.join(config.path, "openai/#{team_id}", "#{user_name}/session_#{session_name}.txt"))
|
29
29
|
File.delete(File.join(config.path, "openai/#{team_id}", "#{user_name}/session_#{session_name}.txt"))
|
30
30
|
end
|
31
31
|
else
|
32
32
|
file_name = File.join(config.path, "openai/#{team_id}", "#{user_name}/session_#{session_name}.txt")
|
33
|
-
|
33
|
+
content_txt = ""
|
34
|
+
content = []
|
35
|
+
@ai_gpt[team_id_user][session_name].each do |line|
|
36
|
+
content << line.to_json
|
37
|
+
end
|
38
|
+
content_txt = content.join("\n").force_encoding("UTF-8")
|
34
39
|
File.open(file_name, 'w') {|file|
|
35
|
-
|
36
|
-
file.write(Utils::Encryption.encrypt(
|
40
|
+
file.flock(File::LOCK_EX)
|
41
|
+
file.write(Utils::Encryption.encrypt(content_txt, config))
|
37
42
|
file.flock(File::LOCK_UN)
|
38
43
|
}
|
39
44
|
end
|
@@ -1,44 +1,48 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
14
|
-
require_relative
|
15
|
-
require_relative
|
16
|
-
require_relative
|
17
|
-
require_relative
|
18
|
-
require_relative
|
19
|
-
require_relative
|
20
|
-
require_relative
|
21
|
-
require_relative
|
22
|
-
require_relative
|
23
|
-
require_relative
|
24
|
-
require_relative
|
25
|
-
require_relative
|
26
|
-
require_relative
|
27
|
-
require_relative
|
28
|
-
require_relative
|
29
|
-
require_relative
|
30
|
-
require_relative
|
31
|
-
require_relative
|
32
|
-
require_relative
|
33
|
-
require_relative
|
34
|
-
require_relative
|
35
|
-
require_relative
|
36
|
-
require_relative
|
37
|
-
require_relative
|
38
|
-
require_relative
|
39
|
-
require_relative
|
40
|
-
require_relative
|
41
|
-
require_relative
|
42
|
-
require_relative
|
43
|
-
require_relative
|
44
|
-
require_relative
|
1
|
+
require_relative "utils/build_help"
|
2
|
+
require_relative "utils/create_routine_thread"
|
3
|
+
require_relative "utils/get_bots_created"
|
4
|
+
require_relative "utils/get_channels_name_and_id"
|
5
|
+
require_relative "utils/get_help"
|
6
|
+
require_relative "utils/get_routines"
|
7
|
+
require_relative "utils/get_shares"
|
8
|
+
require_relative "utils/get_rules_imported"
|
9
|
+
require_relative "utils/remove_hash_keys"
|
10
|
+
require_relative "utils/update_bots_file"
|
11
|
+
require_relative "utils/update_routines"
|
12
|
+
require_relative "utils/update_rules_imported"
|
13
|
+
require_relative "utils/update_shortcuts_file"
|
14
|
+
require_relative "utils/save_stats"
|
15
|
+
require_relative "utils/get_repls"
|
16
|
+
require_relative "utils/update_repls"
|
17
|
+
require_relative "utils/answer"
|
18
|
+
require_relative "utils/answer_delete"
|
19
|
+
require_relative "utils/has_access"
|
20
|
+
require_relative "utils/save_status"
|
21
|
+
require_relative "utils/get_admins_channels"
|
22
|
+
require_relative "utils/update_admins_channels"
|
23
|
+
require_relative "utils/is_admin"
|
24
|
+
require_relative "utils/get_access_channels"
|
25
|
+
require_relative "utils/update_access_channels"
|
26
|
+
require_relative "utils/get_command_ids"
|
27
|
+
require_relative "utils/get_teams"
|
28
|
+
require_relative "utils/get_vacations"
|
29
|
+
require_relative "utils/get_personal_settings"
|
30
|
+
require_relative "utils/update_personal_settings"
|
31
|
+
require_relative "utils/update_teams"
|
32
|
+
require_relative "utils/update_vacations"
|
33
|
+
require_relative "utils/check_vacations"
|
34
|
+
require_relative "utils/display_calendar"
|
35
|
+
require_relative "utils/encryption/encryption_get_key_iv"
|
36
|
+
require_relative "utils/encryption/encrypt"
|
37
|
+
require_relative "utils/encryption/decrypt"
|
38
|
+
require_relative "utils/get_team_members"
|
39
|
+
require_relative "utils/get_openai_sessions"
|
40
|
+
require_relative "utils/update_openai_sessions"
|
41
|
+
require_relative "utils/local_time"
|
42
|
+
require_relative "utils/get_countries_candelarific"
|
43
|
+
require_relative "utils/upgrade_to_use_team_ids"
|
44
|
+
require_relative "utils/find_user"
|
45
|
+
require_relative "utils/transform_to_slack_markdown"
|
46
|
+
require_relative "utils/download_http_content"
|
47
|
+
require_relative "utils/get_authorizations"
|
48
|
+
require_relative "utils/get_keywords"
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -13,6 +13,8 @@ require "nice_hash"
|
|
13
13
|
require "cgi"
|
14
14
|
require "yaml"
|
15
15
|
require "nokogiri"
|
16
|
+
require "tiktoken_ruby"
|
17
|
+
require "engtagger"
|
16
18
|
|
17
19
|
require_relative "slack/smart-bot/config"
|
18
20
|
require_relative "slack/smart-bot/comm"
|
@@ -126,13 +128,13 @@ class SlackSmartBot
|
|
126
128
|
config.status_init = ARGV[3].to_sym
|
127
129
|
end
|
128
130
|
if config.team_id_admins.size != config.admins.size and !config.admins.empty?
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
131
|
+
config.admins.each do |name|
|
132
|
+
if name.match?(/^[A-Z0-9]{7,11}_/)
|
133
|
+
config.team_id_admins << name
|
134
|
+
else
|
135
|
+
config.team_id_admins << "#{config.team_id}_#{name}"
|
135
136
|
end
|
137
|
+
end
|
136
138
|
end
|
137
139
|
config.team_id_admins.uniq!
|
138
140
|
config.admins.uniq!
|
@@ -149,7 +151,7 @@ class SlackSmartBot
|
|
149
151
|
end
|
150
152
|
|
151
153
|
if (!config.masters.is_a?(Array) or !config.team_id_masters.is_a?(Array)) or
|
152
|
-
|
154
|
+
(config.masters + config.team_id_masters).empty?
|
153
155
|
message = "You need to supply a masters array on the settings containing the user names of the master admins, for example: [peter]. key: :masters"
|
154
156
|
message += " or a team_id_masters array containing the team_id and user names of the master admins, for example: [TJDFJKD34_peter]. key: :team_id_masters"
|
155
157
|
abort message
|
@@ -306,7 +308,7 @@ class SlackSmartBot
|
|
306
308
|
@ldap = nil
|
307
309
|
begin
|
308
310
|
if config.ldap.key?(:host) and config.ldap[:host].to_s != ""
|
309
|
-
require
|
311
|
+
require "net/ldap"
|
310
312
|
if config.ldap.key?(:auth) and config.ldap[:auth].key?(:user) and config.ldap[:auth][:user].to_s != ""
|
311
313
|
@ldap = Net::LDAP.new(host: config.ldap.host, port: config.ldap.port, auth: config.ldap.auth)
|
312
314
|
else
|
@@ -401,7 +403,6 @@ class SlackSmartBot
|
|
401
403
|
end
|
402
404
|
@admin_users_id.uniq!
|
403
405
|
@master_admin_users_id.uniq!
|
404
|
-
|
405
406
|
rescue Slack::Web::Api::Errors::TooManyRequestsError
|
406
407
|
@logger.fatal "TooManyRequestsError"
|
407
408
|
save_status :off, :TooManyRequestsError, "TooManyRequestsError please re run the bot and be sure of executing first: killall ruby"
|
data/whats_new.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
*Version 1.15.
|
1
|
+
*Version 1.15.25* Released 2024-Nov-15
|
2
2
|
|
3
3
|
*For General users*
|
4
4
|
- OpenAI adds specific hosts and access tokens for services. (<https://github.com/MarioRuiz/slack-smart-bot/issues/107|#107>).
|
@@ -21,6 +21,21 @@
|
|
21
21
|
- Call `get smartbot readme` to get the README for SmartBot. (<https://github.com/MarioRuiz/slack-smart-bot/issues/128|#128>)
|
22
22
|
- You can call `<bot help` or `<bot rules`. SmartBot will send a Markdown file with extended help commands. Open the file in a new window. You can install this extension in Google Chrome to view it: https://chromewebstore.google.com/detail/medapdbncneneejhbgcjceippjlfkmkg (<https://github.com/MarioRuiz/slack-smart-bot/issues/129|#129>)
|
23
23
|
- It is possible to specify authorizations tokens for any website you want to reach the content using ChatGPT command. When adding to your prompt !URL SmartBot will verify if the domain specified have set an authorization header and add it. To add personal authorization tokens you can do it calling on a DM the commands: `add personal settings authorizations.example.host example.com`, `add personal settings authorizations.example.authorization Xdddj33a_SDFBBBS33Ab` (<https://github.com/MarioRuiz/slack-smart-bot/issues/130|#130>)
|
24
|
+
- ChatGPT accepts Google Drive links. In case PDF, Docx, or text files (json, yaml, text...) will extract the content and will be added to the prompt. Use: `?? PROMPT !URL1 !URL2 !URL99`
|
25
|
+
- ChatGPT accepts attached images.
|
26
|
+
- ChatGPT output is nicer since SmartBot will automatically translate general Markdown to Slack Markdown.
|
27
|
+
- Now when on a ChatGPT session if you want to delete the last ChatGPT response and send again last prompt, you can use `resend prompt`.
|
28
|
+
- You can set the context of your ChatGPT session: `set context CONTEXT`. Example: `set context You are a funny comedian who tells dad jokes. The output should be in JSON format.`
|
29
|
+
- You can remove all prompts from a given session by using `chatgpt clean SESSION_NAME`
|
30
|
+
- Add static content to your session by using `add static content URL1 URL99`.
|
31
|
+
- Add live content to your session by using `add live content URL1 URL99`. The content will be downloaded and added to your session every time you send a new prompt. See also: `delete live content URL1 URL99`
|
32
|
+
- You can add authorizations on a specific ChatGPT session: `add authorization HOST HEADER VALUE`, for example: `add authorization api.example.com Authorization Bearer 123456`.
|
33
|
+
Remember to use a DM with SmartBot to keep these values secret.
|
34
|
+
If you share this session as public or for a specific channel, users will be able to send prompts for that session using your authorizations but they won't be able to see the auth values or copy those auth to a new chatgpt session.
|
35
|
+
- It is possible to use a session that is public, private or shared with a channel as a temporary session: `?? use SESSION_NAME PROMPT`. For example: `?? use lunch What's for Thursday?`
|
36
|
+
- You can add collaborators on temporary ChatGPT sessions
|
37
|
+
- Add messages from a channel to your session by using `add history #CHANNEL_NAME`.
|
38
|
+
- When you send a wrong command, SmartBot ChatGPT will tell you which commands could be the ones you wanted to call.
|
24
39
|
|
25
40
|
*For Admin users*
|
26
41
|
- ChatGPT now supports Azure. (<https://github.com/MarioRuiz/slack-smart-bot/issues/109|#109>)
|
@@ -30,6 +45,17 @@
|
|
30
45
|
- It is possible now to use LLM proxy for ChatGPT and also specify a concrete end point to get the models.
|
31
46
|
- Added LDAP settings in config. (<https://github.com/MarioRuiz/slack-smart-bot/issues/131|#131>)
|
32
47
|
- Added authorizations settings in config. (<https://github.com/MarioRuiz/slack-smart-bot/issues/130|#130>)
|
48
|
+
- Doc folders can be added by admins for specific chatgpt sessions. SmartBot will filter those docs depending on the prompt and attach them along with the prompt.
|
49
|
+
Put all docs as text files on `./openai/TEAM_ID/USER_NAME/SESSION_NAME/docs_folder`.
|
50
|
+
For the documents to be filtered add them to `filter` subfolder under `docs_folder`.
|
51
|
+
For the documents to be added always to the prompts, add them to `include` subfolder under `docs_folder`.
|
52
|
+
Inside those subfolders you can organize the documents the way you want.
|
53
|
+
- You can add a file named restricted_models.yaml on ./openai folder supplying the models and users that will have access to specific models.
|
54
|
+
Example of content:
|
55
|
+
o1-mini: [rmario, peter]
|
56
|
+
o1-preview: [rmario]
|
57
|
+
|
58
|
+
|
33
59
|
|
34
60
|
------------------------------
|
35
61
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-smart-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|
@@ -214,6 +214,62 @@ dependencies:
|
|
214
214
|
- - "~>"
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '1'
|
217
|
+
- !ruby/object:Gem::Dependency
|
218
|
+
name: pdf-reader
|
219
|
+
requirement: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - "~>"
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '2.12'
|
224
|
+
type: :runtime
|
225
|
+
prerelease: false
|
226
|
+
version_requirements: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - "~>"
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '2.12'
|
231
|
+
- !ruby/object:Gem::Dependency
|
232
|
+
name: docx
|
233
|
+
requirement: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - "~>"
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0.8'
|
238
|
+
type: :runtime
|
239
|
+
prerelease: false
|
240
|
+
version_requirements: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - "~>"
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0.8'
|
245
|
+
- !ruby/object:Gem::Dependency
|
246
|
+
name: tiktoken_ruby
|
247
|
+
requirement: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - "~>"
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: 0.0.7
|
252
|
+
type: :runtime
|
253
|
+
prerelease: false
|
254
|
+
version_requirements: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - "~>"
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: 0.0.7
|
259
|
+
- !ruby/object:Gem::Dependency
|
260
|
+
name: engtagger
|
261
|
+
requirement: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - "~>"
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: '0.4'
|
266
|
+
type: :runtime
|
267
|
+
prerelease: false
|
268
|
+
version_requirements: !ruby/object:Gem::Requirement
|
269
|
+
requirements:
|
270
|
+
- - "~>"
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: '0.4'
|
217
273
|
- !ruby/object:Gem::Dependency
|
218
274
|
name: rspec
|
219
275
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,6 +300,7 @@ files:
|
|
244
300
|
- LICENSE
|
245
301
|
- README.md
|
246
302
|
- img/chat_gpt.png
|
303
|
+
- img/chat_gpt_attach_image.png
|
247
304
|
- img/chat_gpt_session.png
|
248
305
|
- img/chat_gpt_share.png
|
249
306
|
- img/command_add_sc.png
|
@@ -417,17 +474,20 @@ files:
|
|
417
474
|
- lib/slack/smart-bot/utils/check_vacations.rb
|
418
475
|
- lib/slack/smart-bot/utils/create_routine_thread.rb
|
419
476
|
- lib/slack/smart-bot/utils/display_calendar.rb
|
477
|
+
- lib/slack/smart-bot/utils/download_http_content.rb
|
420
478
|
- lib/slack/smart-bot/utils/encryption/decrypt.rb
|
421
479
|
- lib/slack/smart-bot/utils/encryption/encrypt.rb
|
422
480
|
- lib/slack/smart-bot/utils/encryption/encryption_get_key_iv.rb
|
423
481
|
- lib/slack/smart-bot/utils/find_user.rb
|
424
482
|
- lib/slack/smart-bot/utils/get_access_channels.rb
|
425
483
|
- lib/slack/smart-bot/utils/get_admins_channels.rb
|
484
|
+
- lib/slack/smart-bot/utils/get_authorizations.rb
|
426
485
|
- lib/slack/smart-bot/utils/get_bots_created.rb
|
427
486
|
- lib/slack/smart-bot/utils/get_channels_name_and_id.rb
|
428
487
|
- lib/slack/smart-bot/utils/get_command_ids.rb
|
429
488
|
- lib/slack/smart-bot/utils/get_countries_candelarific.rb
|
430
489
|
- lib/slack/smart-bot/utils/get_help.rb
|
490
|
+
- lib/slack/smart-bot/utils/get_keywords.rb
|
431
491
|
- lib/slack/smart-bot/utils/get_openai_sessions.rb
|
432
492
|
- lib/slack/smart-bot/utils/get_personal_settings.rb
|
433
493
|
- lib/slack/smart-bot/utils/get_repls.rb
|
@@ -443,6 +503,7 @@ files:
|
|
443
503
|
- lib/slack/smart-bot/utils/remove_hash_keys.rb
|
444
504
|
- lib/slack/smart-bot/utils/save_stats.rb
|
445
505
|
- lib/slack/smart-bot/utils/save_status.rb
|
506
|
+
- lib/slack/smart-bot/utils/transform_to_slack_markdown.rb
|
446
507
|
- lib/slack/smart-bot/utils/update_access_channels.rb
|
447
508
|
- lib/slack/smart-bot/utils/update_admins_channels.rb
|
448
509
|
- lib/slack/smart-bot/utils/update_bots_file.rb
|