Files
IPSExtractor/application/profiles.py
T

34 lines
1.1 KiB
Python

"""Perfiles de extracción.
Define configuraciones por tipo de documento para guiar prompts, envoltura
de resultados y agregaciones especiales en CSV.
"""
from __future__ import annotations
from typing import Dict, List, Optional, TypedDict
class Profile(TypedDict, total=False):
name: str
wrap_root: Optional[str]
default_instruction: str
aggregate_list_paths: List[str]
DEFAULT_INVOICE_INSTRUCTION = (
"Extrae los datos de la factura a un JSON, identificando la tabla principal por sus columnas (código, cantidad, valor unitario) para crear un array con la clave fija 'items', y usando las etiquetas literales del documento como claves para todo el resto de la información. No incluyas el campo 'observaciones' en el JSON. Ten especial cuidado en no confundir el número de autorización con el código."
)
PROFILES: Dict[str, Profile] = {
"invoice": {
"name": "invoice",
"wrap_root": None,
"default_instruction": DEFAULT_INVOICE_INSTRUCTION,
"aggregate_list_paths": [],
},
}
def get_profile(name: str) -> Profile:
key = (name or "invoice").lower()
return PROFILES.get(key, PROFILES["invoice"]) # por defecto factura