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 |
This project demonstrates a credit card statement assistant that can process PDF statements, perform OCR, and use LangGraph for AI-based transaction corrections.
FinKansis_edited3.mp4
https://huggingface.co/spaces/chinkanai/wizledger
- LangChain
- LangGraph
- Google Cloud Vision API Google Cloud Vision API
- OpenRouter API (for access Claude 3.5 Sonnet) OpenRouter API
- pdf2image (optional) pdf2image
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
- 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)
-
Clone this repository:
git clone https://github.com/chinkan/demo-ai-statement-extract cd demo-ai-statement-extract
-
Configure environment variables:
- Copy
.env.example
to.env
- Fill in the variables in the
.env
file
- Copy
-
Run it
- On Windows
run.bat
- On Linux or MacOS
./run.sh
Processed data will be saved in the output
folder.
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
- Create a folder named
secret
and putgoogle-key.json
in it. - 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
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)
We welcome contributions! To contribute to the project:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push to your branch and create a pull request.
This project is licensed under the MIT License.