mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-11 22:14:44 +00:00
Splits persona permissions so you can allow a persona on: - chat dms - personal messages - topic mentions - chat channels (any combination is allowed) Previously we did not have this flexibility. Additionally, adds the ability to "tether" a language model to a persona so it will always be used by the persona. This allows people to use a cheaper language model for one group of people and more expensive one for other people
31 lines
952 B
Ruby
31 lines
952 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseAi::ChatBotHelper
|
|
def toggle_enabled_bots(bots: [])
|
|
models = LlmModel.all
|
|
models = models.where("id not in (?)", bots.map(&:id)) if bots.present?
|
|
models.update_all(enabled_chat_bot: false)
|
|
|
|
bots.each { |b| b.update!(enabled_chat_bot: true) }
|
|
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}=", "custom:#{fake_llm.id}")
|
|
end
|
|
end
|
|
end
|
|
|
|
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
|