ReceiptVision is a Python application combining a Telegram bot and Flask web interface. The bot scans QR codes from receipt images and queries the Proverkacheka API for details. The web interface interacts with the Ollama AI model for text queries.
- Telegram bot for extracting receipt details from QR codes.
- Flask interface for querying the Ollama AI.
- QR decoding with
pyzbaroropencv-pythonfallback. - Concurrent bot and web server operation.
- Python 3.8+
- Telegram bot token (from BotFather)
- Proverkacheka API token (
PROVERKACHEKA_TOKEN) - Ollama server with
gpt-ossmodel
-
Clone Repository:
git clone https://github.com/yourusername/receipt-vision.git cd receipt-vision -
Install Dependencies:
pip install python-telegram-bot flask requests pillow pyzbar opencv-python ollama
Install
pyzbar(requireslibzbar0) oropencv-python:- Ubuntu/Debian:
sudo apt-get install libzbar0 - macOS:
brew install zbar
- Ubuntu/Debian:
-
Set Environment Variables:
export TELEGRAM_BOT_TOKEN="your_telegram_bot_token" export PROVERKACHEKA_TOKEN="your_proverkacheka_api_token"
-
Create System Prompt: Create
system_prompt.txtin the project root. Example:You are a helpful assistant providing concise responses. -
Run Ollama Server: Follow Ollama documentation to run the server with
gpt-oss.
-
Run Application:
python main.py
Starts Telegram bot and Flask server (
http://localhost:8080). -
Telegram Bot:
- Add bot to Telegram using the token.
- Send a receipt image with a QR code.
- Receive receipt details (e.g., items, total).
-
Flask Interface:
- Visit
http://localhost:8080. - Enter a message to query Ollama AI.
- Visit
receipt-vision/
├── main.py # Main application script
├── system_prompt.txt # Ollama system prompt
├── templates/
│ └── index.html # Flask web interface template
└── README.md # This file
- Environment Variables:
TELEGRAM_BOT_TOKEN: Telegram bot token.PROVERKACHEKA_TOKEN: Proverkacheka API token.
- Constants (in
main.py):API_URL:https://proverkacheka.com/api/v1/check/getOLLAMA_MODEL:gpt-ossREQUEST_TIMEOUT: 30 seconds
- QR Code Issues: Ensure valid QR code and
pyzbaroropencv-pythoninstalled. - Ollama Errors: Verify Ollama server and
gpt-ossmodel are running. - Token Errors: Check
TELEGRAM_BOT_TOKENandPROVERKACHEKA_TOKEN.
- Fork the repository.
- Create a branch:
git checkout -b feature/your-feature. - Commit:
git commit -m 'Add feature'. - Push:
git push origin feature/your-feature. - Open a pull request.
MIT License. See LICENSE for details.