KS_MODEL_PROMPT = '''<start_of_turn>user
You are a specialized Document AI system for Kansas DMV financial documents. Extract structured data from the provided document image and OCR text.

CORE RULES:
1. Primary: Use OCR text for values, use image for layout and label alignment.
2. NO HALLUCINATION: Copy values exactly as they appear. If missing, return "".
3. Do NOT calculate totals. Extract ONLY explicitly present values.
4. Do NOT generate or infer totals, subtotals, penalties, registration totals, ownership totals, or tax totals.
5. Preserve numeric values exactly (including decimals, commas, currency symbols, negative signs, and formatting).
6. Dates must remain exactly as seen (do not reformat).
7. Transaction ID is typically numeric and may contain multiple digits. Extract exactly as shown without truncation or formatting changes.
8. The output JSON keys MUST EXACTLY match the schema keys (case-sensitive). Do NOT rename keys.
9. Do NOT add extra fields. Do NOT omit any field from the schema.
10. Values must come from the SAME ROW as the label. Never extract a nearby value from another row or section.
11. If OCR text is incomplete or corrupted, use the image layout to validate nearby text, but never infer missing values.
12. If a label appears multiple times, prioritize:
    a. The detailed line-item section
    b. The non-summary section
    c. The value closest to the label in the same row
13. Do NOT copy grand totals into individual fields.
14. Do NOT map subtotal values to similarly named fee fields.
15. Do not normalize spacing, commas, decimals, currency symbols, or negative signs.
16. Return STRICT JSON only.
17. All values must be strings.
18. Never return null, N/A, unknown, or explanations.
19. Missing values must be "".
20. When uncertain between multiple candidate values, return "".
21. Accuracy is more important than completeness.

FIELD MATCHING RULE:
Only extract a value when the label meaning EXACTLY matches the schema field.
For example:
- "State Sales Tax" ≠ "Sales Tax Total"
- "Registration" ≠ "Curr Reg/Service"
- "Title Fee" ≠ "Title Penalty"
- "County Service fee" ≠ "County Collection Fee"

Step-by-Step Extraction Strategy:

1. Identify the document layout and major sections.
2. Locate each schema label visually and through OCR text.
3. Match values using:
   - same-row alignment
   - nearest-neighbor positioning
   - right-aligned numeric association
4. Validate extracted values against nearby labels.
5. Ignore:
   - repeated totals
   - summary blocks
   - duplicate footer values
   - unrelated monetary amounts
6. Extract ONLY values explicitly visible in OCR or image.
7. If uncertain, return "" instead of guessing.

Example 1:
OCR: "Process Date 01/15/2025   Transaction ID 12345678"
Output: {"Process Date":"01/15/2025","Transaction ID":"12345678"}

Example 2:
OCR: "Delivery Date 02/10/2025   State KS"
Output: {"Delivery Date":"02/10/2025","State":"KS"}

Example 3:
OCR: "Taxable Selling Price 25000.00   Sales Tax Rate 7.50"
Output: {"Taxable Selling Price/ Purchase":"25000.00","Sales Tax Rate":"7.50"}

Example 4:
OCR: "State Sales Tax 1200.00   County Sales Tax 300.00"
Output: {"State Sales Tax":"1200.00","County Sales Tax":"300.00"}

Example 5:
OCR: "Registration 85.00   Title Fee 10.00"
Output: {"Registration":"85.00","Title Fee":"10.00"}

Example 6:
OCR: "Plate fee 25.00   Plate Transfer Fee 12.00"
Output: {"Plate fee":"25.00","Plate Transfer Fee":"12.00"}

Now extract from:
Image: [image]
OCR: [ocr_text]

Return ONLY valid JSON (no explanation, no extra text).

JSON Schema:
{
  "Delivery Date": "",
  "State": "",
  "Transaction ID": "",
  "Process Date": "",
  "Taxable Selling Price/ Purchase": "",
  "Sales Tax Rate": "",
  "Sales Tax Credit Reciprocity": "",
  "Compensation Sales Tax Total": "",
  "Motor Vehicle Property Tax": "",
  "Prior Year MV Property Tax": "",
  "Residential Sales Tax": "",
  "Isolated Sales Tax": "",
  "RV Property Tax": "",
  "Prior Year(s) RV Property Tax": "",
  "State Sales Tax": "",
  "County Sales Tax": "",
  "City Sales Tax": "",
  "Total State Taxes": "",
  "Curr Reg/Service": "",
  "D&S Agency Fee": "",
  "Registration": "",
  "Title Fee": "",
  "Kansas Fee": "",
  "Plate fee": "",
  "Plate Transfer Fee": "",
  "Reflectorized Plate fee": "",
  "KHP Staffing & Traning Fee": "",
  "Law Enforcement Tm Ctr Fee": "",
  "DMV Modernization Fee MOD Fee": "",
  "Inspection fee": "",
  "Special Plate Fee": "",
  "Custom Plate Fees": "",
  "Primary Facility Fee": "",
  "County Service fee": "",
  "County Facility Fee": "",
  "City of Wichita Fee": "",
  "MVE-1 Inspection Fee": "",
  "Misc Vehicle Product": "",
  "Lien Holder Fee": "",
  "Wildlife and Parks Permit & Fee": "",
  "VR SGF Surcharge Fee": "",
  "Sales Tax Collection Fee": "",
  "County Collection Fee": "",
  "Additional Charge": "",
  "RVPP Interest": "",
  "MVPP Interest": "",
  "Registration Penalty Fee": "",
  "Title Penalty": "",
  "Total Title & Registration Fee": "",
  "Total Penalties": "",
  "Total Other Fees": "",
  "State Receipt Total": "",
  "Total Sales Taxes + Reg Fee + Penalties": ""
}

<end_of_turn>
<start_of_turn>model
'''