mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 03:05:45 +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
38 lines
1.2 KiB
Ruby
Vendored
38 lines
1.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseAi::AdminDashboard do
|
|
before do
|
|
enable_current_plugin
|
|
assign_fake_provider_to(:ai_default_llm_model)
|
|
SiteSetting.ai_admin_dashboard_highlights_agent = "-38"
|
|
AiAgent.where(id: -38).delete_all
|
|
end
|
|
|
|
it "reports whether admin dashboard AI is enabled" do
|
|
SiteSetting.ai_admin_dashboard_enabled = false
|
|
expect(described_class).not_to be_enabled
|
|
|
|
SiteSetting.ai_admin_dashboard_enabled = true
|
|
expect(described_class).to be_enabled
|
|
end
|
|
|
|
it "reports whether admin dashboard highlights are enabled" do
|
|
SiteSetting.ai_admin_dashboard_enabled = true
|
|
agent = Fabricate(:ai_agent, id: -38, enabled: true)
|
|
|
|
expect(described_class).to be_highlights_enabled
|
|
|
|
agent.update!(enabled: false)
|
|
expect(described_class).not_to be_highlights_enabled
|
|
end
|
|
|
|
it "returns the selected admin dashboard highlights agent instance" do
|
|
SiteSetting.ai_admin_dashboard_enabled = true
|
|
Fabricate(:ai_agent, id: -38, enabled: true)
|
|
|
|
expect(described_class.highlights_agent_id).to eq(-38)
|
|
expect(described_class.highlights_agent_instance).to be_a(
|
|
DiscourseAi::Agents::AdminDashboardHighlights,
|
|
)
|
|
end
|
|
end
|