Skip to content

chinkan/wizledger-statement-processor

Repository files navigation

title emoji colorFrom colorTo sdk sdk_version app_file pinned license
WizLedger - Monthly Statement Processor
💳
indigo
yellow
gradio
4.43.0
src/ui.py
false
mit

WizLedger - Monthly Statement Processor

Introduction

This project demonstrates a credit card statement assistant that can process PDF statements, perform OCR, and use LangGraph for AI-based transaction corrections.

Demo

FinKansis_edited3.mp4

Try it on HuggingFace

https://huggingface.co/spaces/chinkanai/wizledger

Technologies

LangGraph

Here is the graph of the workflow:

graph TD
    Start((Start)) --> A[ocr]
    A --> B[extract]
    B --> C[display_transactions]
    C --> D[get_human_input]
    D --> E[process_human_input]
    E --> F{check_if_done}
    F -->|continue| C
    F -->|done| G[store_csv]
    G --> End((End))

    style Start fill:#4CAF50,stroke:#333,stroke-width:2px
    style End fill:#FF5722,stroke:#333,stroke-width:2px
Loading

Prerequisites

  • Python 3.10 or later
  • OpenRouter API key (Get it here)
  • Enable Google Cloud Vision API (Get service account keys here)
  • Poppler (for pdf2image, optional)

Installation

  1. Clone this repository:

    git clone https://github.com/chinkan/demo-ai-statement-extract
    cd demo-ai-statement-extract
  2. Configure environment variables:

    • Copy .env.example to .env
    • Fill in the variables in the .env file
  3. Run it

    • On Windows
    run.bat
    • On Linux or MacOS
    ./run.sh

Output

Processed data will be saved in the output folder.

Docker run from build local

docker build -t wizledger .
docker run -d -p 7860:7860 \
    -e OPENROUTER_MODEL="anthropic/claude-3.5-sonnet" \
    -e OPENROUTER_API_URL="https://openrouter.ai/api/v1" \
    -e OPENROUTER_API_KEY="<replace with your openrouter api key>" \
    -e GOOGLE_APPLICATION_CREDENTIALS="/app/secret/google-key.json" \
    -v ./secret:/app/secret \
    wizledger

Docker run from huggingface

  1. Create a folder named secret and put google-key.json in it.
  2. Run the following command:
docker run -it -p 7860:7860 --platform=linux/amd64 \
	-e OPENROUTER_MODEL="anthropic/claude-3.5-sonnet" \
	-e OPENROUTER_API_URL="https://openrouter.ai/api/v1" \
	-e OPENROUTER_API_KEY="<replace with your openrouter api key>" \
	-e GOOGLE_APPLICATION_CREDENTIALS="/app/secret/google-key.json" \
    -v ./secret:/app/secret \
	registry.hf.space/chinkanai-wizledger:latest python src/ui.py

API

import requests
import json
# Process a new statement
url = "http://localhost:7860/process"
files = {
    'statement': ('statement.pdf', open('path/to/statement.pdf', 'rb'), 'application/pdf'),
}
response = requests.post(url, files=files)
result = response.json()
print(result['result'])
thread_id = result['thread_id']

# Continue processing
url = "http://localhost:7860/continue_processing"
data = {
    'human_input': 'Some human input',
    'thread_id': thread_id
}
response = requests.post(url, json=data)
print(response.json())
result = response.json()

# Export transactions
url = "http://localhost:7860/export_transactions"
data = {'output': json.dumps(result)}
response = requests.post(url, json=data)

# Display the transactions
import pandas as pd
import io
df = pd.read_csv(io.BytesIO(response.content), encoding='utf-8')
display(df)

Contributing

We welcome contributions! To contribute to the project:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push to your branch and create a pull request.

License

This project is licensed under the MIT License.

About

Demo of credit card monthly statement extract using AI

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages