2023-03-15 16:02:20 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
|
|
module AiHelper
|
|
|
|
class EntryPoint
|
|
|
|
def load_files
|
2023-10-30 10:56:33 -04:00
|
|
|
require_relative "chat_thread_titler"
|
|
|
|
require_relative "jobs/regular/generate_chat_thread_title"
|
2023-04-10 10:04:42 -04:00
|
|
|
require_relative "llm_prompt"
|
2023-09-14 11:53:44 -04:00
|
|
|
require_relative "painter"
|
2023-10-30 10:56:33 -04:00
|
|
|
require_relative "semantic_categorizer"
|
2023-10-23 10:41:36 -04:00
|
|
|
require_relative "topic_helper"
|
2023-03-15 16:02:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def inject_into(plugin)
|
2023-03-17 14:14:19 -04:00
|
|
|
plugin.register_seedfu_fixtures(
|
2023-05-05 14:28:31 -04:00
|
|
|
Rails.root.join("plugins", "discourse-ai", "db", "fixtures", "ai_helper"),
|
2023-03-17 14:14:19 -04:00
|
|
|
)
|
2023-09-25 14:12:54 -04:00
|
|
|
|
2023-10-19 18:31:56 -04:00
|
|
|
additional_icons = %w[spell-check language]
|
2023-09-25 14:12:54 -04:00
|
|
|
additional_icons.each { |icon| plugin.register_svg_icon(icon) }
|
2023-10-30 10:56:33 -04:00
|
|
|
|
|
|
|
plugin.on(:chat_thread_created) do |thread|
|
2023-10-30 12:32:56 -04:00
|
|
|
next unless SiteSetting.composer_ai_helper_enabled
|
|
|
|
next unless SiteSetting.ai_helper_automatic_chat_thread_title
|
2023-10-30 10:56:33 -04:00
|
|
|
Jobs.enqueue_in(
|
|
|
|
SiteSetting.ai_helper_automatic_chat_thread_title_delay.minutes,
|
|
|
|
:generate_chat_thread_title,
|
|
|
|
thread_id: thread.id,
|
|
|
|
)
|
|
|
|
end
|
2023-03-15 16:02:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|