@@ -38,21 +38,29 @@ def summary_extension_prompt(summary, contents)
3838 input =
3939 contents . map { |item | "(#{ item [ :id ] } #{ item [ :poster ] } said: #{ item [ :text ] } )" } . join
4040
41- prompt = DiscourseAi ::Completions ::Prompt . new ( <<~TEXT , topic_id : target . id )
42- You are an advanced summarization bot tasked with enhancing an existing summary by incorporating additional posts.
43-
44- ### Guidelines:
45- - Only include the enhanced summary, without any additional commentary.
46- - Understand and generate Discourse forum Markdown; including links, _italics_, **bold**.
47- - Maintain the original language of the text being summarized.
48- - Aim for summaries to be 400 words or less.
49- - Each new post is formatted as "<POST_NUMBER>) <USERNAME> <MESSAGE>"
50- - Cite specific noteworthy posts using the format [DESCRIPTION](#{ resource_path } /POST_NUMBER)
51- - Example: links to the 3rd and 6th posts by sam: sam ([#3](#{ resource_path } /3), [#6](#{ resource_path } /6))
52- - Example: link to the 6th post by jane: [agreed with](#{ resource_path } /6)
53- - Example: link to the 13th post by joe: [joe](#{ resource_path } /13)
54- - When formatting usernames either use @USERNAME or [USERNAME](#{ resource_path } /POST_NUMBER)
55- TEXT
41+ if SiteSetting . ai_summary_consolidator_persona_id
42+ prompt =
43+ DiscourseAi ::Completions ::Prompt . new (
44+ AiPersona . find_by ( id : SiteSetting . ai_summary_consolidator_persona_id ) . system_prompt ,
45+ topic_id : target . id ,
46+ )
47+ else
48+ prompt = DiscourseAi ::Completions ::Prompt . new ( <<~TEXT , topic_id : target . id ) # summary extension prompt
49+ You are an advanced summarization bot tasked with enhancing an existing summary by incorporating additional posts.
50+
51+ ### Guidelines:
52+ - Only include the enhanced summary, without any additional commentary.
53+ - Understand and generate Discourse forum Markdown; including links, _italics_, **bold**.
54+ - Maintain the original language of the text being summarized.
55+ - Aim for summaries to be 400 words or less.
56+ - Each new post is formatted as "<POST_NUMBER>) <USERNAME> <MESSAGE>"
57+ - Cite specific noteworthy posts using the format [DESCRIPTION](#{ resource_path } /POST_NUMBER)
58+ - Example: links to the 3rd and 6th posts by sam: sam ([#3](#{ resource_path } /3), [#6](#{ resource_path } /6))
59+ - Example: link to the 6th post by jane: [agreed with](#{ resource_path } /6)
60+ - Example: link to the 13th post by joe: [joe](#{ resource_path } /13)
61+ - When formatting usernames either use @USERNAME or [USERNAME](#{ resource_path } /POST_NUMBER)
62+ TEXT
63+ end
5664
5765 prompt . push ( type : :user , content : <<~TEXT . strip )
5866 ### Context:
@@ -81,20 +89,28 @@ def first_summary_prompt(contents)
8189 input =
8290 contents . map { |item | "(#{ item [ :id ] } #{ item [ :poster ] } said: #{ item [ :text ] } " } . join
8391
84- prompt = DiscourseAi ::Completions ::Prompt . new ( <<~TEXT . strip , topic_id : target . id )
85- You are an advanced summarization bot that generates concise, coherent summaries of provided text.
86-
87- - Only include the summary, without any additional commentary.
88- - You understand and generate Discourse forum Markdown; including links, _italics_, **bold**.
89- - Maintain the original language of the text being summarized.
90- - Aim for summaries to be 400 words or less.
91- - Each post is formatted as "<POST_NUMBER>) <USERNAME> <MESSAGE>"
92- - Cite specific noteworthy posts using the format [DESCRIPTION](#{ resource_path } /POST_NUMBER)
93- - Example: links to the 3rd and 6th posts by sam: sam ([#3](#{ resource_path } /3), [#6](#{ resource_path } /6))
94- - Example: link to the 6th post by jane: [agreed with](#{ resource_path } /6)
95- - Example: link to the 13th post by joe: [joe](#{ resource_path } /13)
96- - When formatting usernames either use @USERNMAE OR [USERNAME](#{ resource_path } /POST_NUMBER)
97- TEXT
92+ if SiteSetting . ai_summary_persona_id . present?
93+ prompt =
94+ DiscourseAi ::Completions ::Prompt . new (
95+ AiPersona . find_by ( id : SiteSetting . ai_summary_consolidator_persona_id ) . system_prompt ,
96+ topic_id : target . id ,
97+ )
98+ else
99+ prompt = DiscourseAi ::Completions ::Prompt . new ( <<~TEXT . strip , topic_id : target . id )
100+ You are an advanced summarization bot that generates concise, coherent summaries of provided text.
101+
102+ - Only include the summary, without any additional commentary.
103+ - You understand and generate Discourse forum Markdown; including links, _italics_, **bold**.
104+ - Maintain the original language of the text being summarized.
105+ - Aim for summaries to be 400 words or less.
106+ - Each post is formatted as "<POST_NUMBER>) <USERNAME> <MESSAGE>"
107+ - Cite specific noteworthy posts using the format [DESCRIPTION](#{ resource_path } /POST_NUMBER)
108+ - Example: links to the 3rd and 6th posts by sam: sam ([#3](#{ resource_path } /3), [#6](#{ resource_path } /6))
109+ - Example: link to the 6th post by jane: [agreed with](#{ resource_path } /6)
110+ - Example: link to the 13th post by joe: [joe](#{ resource_path } /13)
111+ - When formatting usernames either use @USERNMAE OR [USERNAME](#{ resource_path } /POST_NUMBER)
112+ TEXT
113+ end
98114
99115 prompt . push (
100116 type : :user ,
0 commit comments