2024-06-18 13:32:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi::ChatBotHelper
|
|
|
|
def toggle_enabled_bots(bots: [])
|
|
|
|
LlmModel.update_all(enabled_chat_bot: false)
|
|
|
|
bots.each { |b| b.update!(enabled_chat_bot: true) }
|
|
|
|
DiscourseAi::AiBot::SiteSettingsExtension.enable_or_disable_ai_bots
|
|
|
|
end
|
2024-06-19 17:01:35 -04:00
|
|
|
|
|
|
|
def assign_fake_provider_to(setting_name)
|
2024-07-30 12:44:57 -04:00
|
|
|
Fabricate(:fake_model).tap do |fake_llm|
|
2024-06-19 17:01:35 -04:00
|
|
|
SiteSetting.public_send("#{setting_name}=", "custom:#{fake_llm.id}")
|
|
|
|
end
|
|
|
|
end
|
2024-06-18 13:32:14 -04:00
|
|
|
end
|
|
|
|
|
2024-10-10 11:39:36 -04:00
|
|
|
RSpec.configure do |config|
|
|
|
|
config.include DiscourseAi::ChatBotHelper
|
|
|
|
|
|
|
|
config.before(:suite) do
|
|
|
|
if defined?(migrate_column_to_bigint)
|
|
|
|
migrate_column_to_bigint(RagDocumentFragment, :target_id)
|
|
|
|
migrate_column_to_bigint("ai_document_fragment_embeddings", "rag_document_fragment_id")
|
|
|
|
migrate_column_to_bigint(ClassificationResult, :target_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|