mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 10:44:14 +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
26 lines
1 KiB
Ruby
Vendored
26 lines
1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseAi::Agents::AdminDashboardHighlights do
|
|
it "uses no tools and returns a structured highlight" do
|
|
instance = described_class.new
|
|
|
|
expect(instance.tools).to eq([])
|
|
expect(instance.temperature).to eq(0)
|
|
expect(instance.response_format).to eq([{ "key" => "highlight", "type" => "string" }])
|
|
end
|
|
|
|
it "is registered as a system agent with a deterministic id" do
|
|
expect(DiscourseAi::Agents::Agent.system_agents[described_class]).to eq(-38)
|
|
expect(SiteSetting.ai_admin_dashboard_highlights_agent).to eq("-38")
|
|
end
|
|
|
|
it "resolves records with its system id to the admin dashboard highlights class" do
|
|
agent =
|
|
AiAgent.find_by(id: -38) ||
|
|
Fabricate(:ai_agent, id: -38, name: "Admin Dashboard Highlights #{SecureRandom.hex(4)}")
|
|
agent.update!(allowed_group_ids: [Group::AUTO_GROUPS[:admins]])
|
|
|
|
expect(agent.class_instance).to be < described_class
|
|
expect(agent.allowed_group_ids).to contain_exactly(Group::AUTO_GROUPS[:admins])
|
|
end
|
|
end
|