Class: Collavre::Mobile::EventSummarizer
- Inherits:
-
Object
- Object
- Collavre::Mobile::EventSummarizer
- Defined in:
- app/services/collavre/mobile/event_summarizer.rb
Overview
Turns an approval/permission comment or an agent reply into a SHORT, decision-oriented line of speech. Deterministic (no LLM) so the hot path stays fast: it extracts the tool name / human description from the permission action payload and renders a localized, spoken-friendly summary.
Instance Method Summary collapse
- #approval_summary(comment:, label:) ⇒ Object
-
#initialize(locale:) ⇒ EventSummarizer
constructor
A new instance of EventSummarizer.
Constructor Details
#initialize(locale:) ⇒ EventSummarizer
Returns a new instance of EventSummarizer.
10 11 12 |
# File 'app/services/collavre/mobile/event_summarizer.rb', line 10 def initialize(locale:) @locale = (locale.presence || I18n.default_locale).to_s end |
Instance Method Details
#approval_summary(comment:, label:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/collavre/mobile/event_summarizer.rb', line 14 def approval_summary(comment:, label:) payload = parse_action(comment) I18n.with_locale(@locale) do detail = payload&.dig("description").presence || payload&.dig("tool_name").presence || I18n.t("collavre.mobile.summary.a_tool") I18n.t("collavre.mobile.summary.approval", label: label, detail: flatten(detail)) end end |