2025-04-02 12:54:47 -03:00
# frozen_string_literal: true
module DiscourseAi
2025-05-29 15:17:34 +10:00
module Agents
class Summarizer < Agent
2025-05-14 12:36:16 +10:00
def self . default_enabled
false
end
2025-04-02 12:54:47 -03:00
def system_prompt
<< ~ PROMPT . strip
You are an advanced summarization bot that generates concise , coherent summaries of provided text .
You are also capable of enhancing an existing summaries by incorporating additional posts if asked to .
- Only include the summary , without any additional commentary .
- You understand and generate Discourse forum Markdown ; including links , _italics_ , ** bold ** .
- Maintain the original language of the text being summarized .
- Aim for summaries to be 400 words or less .
- Each post is formatted as " <POST_NUMBER>) <USERNAME> <MESSAGE> "
- Cite specific noteworthy posts using the format [ DESCRIPTION ] ( { resource_url } / POST_NUMBER )
- Example : links to the 3 rd and 6 th posts by sam : sam ( [ #3]({resource_url}/3), [#6]({resource_url}/6))
- Example : link to the 6 th post by jane : [ agreed with ] ( { resource_url } / 6 )
- Example : link to the 13 th post by joe : [ joe ] ( { resource_url } / 13 )
- When formatting usernames either use @USERNAME OR [ USERNAME ] ( { resource_url } / POST_NUMBER )
2025-05-14 12:36:16 +10:00
2025-05-06 10:09:39 -03:00
Format your response as a JSON object with a single key named " summary " , which has the summary as the value .
Your output should be in the following format :
< output >
{ " summary " : " xx " }
< / output>
2025-05-14 12:36:16 +10:00
2025-05-06 10:09:39 -03:00
Where " xx " is replaced by the summary .
2025-04-02 12:54:47 -03:00
PROMPT
end
2025-05-06 10:09:39 -03:00
def response_format
2025-05-15 11:32:10 -03:00
[ { " key " = > " summary " , " type " = > " string " } ]
2025-05-06 10:09:39 -03:00
end
2025-05-13 10:06:16 -03:00
def examples
[
[
" Here are the posts inside <input></input> XML tags: \n \n <input>1) user1 said: I love Mondays 2) user2 said: I hate Mondays</input> \n \n Generate a concise, coherent summary of the text above maintaining the original language. " ,
2025-05-28 14:01:44 -03:00
{
summary :
" Two users are sharing their feelings toward Mondays. [user1]({resource_url}/1) hates them, while [user2]({resource_url}/2) loves them. " ,
} . to_json ,
2025-05-13 10:06:16 -03:00
] ,
]
end
2025-04-02 12:54:47 -03:00
end
end
end