Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Autonomous Multi-Agent Invoice Payment System

An intelligent pipeline that automates the lifecycle of invoice processing. This system uses a local LLM (Llama 3.2 via Ollama) or xAI/OpenAI-compatible APIs to handle data extraction, inventory validation, and risk-based payment approvals.

🚀 Key Features

  • Multi-Agent Architecture: Modular agents for Ingestion, Validation, Approval, and Payment.
  • Duplicate Detection: Uses invoice_id as a primary key to prevent double processing of the same invoice.
  • Fuzzy Item Matching: Automatically corrects typos in invoice items (e.g., "WidgtA" → "WidgetA") using difflib and AI.
  • Inventory Check: Real-time stock validation against a local SQLite database.
  • Structured Logging: Appends every transaction to a single transaction_history.json file.
  • Excel Reporting: Automatically converts JSON logs into a clean audit_report.xlsx for financial review.

🛠️ Setup Instructions

1. Prerequisites

ollama run llama3.2:1b

2. Installation

Clone the repository and install the required Python libraries:

pip install ollama pdfplumber pandas openpyxl python-dotenv openai

3. Environment Configuration

Create a .env file in the root directory to store your API keys securely (this file is ignored by Git):

XAI_API_KEY=your_xai_api_key_here

4. Database Initialization

Before running the pipeline for the first time, initialize your inventory database:

python tools/database.py

This creates acme_inventory.db with default stock for WidgetA, WidgetB, and GadgetX.

💻 Usage

To process an invoice, run the main.py script and provide the path to your PDF:

python main.py --invoice invoices/sample_invoice.pdf

Workflow Summary:

  1. Ingestion: Reads PDF and converts text to JSON.
  2. Duplicate Check: Rejects the file if the invoice_id already exists in logs.
  3. Validation: Verifies item names and stock levels.
  4. Approval: Checks if the amount exceeds the $10,000 threshold for manual critique.
  5. Payment: Simulates a banking transaction and updates the Excel audit report.

📂 Project Structure

  • agents/: Logic for ingestion, validation, and approval.
  • tools/: Database management, LLM client, and structured logger.
  • logs/: Contains the transaction_history.json and audit_report.xlsx.
  • main.py: The central coordinator for the entire system.

⚠️ Security

Your .env file and logs/ folder are listed in the .gitignore to prevent sensitive API keys or transaction data from being pushed to GitHub.

About

An AI-driven Multi-Agent System that automates invoice processing using XAI and Llama 3.2:1b. It features PDF data extraction, inventory validation via SQLite, and risk-based approval gates. Includes built-in duplicate detection, structured JSON logging, and automatic Excel audit reports to ensure secure and efficient financial workflows.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages