feat(email_gen): draft constituent letter generator + bill text indicators

- Add DraftLetterPanel: collapsible UI below BriefPanel for bills with a
  brief; lets users select up to 3 cited points, pick stance/tone, and
  generate a plain-text letter via the configured LLM provider
- Stance pre-fills from follow mode (pocket_boost → YES, pocket_veto → NO)
  and clears when the user unfollows; recipient derived from bill chamber
- Add POST /api/bills/{bill_id}/draft-letter endpoint with proper LLM
  provider/model resolution from AppSetting (respects Settings page choice)
- Add generate_text() to LLMProvider ABC and all four providers
- Expose has_document on BillSchema (list endpoint) via a single batch
  query; BillCard shows Brief / Pending / No text indicator per bill

Authored-By: Jack Levy
This commit is contained in:
Jack Levy
2026-03-01 16:37:52 -05:00
parent 7106c9a63c
commit dc5e756749
8 changed files with 556 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import Link from "next/link";
import { TrendingUp, Calendar, User } from "lucide-react";
import { TrendingUp, Calendar, User, FileText, FileClock, FileX } from "lucide-react";
import { Bill } from "@/lib/types";
import { billLabel, chamberBadgeColor, cn, formatDate, partyBadgeColor, trendColor } from "@/lib/utils";
import { FollowButton } from "./FollowButton";
@@ -69,6 +69,22 @@ export function BillCard({ bill, compact = false }: BillCardProps) {
{Math.round(score)}
</div>
)}
{bill.latest_brief ? (
<div className="flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400" title="Analysis available">
<FileText className="w-3 h-3" />
<span>Brief</span>
</div>
) : bill.has_document ? (
<div className="flex items-center gap-1 text-xs text-amber-500" title="Text retrieved, analysis pending">
<FileClock className="w-3 h-3" />
<span>Pending</span>
</div>
) : (
<div className="flex items-center gap-1 text-xs text-muted-foreground/50" title="No bill text published">
<FileX className="w-3 h-3" />
<span>No text</span>
</div>
)}
</div>
</div>