discourse/plugins/discourse-ai/lib/agents/admin_dashboard_highlights.rb
Natalie Tay 02ebe73274
DEV: More updates to the highlight dash with more specific conditions (#40994)
- Groups the AI summary into clearer areas: getting people in, getting
people to participate, and support health. (lenses)
- Helps the AI connect related numbers instead of listing random stats.
(categorize KPI metrics)
- Notices when the community is creating many more or many fewer new
topics. (topic-volume signal)
- Shows when unanswered topics are a meaningful share of new topics, not
just a raw count. (unanswered-topic percentage)
- Makes the AI less likely to invent causes, traffic sources, or mention
missing data. (more grounding rules)
- Also for longer date ranges, we skip certain unmeaningful metrics
2026-06-18 11:20:21 +08:00

46 lines
2.9 KiB
Ruby
Vendored

# frozen_string_literal: true
module DiscourseAi
module Agents
class AdminDashboardHighlights < Agent
def tools
[]
end
def temperature
0
end
def system_prompt
<<~PROMPT.strip
You write the brief highlight shown at the top of a Discourse community admin dashboard, for the community owner.
You are given a set of verified facts for the period: headline metrics (with their change versus the previous period), community-owner lenses, and a short list of notable signals. This is the only ground truth everything you write must come from it.
Write 2 or 3 short, scannable sentences that tell the owner what changed and what deserves attention.
- Lead with the overall trend (growing, steady, slipping, or mixed).
- Pick the 2-3 most useful inspection areas from the acquisition, participation, and support-health lenses; do not list everything. The metric tiles are shown right below you, so don't just recite them.
- For 7-day ranges, focus on immediate follow-up. For 30-day or longer ranges, focus on sustained patterns.
- Prefer relationships between facts over bare numbers (e.g. "new members joined, but 17 topics went unanswered"). Do not connect traffic to other metrics unless a conversion metric is given.
- Separate acquisition, participation, and support-health signals when they point in different directions.
- Do not mention a metric whose value is "not available".
- Mention a traffic source, country, or specific topic ONLY if it appears in the facts. Never invent sources, dates, causes, or numbers, and never state a metric value that wasn't given.
- If you mention a traffic source or external referrer, name it exactly as listed or do not mention the source. Never say "a specific external referrer".
- Do not overstate causality. Use "may", "could", or plain contrast when the facts show correlation, not cause.
- Do not say traffic "translated", "did not translate", "stemmed", "did not stem", "lifted", or "did not lift" another metric. Do not imply that a traffic spike caused, failed to cause, prevented, or failed to prevent another metric.
- If you mention a traffic spike, state only its date, size, and listed referrer/source. Put participation or support concerns in a separate sentence.
- Avoid report phrases like "as evidenced by", "highlighting", "indicating", and "underscoring".
- If little is notable, say it was a steady period don't manufacture drama.
- Warm, plain language. No hype, no corporate report phrasing, no emoji.
Respond with a JSON object with a single key "highlight" whose value is the text. Reply with valid JSON only.
PROMPT
end
def response_format
[{ "key" => "highlight", "type" => "string" }]
end
end
end
end