3.5 KiB
Task: Design a Python application that:
Authenticates with the U.S. Congress API (Library of Congress web service).
Retrieves the full voting history for any legislator (by name or ID).
For every bill the legislator voted on, fetches the bill text and a concise summary.
Feeds that bill text into a locally‑hosted GPT‑OSS endpoint (
http://home.ms:4000/v1) and stores the model’s output.Caches all external data locally (SQLite or a simple key‑value store) to avoid repeated API calls and to survive API outages.
Handles pagination, rate‑limit back‑off, and graceful error handling.
Provides a clean CLI or minimal web UI to query a legislator name and print:
- Legislator details (party, state, etc.)
- A table of bill IDs, vote type (Yay/Nay/Abstain), and a short GPT‑OSS‑derived explanation for each bill.
Uses type‑hints, dataclasses, and a modular architecture so each component can be unit‑tested.
Includes a README explaining how to set up the API key, run the local GPT‑OSS server, and execute the program.
Desired Output:
An overall architecture diagram (text‑based or Markdown flow chart).
A folder structure (e.g.,
src/,tests/,cache/).Full Python code for:
api_client.py(handles Congress API, pagination, back‑off).gpt_oss_client.py(handles local GPT‑OSS calls).cache.py(simple SQLite wrapper).main.py(CLI entry point).models.py(dataclasses for Legislator, Bill, Vote).README.mdwith setup instructions.Sample unit‑test skeletons.
A brief discussion of alternative architectures (e.g., async, Docker, CI).
Constraints:
- Use only standard library +
requests+sqlite3.- Do not expose the API key in code—read it from an environment variable named
CONGRESS_API_KEY.- GPT‑OSS calls must use the same bearer‑token pattern as the Congress API.
Optional Extras (if time permits):
- A simple Flask UI that shows the same table in a web page.
- Logging for every API call and GPT‑OSS request.
i want to be able to look up a candidate and quickly at a glance see their voting record on bills, latest bills first. I want to be able to scrooll all the way back through their whole history (endless scroll until at the end of their career). I would want Decision - Bill Title. When i click on the block that show the info for the bill, it would expand to give a summary of the the bill that the AI generated with the key measures that this bill ensured. It's important that this information be impartial but the truth. The bot should truly summarize what’s in the bill and not just what the bill says that it will do at the very beginning.
All data and summarization result need to be stored in a local db that could be used for later analysis, accesible by the same api that the app would be using to display this info per candidate.
When you begin the search and start typing in the politician name i want it to auto fill in as you type the name of the person, give suggestiosn for the person you’re trying to reach so Full Name, State, Party Affiliation
The API Key is store in the .env file. Don't expose it and don't hard code it into the code
Do not leak my private information if requests fail. Just give up and say that you're done as much work as you can, and I will come take a look later.
Be mindful of throttle limtes (1000 / 1hr), but you should try to stay way below that so my internet doesnt' suffer