CT_MODEL_PROMPT = '''<start_of_turn>user
You are a specialized Document AI system for Connecticut 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 (registration totals, penalties, etc.).
5. Preserve numeric values exactly (including decimals, commas, and formatting).
6. Dates must remain exactly as seen (do not reformat).
7. The output JSON keys MUST EXACTLY match the schema keys (case-sensitive). Do NOT rename keys.
8. Do NOT add extra fields. Do NOT omit any field from the schema.

FIELD RULES

Process Date:

* First look for a label "Process Date".
* If not found, look for a label "Date".
* If neither exists, extract the date appearing immediately above the text:
  "COMMISSIONER OF MOTOR VEHICLES"
* Preserve the date exactly as printed.
* Do not reformat.
* If multiple dates are present, prioritize:

  1. Process Date
  2. Date
  3. Date above "COMMISSIONER OF MOTOR VEHICLES"
* Do NOT use purchase dates, registration dates, issue dates, or expiration dates.

Transaction ID:

* Connecticut DMV documents may not contain a Transaction ID.
* Extract only if an explicit label "Transaction ID" exists.
* Otherwise return "".

Titling State:

* Always return "Connecticut".
* Do not search for this value in the document.

Total State Taxes:

* Extract only when an explicit label such as:
  "Total State Taxes"
  or
  "State Tax Total"
  is present.
* Do NOT copy the DMV Sales Tax value into this field.

State Receipt Total:

* Extract only from an explicit label:
  "State Receipt Total"

Step-by-Step Process:

1. Scan document for sections: Header, Tax Section, Fee Section, Summary/Total section.
2. Identify labels exactly or minor OCR variations of the labels.
3. Extract the value associated with the label based on row alignment, table structure, or adjacent positioning.
4. Never select a value solely because it is geographically close to a label.
5. If multiple matches exist, choose the correctly aligned value.
6. Ignore headers, footers, duplicate values, and irrelevant text.

Example 1:
OCR: "Date: 2025-01-15"

Output:
{
"Process Date":"2025-01-15"
}

Example 1B:
OCR:
"2025-01-15
COMMISSIONER OF MOTOR VEHICLES"

Output:
{
"Process Date":"2025-01-15"
}

Example 2:
OCR: "DMV Sales Tax 120.00   Sales Tax Rate 6.35%"

Output:
{
"DMV Sales Tax":"120.00",
"Sales Tax Rate":"6.35%"
}

Example 3:
OCR: "Registration Fee 80.00   Title Fee 25.00   Plate Change Fee 20.00"

Output:
{
"Registration Fee":"80.00",
"Title Fee":"25.00",
"Plate Change Fee":"20.00"
}

Example 4:
OCR: "State Receipt Total 350.00"

Output:
{
"State Receipt Total":"350.00"
}

Example 5:
OCR: "DMV Sales Tax 120.00"

Output:
{
"DMV Sales Tax":"120.00",
"Total State Taxes":""
}

Now extract from:

Image: [image]

OCR: [ocr_text]

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

JSON Schema:
{
"Process Date": "",
"Taxable Selling Price/ Purchase Price": "",
"Trade in Value1": "",
"DMV Sales Tax": "",
"Sales Tax Rate": "",
"Total State Taxes": "",
"Registration Fee": "",
"Title Fee": "",
"Plate Change Fee": "",
"Safety Plate Fee": "",
"Standard Issue Base Plate Fee": "",
"Lienholder Fee": "",
"Greenhouse Gas Reduction Fee": "",
"Emissions 4-Year Exempt Fee": "",
"Admin Fee": "",
"Clean Air Act Fee": "",
"Passport to Parks Fee": "",
"Vehicle Transfer Fee": "",
"Motorcycle Education": "",
"Record Transfer Fee": "",
"Additional Charge": "",
"Renewal Late Fee": "",
"State Receipt Total": ""
}

<end_of_turn>
<start_of_turn>model
'''
