Last active
July 19, 2023 09:25
-
-
Save seidtgeist/019a811ef41fa0288d418657ea6067d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
set -euo pipefail | |
SYSTEM_PROMPT=$(cat <<EOF | |
You're given text extracted from a PDF or OCRed from an image. | |
It's relating to a payment. | |
Analyze it step by step: | |
1. Summarize the text | |
2. Extract the following information: | |
- Document langauge | |
- Payee name | |
- Payee IBAN: First if multiple | |
- Amount | |
- Reference: Order/invoice/reference number | |
- Purpose: Short summary translated to document language | |
3. Respond with the following template and fill in the extracted information: | |
BCD | |
002 | |
1 | |
SCT | |
\$PAYEE_NAME | |
\$PAYEE_IBAN | |
EUR\$AMOUNT | |
CHAR | |
\$REFERENCE | |
\$PURPOSE | |
EOF | |
) | |
# 1. Extract text | |
# 2. Feed text into GPT4 with system prompt | |
# 3. Tee output to stderr for progress | |
# 4. Ignore stdout until beginning of EPC QR code content | |
# 5. Pipe EPC QR code into qr for scannable ASCII QR code output | |
pipx run pypdfium2 extract-text $1 | pipx run llm -m4 -s $SYSTEM_PROMPT | tee /dev/stderr | awk '/BCD/,EOF' | pipx run --spec qrcode qr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment