KIE: bóc 2 lượt theo trang, mặc định Qwen3.5-4B

- Lượt 1: document_type, document_number, issued_date, issuing_authority,
  title chỉ trên 3 trang đầu.
- Lượt 2: signer chỉ trên trang DLA có Signature/Stamp; ưu tiên trang có
  Stamp trong thân trang (bỏ dấu giáp lai ở dải 10% mép), tối đa
  IDP_KIE_MAX_PAGES trang cuối; không có trang nào thì không gọi model.
- Viết lại description các trường theo yêu cầu nghiệp vụ.
- normalize_answer nhận signer trả về dạng mảng.
- IDP_KIE_URL/IDP_KIE_MODEL mặc định trỏ Qwen3.5-4B cổng 9224, không còn
  dùng chung model OCR (Chandra DLA sinh JSON lan man khi làm KIE).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-25 04:15:58 +00:00
parent 2039ddb487
commit 904134a224
5 changed files with 145 additions and 61 deletions

View File

@@ -17,8 +17,8 @@ class Settings:
ocr_model: str = os.getenv("IDP_OCR_MODEL", "chandra")
ocr_backend: str = os.getenv("IDP_OCR_BACKEND", "http") # http hoặc pdf_text
kie_enabled: bool = os.getenv("IDP_KIE_ENABLED", "1").lower() in ("1", "true", "yes")
kie_url: str = os.getenv("IDP_KIE_URL") or os.getenv("IDP_OCR_URL", "http://localhost:9222/v1/chat/completions")
kie_model: str = os.getenv("IDP_KIE_MODEL") or os.getenv("IDP_OCR_MODEL", "chandra")
kie_url: str = os.getenv("IDP_KIE_URL", "http://localhost:9224/v1/chat/completions")
kie_model: str = os.getenv("IDP_KIE_MODEL", "qwen3.5-4b")
kie_max_pages: int = int(os.getenv("IDP_KIE_MAX_PAGES", "5"))
kie_timeout: int = int(os.getenv("IDP_KIE_TIMEOUT", "300"))
kie_max_tokens: int = int(os.getenv("IDP_KIE_MAX_TOKENS", "2048"))