Skip to main content

LLM plugin for analyzing FEC campaign finance filings

Project description

A plugin for the Python llm library that assists in analyzing federal campaign finance filings.

PyPI License

llm-fecfile is an LLM plugin for analyzing FEC (Federal Election Commission) campaign finance filings. This plugin allows you to load FEC filings as fragments and analyze them using natural language through the LLM command-line tool.

Installation

Install this plugin in the same environment as LLM:

llm install llm-fecfile

Usage

The plugin provides a fragment loader with the fec: prefix that loads FEC campaign finance filings and provides structured analysis instructions to help you understand the data.

Basic Usage

# Load and analyze a specific FEC filing by ID
llm -f fec:1896830 "What are the key financial aspects of this filing?"

# Ask about specific aspects of the filing
llm -f fec:1896830 "Who are the largest contributors?"

# Get an overview of spending patterns
llm -f fec:1896830 "What are the biggest expenditures and what were they for?"

What the Fragment Provides

When you use -f fec:FILING_ID, the plugin:

  1. Loads the complete FEC filing using the fecfile library
  2. Provides response style instructions to ensure clear, readable analysis
  3. Includes form-specific guidance based on the filing type (F1, F2, F3, F99, etc.)
  4. Offers detailed field mapping for contributions, disbursements, and other itemizations
  5. Includes the complete raw filing data in JSON format for comprehensive analysis

The fragment includes specialized instructions for different form types:

  • F1/F1A: Committee registration and organizational details
  • F2/F2A: Candidate declarations and information
  • F3/F3P/F3X: Financial reports with receipts, disbursements, and itemizations
  • F99: Miscellaneous text filings

Example Queries

Once you've loaded a filing as a fragment, you can ask various questions:

Financial Analysis

llm -f fec:1896830 "What's the total amount raised and spent in this reporting period?"
llm -f fec:1896830 "What's the cash on hand at the end of this period?"
llm -f fec:1896830 "Is this an amendment? If so, what filing does it amend?"

Contribution Analysis

llm -f fec:1896830 "Who are the top 10 individual contributors?"
llm -f fec:1896830 "What contributions came from California?"
llm -f fec:1896830 "Show me all contributions over $2,000"

Expenditure Analysis

llm -f fec:1896830 "What are the largest expenditures?"
llm -f fec:1896830 "How much was spent on advertising?"
llm -f fec:1896830 "Who received the most money from this committee?"
llm -f fec:1896830 "What types of expenses are listed?"

Time-based Analysis

llm -f fec:1896830 "How many days does this filing cover?"
llm -f fec:1896830 "What was the average daily fundraising rate?"

Understanding FEC Filings

The plugin provides guidance for understanding different schedules in FEC filings:

  • Schedule A: Individual contributions received (itemized contributions $200+)
  • Schedule B: Disbursements and expenditures (itemized expenditures $200+)
  • Schedule C: Loans received
  • Schedule D: Debts and obligations
  • Schedule E: Independent expenditures

Finding Filing IDs

You can find FEC filing IDs in several ways:

  1. FEC Website: Visit fec.gov and search for a committee
  2. Direct URLs: Filing IDs appear in URLs like https://docquery.fec.gov/dcdev/posted/1690664.fec
  3. FEC API: Use the FEC API to search for filings

Multi-Filing Analysis

You can load multiple filings to compare them:

# Compare two different filings
llm -f fec:1896830 -f fec:1893645 "Compare the fundraising performance between these two filings"

Limitations

  • Filing Availability: Not all filings may be immediately available through the FEC's API
  • Network Dependency: Requires internet connection to fetch filing data
  • Large Filings: Very large filings may take time to load and process

Development

To develop this plugin:

git clone https://github.com/dwillis/llm-fecfile
cd llm-fecfile
pip install -e .

Running Tests

python test_plugin.py

The test suite includes:

  • Filing ID validation tests
  • Form type instruction tests
  • Fragment creation tests
  • Error handling tests
  • Manual integration tests with real filings

Dependencies

This plugin requires Python 3.9 or greater.

This plugin depends on:

  • llm: The LLM command-line tool and fragment system
  • fecfile: Python library for parsing FEC filings

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

When contributing:

  1. Ensure tests pass with python test_plugin.py
  2. Follow the existing code style
  3. Update documentation for any new features

Acknowledgments

  • Built on the excellent fecfile library by Evan Sonderegger
  • Inspired by the LLM tool and fragments system by Simon Willison
  • Uses data from the Federal Election Commission

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_fecfile-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_fecfile-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file llm_fecfile-0.1.0.tar.gz.

File metadata

  • Download URL: llm_fecfile-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.1

File hashes

Hashes for llm_fecfile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 97bef7d7bfdacc1b4ab77106981b83b3477ed498197646715337453263aa7556
MD5 7db30d0d5aab75d3743bcd706f6047cf
BLAKE2b-256 f46022ab8e8289f85166c51e628cf3aabe655a055fdb9ffd947029c51c0e4721

See more details on using hashes here.

File details

Details for the file llm_fecfile-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_fecfile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab963bfc49db215fdf7416559d815622f74800adf7f7d9fddd1c372932d06bc1
MD5 b9846e1984a7dd9502fef81fe7152bc9
BLAKE2b-256 4a9ca262e0e54e35d12bdde4c57dda43b62813c7b9002dad2bacef1e4c9e451a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page