Skip to content

A platform for community discussion. Free, open, simple.

1.9 KB
Raw Blame
# frozen_string_literal: true

module DiscourseAi
  module Agents
    class ConceptMatcher < Agent
      def self.default_enabled
        false
      end

      def thinking_effort
        "none"
      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:

          {"matching_concepts": ["concept1", "concept3", "concept5"]}

          Only include concepts from the provided list that match the content. If no concepts match, return an empty array.
          reply with valid JSON only
        PROMPT
      end

      def response_format
        [{ "key" => "matching_concepts", "type" => "array", "array_type" => "string" }]
      end
    end
  end
end