mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-08 15:22:47 +00:00
* FEATURE: add inferred concepts system This commit adds a new inferred concepts system that: - Creates a model for storing concept labels that can be applied to topics - Provides AI personas for finding new concepts and matching existing ones - Adds jobs for generating concepts from popular topics - Includes a scheduled job that automatically processes engaging topics * FEATURE: Extend inferred concepts to include posts * Adds support for concepts to be inferred from and applied to posts * Replaces daily task with one that handles both topics and posts * Adds database migration for posts_inferred_concepts join table * Updates PersonaContext to include inferred concepts Co-authored-by: Roman Rizzi <rizziromanalejandro@gmail.com> Co-authored-by: Keegan George <kgeorge13@gmail.com>
37 lines
997 B
Ruby
37 lines
997 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseAi::Personas::ConceptMatcher do
|
|
let(:persona) { described_class.new }
|
|
|
|
describe ".default_enabled" do
|
|
it "is disabled by default" do
|
|
expect(described_class.default_enabled).to eq(false)
|
|
end
|
|
end
|
|
|
|
describe "#system_prompt" do
|
|
let(:prompt) { persona.system_prompt }
|
|
|
|
it "includes placeholder for concept list" do
|
|
expect(prompt).to include("{inferred_concepts}")
|
|
end
|
|
|
|
it "specifies output format" do
|
|
expect(prompt).to include("matching_concepts")
|
|
expect(prompt).to include("<o>")
|
|
expect(prompt).to include('{"matching_concepts": ["concept1", "concept3", "concept5"]}')
|
|
expect(prompt).to include("</o>")
|
|
end
|
|
end
|
|
|
|
describe "#response_format" do
|
|
it "defines correct response format" do
|
|
format = persona.response_format
|
|
|
|
expect(format).to eq(
|
|
[{ "array_type" => "string", "key" => "matching_concepts", "type" => "array" }],
|
|
)
|
|
end
|
|
end
|
|
end
|