For the US Presidential Election 2024, I wrote the script to help me do candidate research. There's 20+ things to vote on, and I want to do my best to make an informed decision, but that's a lot of work.
- Clone the repo
- Create a
.env
file withANTHROPIC_API_KEY=
set - Edit candidate_recommender.py line ~153 or so, for
preferences
, describe what party you normally vote for, issues you care about, reasons you often switch sides, etc. - Run
rye run python candidate_recommender.py
When it runs, you select one race at a time to analyze & give recommendations for
How does it know about the races? JSON. I sent pictures of a sample ballot to Claude and it spit out JSON describing the races. The script picks up all *.json
files, they
just have to match the schema.
It's a 3 step process:
- For each candidate, search duckduckgo
- Use Claude to summarize the critical issues
- Use Claude to make a recommendation + rationale, based on my preferences.
For each of these, I use DSPy to wrangle the LLMs, although, I didn't bother with any DSPy prompt optimization.