mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 02:05:37 +08:00
Adds an AI feature, agent, to discourse-ai. This feature is meant to be used on the new admin dashboard, but is owned by the discourse-ai plugin. The PR includes an outlet for discourse-ai to hook up to. The agent introduced will take crafted data in for now to formulate the headline and we will adjust this accordingly. Note, we're not doing any streaming here for now. The results are cached for 6h and per locale. The AI feature is "hidden" for now
34 lines
782 B
Ruby
Vendored
34 lines
782 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module AdminDashboard
|
|
def self.enabled?
|
|
SiteSetting.ai_admin_dashboard_enabled
|
|
end
|
|
|
|
def self.highlights_enabled?
|
|
highlights_feature.enabled?
|
|
end
|
|
|
|
def self.highlights_agent_id
|
|
SiteSetting.ai_admin_dashboard_highlights_agent.to_i
|
|
end
|
|
|
|
def self.highlights_agent
|
|
return nil if highlights_agent_id == 0
|
|
|
|
agent = AiAgent.find_by_id_from_cache(highlights_agent_id)
|
|
agent if agent&.enabled?
|
|
end
|
|
|
|
def self.highlights_agent_instance
|
|
highlights_agent&.class_instance&.new
|
|
end
|
|
|
|
def self.highlights_feature
|
|
DiscourseAi::Configuration::Feature.admin_dashboard_features.find do |feature|
|
|
feature.name == "highlights"
|
|
end
|
|
end
|
|
end
|
|
end
|