Skip to content

Conversation

@xiaooubai
Copy link

@xiaooubai xiaooubai commented Dec 4, 2025

This PR adds a relevance scoring system for bills. It uses an LLM to analyze each bill's text and estimate how relevant it is to builders and entrepreneurs (scored 1-10), along with an estimated GDP impact percentage. The analysis includes justifications for both scores, the primary mechanism of economic impact, and implementation timeline.
Results are stored in MongoDB and surfaced on the frontend in two places: as color-coded badges on bill cards in the list view (Low/Relevant/Very Relevant), and as a full "Relevance to Builders" section on individual bill detail pages showing the score breakdown, justifications, and economic impact details. Users can also filter bills by minimum relevance score and sort by relevance instead of date.

How bills get relevance analysis:

Automatically when someone views a bill detail page: If a bill exists in the database but doesn't have a relevance score yet, the system fetches the bill markdown, sends it to the LLM for analysis, and persists the results to MongoDB. This happens during page load.

Running the bulk analysis script

To test on a small set of bills first:

bash pnpm tsx src/scripts/bulk-analyze-bills.ts --url https://www.buildcanada.com/bills --bills C-14 C-18 S-5

To preview what would happen without actually running:

bash pnpm tsx src/scripts/bulk-analyze-bills.ts --url https://www.buildcanada.com/bills --dry-run

To run on all bills missing relevance scores:

bash pnpm tsx src/scripts/bulk-analyze-bills.ts --url https://www.buildcanada.com/bills

Screenshot 2025-12-03 at 11 04 43 PM Screenshot 2025-12-03 at 11 05 46 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant