Skip to content

feat(consultation): add AI-generated response summaries in multiple languages - #1249

Open
austinjb32 wants to merge 1 commit into
CIV-116-2from
CIV-116-3
Open

feat(consultation): add AI-generated response summaries in multiple languages#1249
austinjb32 wants to merge 1 commit into
CIV-116-2from
CIV-116-3

Conversation

@austinjb32

Copy link
Copy Markdown
Contributor

Bridge Ticket: CIV-116

What does this change do?

Adds AI-generated response summaries for consultations in 5 languages (English, Hindi, Marathi, Odia, Kannada). When a consultation expires, a background job generates narrative summaries from all question responses (excluding clause feedback) using GPT-5.6 Luna via OpenRouter.

Why is this change needed?

Consultations need automated summaries of public responses to help policymakers quickly understand consensus, diverging views, and minority opinions — without manually reading every response.

How were the changes done?

  • ConsultationSummaryService — orchestrates prompt building, LLM calls, and storage. Generates summaries per language with translated section labels.
  • ConsultationSummaryJob — async job triggered from Consultation#expire, calls the service.
  • Prompt template (config/prompts/consultation_ai_summary.prompt) — instructs the AI to produce a 4-part narrative (opening paragraph, Frequently Raised, Diverging Views, Also Raised) with labels translated into the target language.
  • Rich text fieldsenglish_response_summary, hindi_response_summary, marathi_response_summary, odia_response_summary, kannada_response_summary on the Consultation model.
  • GraphQL — exposed all 5 per-language response summary fields as String types with resolvers.
  • JSONB storage — raw summaries also saved to response_summary column as { language: text } hash.

How was testing done?

Tested end-to-end against consultation #128 in dev — all 5 languages generated correctly with proper scripts (Devanagari, Odia, Kannada) and translated labels.

AI Code Review Summary

# Severity File Description Status Notes
1 🟡 Minor base.rb:94-96 Dead summary_hindi resolver method remained after field was removed ✅ Fixed Removed dead method
2 🟡 Minor base.rb response_summary JSONB field not exposed in GraphQL ⏭️ Skipped Per-language fields are sufficient

Blast Radius: High

…anguages

- Added ConsultationSummaryService to generate AI summaries using GPT-5.6 Luna via OpenRouter
- Added ConsultationSummaryJob triggered on consultation expiry
- Added prompt template for narrative summary in 4 parts with translated labels
- Added per-language rich text fields (english_response_summary, hindi_response_summary, etc.)
- Exposed new response summary fields in GraphQL consultation type
- Removed dead summary_hindi resolver method
@austinjb32 austinjb32 added the Blast Radius: High Changes affecting multiple flows, shared code, auth, payments, schema, APIs, or infrastructure label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blast Radius: High Changes affecting multiple flows, shared code, auth, payments, schema, APIs, or infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant