AI desktop path: plain-HTML Review and Cost tabs over the Qt bridge, gate in Python

ai_sections.html pastes into the no-AI dashboard.html; ai_bridge.py adds one
ai_request slot that hands every AI contract request (incl. GET /roi) to the
review backend's dispatch(). Desktop page check reruns the web review and cost
cases plus a tampered-page gate case. Eval fixture e-pyqt-ai added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
VasanthandClaude Opus 5.5 committed 2026-10-16 15:32:45 +05:30
1 parent 128f153f84
commit d89dce3c33
13 files changed
+203 -14

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
# Invoice intake bot
A desktop RPA bot. It reads each scanned invoice in `inbox/` with an LLM
(`extractor.py`) and queues the fields for a person to review.
The operator window will be a PyQt6 app.
Run the bot on its own:
```
python -m bot
```
+31
View File
@@ -0,0 +1,31 @@
"""Invoice intake bot: picks up scanned invoices and extracts their fields with an LLM.
Start it with: python -m bot"""
import time
from pathlib import Path
INBOX = Path(__file__).with_name("inbox")
def say(line):
print(line, flush=True)
time.sleep(0.2)
def main():
say("[step 1] Initializing")
docs = sorted(INBOX.glob("*.pdf"))
say(f"[inbox] {len(docs)} invoices waiting")
say("[step 2] Extracting fields")
for i, doc in enumerate(docs, 1):
try:
from extractor import extract_invoice # the LLM call
rows = extract_invoice(doc.read_bytes(), "application/pdf")
say(f"[extract] {doc.name}: {len(rows)} fields ({i}/{len(docs)})")
except Exception as e: # one bad document must not stop the batch
say(f"ERROR: extraction failed for {doc.name}: {type(e).__name__}")
say("[step 3] Queueing for review")
say(f"[all done] {len(docs)} invoices processed")
if __name__ == "__main__":
main()
+34
View File
@@ -0,0 +1,34 @@
"""The LLM extraction call: one scanned invoice in, its fields out, each with word scores."""
import json
from google import genai
from google.genai import types
MODEL = "gemini-2.5-flash"
FIELDS = { # field name -> mandatory
"Invoice number": True,
"Invoice date": True,
"Vendor": True,
"PO number": False,
"Due date": True,
"Total": True,
}
PROMPT = (
"Read this invoice. Return JSON: a list of {field, value, word_scores}, one per field in "
+ ", ".join(FIELDS)
+ ". word_scores is your 0-1 legibility score for each word of the value. Use an empty "
"value and no scores when a field isn't on the page."
)
def extract_invoice(document: bytes, mime_type: str) -> list[dict]:
client = genai.Client() # credentials come from the environment
response = client.models.generate_content(
model=MODEL,
contents=[types.Part.from_bytes(data=document, mime_type=mime_type), PROMPT],
config=types.GenerateContentConfig(response_mime_type="application/json"),
)
rows = json.loads(response.text)
for row in rows:
row["mandatory"] = FIELDS.get(row["field"], False)
return rows
+2
View File
@@ -0,0 +1,2 @@
%PDF-1.4
% sample invoice placeholder
+2
View File
@@ -0,0 +1,2 @@
%PDF-1.4
% sample invoice placeholder
+3
View File
@@ -0,0 +1,3 @@
PyQt6
PyQt6-WebEngine
google-genai