Skip to content

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

FIX: Preserve language in short summaries (#41829)

Sam15e1c28b16fc
diff --git a/plugins/discourse-ai/lib/agents/short_summarizer.rb b/plugins/discourse-ai/lib/agents/short_summarizer.rb
index c58c76071d1..786069edf24 100644
--- a/plugins/discourse-ai/lib/agents/short_summarizer.rb
+++ b/plugins/discourse-ai/lib/agents/short_summarizer.rb
@@ -9,27 +9,33 @@ module DiscourseAi
def system_prompt
<<~PROMPT.strip
- You are an advanced summarization bot. Analyze a given conversation and produce a concise,
- single-sentence summary that conveys the main topic and current developments to someone with no prior context.
+ You are an advanced summarization bot. Analyze the supplied conversation and produce a concise, single-sentence summary that conveys the main topic and current developments to someone with no prior context.
- ### Guidelines:
+ ### Guidelines
- Emphasize the most recent updates while considering their significance within the original post.
- - Focus on the central theme or issue being addressed, maintaining an objective and neutral tone.
- - Exclude extraneous details or subjective opinions.
- - Use the original language of the text.
- - Begin directly with the main topic or issue, avoiding introductory phrases.
+ - Focus on the central theme or issue, maintaining an objective and neutral tone.
+ - Exclude extraneous details and subjective opinions.
+ - Begin directly with the main topic or issue.
+ - Do not repeat the discussion title.
- Limit the summary to a maximum of 40 words.
- - Do *NOT* repeat the discussion title in the summary.
- 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:
+ ### Language procedure
- {"summary": "xx"}
+ Before composing the summary:
+ 1. Silently identify the primary language used in the substantive conversation text.
+ 2. Determine the language from the conversation itself, not from usernames, titles, metadata, formatting, code, or these instructions.
+ 3. Write the summary in the identified language.
+ 4. Verify that the summary language matches the conversation language before returning it.
- Where "xx" is replaced by the summary.
- reply with valid JSON only
+ Do not output the identified language, your analysis, or your reasoning.
+
+ Return a valid JSON object containing exactly one key named "summary":
+
+ {"summary":"xx"}
+
+ Replace "xx" with the summary. Return valid JSON only, with no Markdown fences or additional text.
PROMPT
end