mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 06:43:54 +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
46 lines
1.3 KiB
Ruby
Vendored
46 lines
1.3 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseAi::Admin::AiFeaturesController do
|
|
let(:controller) { described_class.new }
|
|
fab!(:admin)
|
|
fab!(:group)
|
|
fab!(:llm_model)
|
|
fab!(:summarizer_agent, :ai_agent)
|
|
fab!(:alternate_summarizer_agent, :ai_agent)
|
|
|
|
before do
|
|
enable_current_plugin
|
|
sign_in(admin)
|
|
assign_fake_provider_to(:ai_default_llm_model)
|
|
SiteSetting.ai_bot_enabled = true
|
|
end
|
|
|
|
describe "#index" do
|
|
it "lists all features backed by agents" do
|
|
get "/admin/plugins/discourse-ai/ai-features.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.parsed_body["ai_features"].count).to eq(
|
|
DiscourseAi::Configuration::Module.all.count(&:visible?),
|
|
)
|
|
end
|
|
|
|
it "includes automation-related features" do
|
|
SiteSetting.discourse_automation_enabled = true
|
|
|
|
get "/admin/plugins/discourse-ai/ai-features.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.parsed_body["ai_features"].count).to eq(
|
|
DiscourseAi::Configuration::Module.all.count(&:visible?),
|
|
)
|
|
end
|
|
end
|
|
|
|
describe "#edit" do
|
|
it "returns a success response" do
|
|
get "/admin/plugins/discourse-ai/ai-features/1/edit.json"
|
|
expect(response.parsed_body["module_name"]).to eq("summarization")
|
|
end
|
|
end
|
|
end
|