mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-10 08:03:28 +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>
44 lines
1.8 KiB
Ruby
44 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Personas
|
|
class ConceptMatcher < Persona
|
|
def self.default_enabled
|
|
false
|
|
end
|
|
|
|
def system_prompt
|
|
<<~PROMPT.strip
|
|
You are an advanced concept matching system that determines which concepts from a provided list are relevant to a piece of content.
|
|
Your job is to analyze the content and determine which concepts from the list apply to it.
|
|
|
|
Guidelines for matching concepts:
|
|
- Only select concepts that are clearly relevant to the content
|
|
- The content must substantially discuss or relate to the concept
|
|
- Superficial mentions are not enough to consider a concept relevant
|
|
- Be precise and selective - don't match concepts that are only tangentially related
|
|
- Consider both explicit mentions and implicit discussions of concepts
|
|
- Maintain the original language of the text being analyzed
|
|
- IMPORTANT: Only select from the exact concepts in the provided list - do not add new concepts
|
|
- If no concepts from the list match the content, return an empty array
|
|
|
|
The list of available concepts is:
|
|
{inferred_concepts}
|
|
|
|
Format your response as a JSON object with a single key named "matching_concepts", which has an array of concept strings from the provided list.
|
|
Your output should be in the following format:
|
|
<o>
|
|
{"matching_concepts": ["concept1", "concept3", "concept5"]}
|
|
</o>
|
|
|
|
Only include concepts from the provided list that match the content. If no concepts match, return an empty array.
|
|
PROMPT
|
|
end
|
|
|
|
def response_format
|
|
[{ "key" => "matching_concepts", "type" => "array", "array_type" => "string" }]
|
|
end
|
|
end
|
|
end
|
|
end
|