feat(ai): refine extraction prompt with human-readable size conversions

- Add SIZE CONVERSION RULES section (critical) with explicit thresholds
- Convert ≥1600GB to TB format (e.g., 1600GB → 1.6TB)
- Convert memory ≥1024MB to GB format
- Update Item field examples with human-readable sizes
- Update Size field definition to emphasize HUMAN-READABLE format
- Update OCR key definition with size conversion examples
- Apply rules consistently across all size-related fields

This ensures AI-extracted items display sizes in user-friendly format
and improves OCR matching accuracy with normalized size representations.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-04-17 12:57:06 +03:00
parent da83c91a5b
commit 6aabf3eac1
3 changed files with 108 additions and 40 deletions

View File

@@ -105,25 +105,32 @@ def startup_event():
default_prompt = (
"Extract hardware specifications with PRECISE formatting.\n"
"For any field, do not add comments in parenthesis or measurement units in Item name.\n\n"
"SIZE CONVERSION RULES (CRITICAL - Apply to all size fields):\n"
" Convert sizes to HUMAN-READABLE format:\n"
" • Storage ≥1600GB: convert to TB (e.g., '1600GB''1.6TB', '2048GB''2TB', '8192GB''8TB')\n"
" • Storage 512GB-1599GB: keep as GB (e.g., '512GB', '1TB' if labeled as 1000GB)\n"
" • Memory ≥1024MB: convert to GB (e.g., '1024MB''1GB')\n"
" • Cables/length: express in meters (e.g., '5m', '30m')\n"
" Apply this rule to: Item field size prefix, Size field, and OCR key sizes.\n\n"
"ITEM FIELD FORMAT (Critical):\n"
"[<size_or_length>] <type> <vendor> <connector> <part_number>\n"
" <size_or_length>: GB/TB for storage, meters for cables (e.g., '2m', '256GB', '2TB'). Omit diameter/mm measurements.\n"
" <size_or_length>: HUMAN-READABLE format - GB/TB for storage, meters for cables (e.g., '2m', '256GB', '1.6TB'). Omit diameter/mm measurements.\n"
" <type>: DDR3/DDR4/DDR5/SSD/HDD/NVMe/SAS/SATA/Patchcord/Fiber/Cable/Transceiver etc.\n"
" <vendor>: HP/HPE/Dell/Samsung/Cisco/Lenovo/Hynix etc.\n"
" <connector>: RJ45/LC-LC/MPO/U.3/SATA/SAS/LC/ST etc. Omit if N/A.\n"
" <part_number>: PN only if visible on label. Omit serial numbers.\n"
"Examples: '5m Patchcord LC-LC' / '256GB SSD Samsung SAS' / '128GB DDR4 Hynix SK-234' / '2TB NVMe HP U.3'\n\n"
"Examples: '5m Patchcord LC-LC' / '256GB SSD Samsung SAS' / '128GB DDR4 Hynix SK-234' / '1.6TB NVMe HP U.3' / '8TB HDD Seagate SATA'\n\n"
"TYPE: Item asset class (DDR3/SSD/NVMe/Patchcord/SFP etc.)\n"
"DESCRIPTION: Technical details max 5 words (e.g., 'High speed fiber optic cable'). Omit size/length here.\n"
"CATEGORY: Broad ecosystem (Memory, Storage, Network, Cabling, etc.)\n"
"CONNECTOR: Physical interface type (e.g., 'LC', 'RJ45', 'U.3')\n"
"SIZE: Capacity or length ONLY (e.g., '256GB', '2m')\n"
"SIZE: HUMAN-READABLE capacity or length ONLY (e.g., '256GB', '1.6TB', '2m'). No serial numbers or comments.\n"
"COLOR: Physical color if distinguishing.\n"
"PartNr: Part number only (no serial numbers)\n"
"OCR: Robust matching key. Include: core type + vendor + key identifiers + common variations.\n"
" Example for '5m Patchcord LC-LC': 'PATCHCORD 5M LC LC CAT6 FIBER'\n"
"OCR: Robust matching key. Include: core type + vendor + key identifiers + HUMAN-READABLE size + common variations.\n"
" Examples: 'PATCHCORD 5M LC LC CAT6 FIBER' / '256GB SSD SAMSUNG' / '1.6TB NVME HP' / '128GB DDR4 HYNIX'\n"
" Include abbreviations: 'DDR4'/'DDR' or 'SSD'/'SSDS' or 'HP'/'HPE' or 'NVMe'/'NVME'\n"
" Format: ALL UPPERCASE, space-separated tokens, NO special chars. Skip serial numbers."
" Format: ALL UPPERCASE, space-separated tokens, NO special chars. Skip serial numbers. Use human-readable sizes."
)
# Wrap in JSON instructions for reliable parsing