2023-02-17 11:33:47 -03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2023-02-22 20:46:53 -03:00
|
|
|
# name: discourse-ai
|
2023-11-09 11:23:43 +10:00
|
|
|
# about: Enables integration between AI modules and features in Discourse
|
2023-11-08 09:45:02 +10:00
|
|
|
# meta_topic_id: 259214
|
2023-02-17 11:33:47 -03:00
|
|
|
# version: 0.0.1
|
|
|
|
|
# authors: Discourse
|
2023-05-12 12:54:25 +10:00
|
|
|
# url: https://meta.discourse.org/t/discourse-ai/259214
|
2023-02-17 11:33:47 -03:00
|
|
|
# required_version: 2.7.0
|
|
|
|
|
|
2024-04-05 01:02:16 +11:00
|
|
|
gem "tokenizers", "0.4.4"
|
2024-07-22 15:26:14 -03:00
|
|
|
gem "tiktoken_ruby", "0.0.9"
|
2024-10-16 12:41:18 -03:00
|
|
|
gem "ed25519", "1.2.4" #TODO remove this as existing ssl gem should handle this
|
2023-04-19 11:55:59 -03:00
|
|
|
|
2023-02-23 11:08:34 -03:00
|
|
|
enabled_site_setting :discourse_ai_enabled
|
2023-02-17 11:33:47 -03:00
|
|
|
|
2024-08-29 15:07:07 -07:00
|
|
|
register_asset "stylesheets/common/streaming.scss"
|
|
|
|
|
|
2023-03-15 17:02:20 -03:00
|
|
|
register_asset "stylesheets/modules/ai-helper/common/ai-helper.scss"
|
2024-09-11 05:45:48 +02:00
|
|
|
register_asset "stylesheets/modules/ai-helper/desktop/ai-helper-fk-modals.scss", :desktop
|
|
|
|
|
register_asset "stylesheets/modules/ai-helper/mobile/ai-helper-fk-modals.scss", :mobile
|
2023-05-18 12:34:49 -03:00
|
|
|
|
2024-08-26 08:32:39 -07:00
|
|
|
register_asset "stylesheets/modules/summarization/mobile/ai-summary.scss", :mobile
|
2024-07-02 08:51:59 -07:00
|
|
|
register_asset "stylesheets/modules/summarization/common/ai-summary.scss"
|
2024-08-05 17:39:08 +02:00
|
|
|
register_asset "stylesheets/modules/summarization/desktop/ai-summary.scss", :desktop
|
2024-07-02 08:51:59 -07:00
|
|
|
|
2023-05-05 15:28:31 -03:00
|
|
|
register_asset "stylesheets/modules/ai-bot/common/bot-replies.scss"
|
2023-11-21 16:56:43 +11:00
|
|
|
register_asset "stylesheets/modules/ai-bot/common/ai-persona.scss"
|
2024-03-21 14:29:56 +10:00
|
|
|
register_asset "stylesheets/modules/ai-bot/mobile/ai-persona.scss", :mobile
|
2023-03-15 17:02:20 -03:00
|
|
|
|
2023-07-13 20:34:02 +01:00
|
|
|
register_asset "stylesheets/modules/embeddings/common/semantic-related-topics.scss"
|
2023-09-05 11:08:23 -03:00
|
|
|
register_asset "stylesheets/modules/embeddings/common/semantic-search.scss"
|
2023-07-13 20:34:02 +01:00
|
|
|
|
2023-11-08 10:50:37 -03:00
|
|
|
register_asset "stylesheets/modules/sentiment/common/dashboard.scss"
|
|
|
|
|
register_asset "stylesheets/modules/sentiment/desktop/dashboard.scss", :desktop
|
|
|
|
|
register_asset "stylesheets/modules/sentiment/mobile/dashboard.scss", :mobile
|
|
|
|
|
|
2024-05-13 12:46:42 -03:00
|
|
|
register_asset "stylesheets/modules/llms/common/ai-llms-editor.scss"
|
|
|
|
|
|
2024-06-27 17:27:40 +10:00
|
|
|
register_asset "stylesheets/modules/ai-bot/common/ai-tools.scss"
|
|
|
|
|
|
2023-03-14 16:03:50 -03:00
|
|
|
module ::DiscourseAi
|
|
|
|
|
PLUGIN_NAME = "discourse-ai"
|
|
|
|
|
end
|
|
|
|
|
|
2023-11-29 15:17:46 +11:00
|
|
|
Rails.autoloaders.main.push_dir(File.join(__dir__, "lib"), namespace: ::DiscourseAi)
|
|
|
|
|
|
|
|
|
|
require_relative "lib/engine"
|
2023-03-07 15:39:28 -03:00
|
|
|
|
2023-02-24 07:53:43 -03:00
|
|
|
after_initialize do
|
2023-11-29 15:17:46 +11:00
|
|
|
# do not autoload this cause we may have no namespace
|
|
|
|
|
require_relative "discourse_automation/llm_triage"
|
2023-12-19 12:04:15 +11:00
|
|
|
require_relative "discourse_automation/llm_report"
|
2023-02-22 20:46:53 -03:00
|
|
|
|
2024-03-21 14:29:56 +10:00
|
|
|
add_admin_route("discourse_ai.title", "discourse-ai", { use_new_show_route: true })
|
2023-11-21 16:56:43 +11:00
|
|
|
|
2023-03-07 15:39:28 -03:00
|
|
|
[
|
2023-03-15 17:21:45 -03:00
|
|
|
DiscourseAi::Embeddings::EntryPoint.new,
|
2023-11-29 15:17:46 +11:00
|
|
|
DiscourseAi::Nsfw::EntryPoint.new,
|
2023-03-14 16:03:50 -03:00
|
|
|
DiscourseAi::Toxicity::EntryPoint.new,
|
|
|
|
|
DiscourseAi::Sentiment::EntryPoint.new,
|
2023-03-15 17:02:20 -03:00
|
|
|
DiscourseAi::AiHelper::EntryPoint.new,
|
2023-04-04 11:24:09 -03:00
|
|
|
DiscourseAi::Summarization::EntryPoint.new,
|
2023-05-05 15:28:31 -03:00
|
|
|
DiscourseAi::AiBot::EntryPoint.new,
|
2023-11-29 15:17:46 +11:00
|
|
|
].each { |a_module| a_module.inject_into(self) }
|
2023-03-07 15:39:28 -03:00
|
|
|
|
2023-03-14 16:03:50 -03:00
|
|
|
register_reviewable_type ReviewableAiChatMessage
|
|
|
|
|
register_reviewable_type ReviewableAiPost
|
2023-03-07 15:39:28 -03:00
|
|
|
|
|
|
|
|
on(:reviewable_transitioned_to) do |new_status, reviewable|
|
|
|
|
|
ModelAccuracy.adjust_model_accuracy(new_status, reviewable)
|
|
|
|
|
end
|
2023-11-21 16:56:43 +11:00
|
|
|
|
|
|
|
|
if Rails.env.test?
|
2023-11-21 18:02:27 +11:00
|
|
|
require_relative "spec/support/embeddings_generation_stubs"
|
2024-01-04 10:44:07 -03:00
|
|
|
require_relative "spec/support/stable_diffusion_stubs"
|
2023-11-21 16:56:43 +11:00
|
|
|
end
|
2024-03-12 16:51:41 +11:00
|
|
|
|
2024-10-18 18:01:39 -03:00
|
|
|
reloadable_patch do |plugin|
|
|
|
|
|
Guardian.prepend DiscourseAi::GuardianExtensions
|
|
|
|
|
Topic.prepend DiscourseAi::TopicExtensions
|
|
|
|
|
end
|
2024-04-11 10:00:41 +10:00
|
|
|
|
|
|
|
|
register_modifier(:post_should_secure_uploads?) do |_, _, topic|
|
2024-05-07 21:55:46 +10:00
|
|
|
if topic.private_message? && SharedAiConversation.exists?(target: topic)
|
|
|
|
|
false
|
|
|
|
|
else
|
|
|
|
|
# revert to default behavior
|
|
|
|
|
# even though this can be shortened this is the clearest way to express it
|
|
|
|
|
nil
|
|
|
|
|
end
|
2024-04-11 10:00:41 +10:00
|
|
|
end
|
2023-02-22 20:46:53 -03:00
|
|
|
end
|