mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
## 🔍 Overview This update migrates the `enabled_chat_bot` column on the LlmModel to an independent setting called: `ai_bot_enabled_llms`. In this setting admins can quickly select all LLM models that will be enabled for AI bot. ## 📷 Screenshots <img width="343" height="343" alt="Screenshot 2025-12-15 at 14 05 20" src="https://github.com/user-attachments/assets/2386b6ed-a7ad-4bbc-bc3c-bf0d1c8427c8" />
23 lines
745 B
Ruby
Vendored
23 lines
745 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi::ChatBotHelper
|
|
def toggle_enabled_bots(bots: [])
|
|
SiteSetting.ai_bot_enabled = true if bots.any?
|
|
SiteSetting.ai_bot_enabled_llms = bots.map(&:id).join("|")
|
|
DiscourseAi::AiBot::SiteSettingsExtension.enable_or_disable_ai_bots
|
|
end
|
|
|
|
def assign_fake_provider_to(setting_name)
|
|
Fabricate(:fake_model).tap do |fake_llm|
|
|
SiteSetting.public_send("#{setting_name}=", "#{fake_llm.id}")
|
|
end
|
|
end
|
|
|
|
def assign_persona_to(setting_name, allowed_group_ids)
|
|
Fabricate(:ai_persona, allowed_group_ids: allowed_group_ids).tap do |p|
|
|
SiteSetting.public_send("#{setting_name}=", p.id)
|
|
end
|
|
end
|
|
end
|
|
|
|
RSpec.configure { |config| config.include DiscourseAi::ChatBotHelper }
|