44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
# core/config.py
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
from typing import List, Dict
|
|
|
|
class Settings(BaseSettings):
|
|
# Carga las variables desde un fichero .env
|
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
|
|
|
# --- Configuración de Seguridad ---
|
|
SECRET_KEY: str
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
|
|
# --- Configuración de Google Cloud Document AI ---
|
|
GCP_PROJECT_ID: str
|
|
GCP_LOCATION: str
|
|
DOCAI_PROCESSOR_ID: str
|
|
|
|
# --- Lógica de Negocio (pedido por Jaime, datos a extraer) ---
|
|
REQUIRED_FIELDS: List[str] = [
|
|
"invoice_id",
|
|
"invoice_date",
|
|
"total_amount",
|
|
"net_amount", # Podríamos considerar renombrar esto a subtotal_amount en el futuro
|
|
"receiver_name",
|
|
"supplier_tax_id",
|
|
"total_tax_amount",
|
|
"subtotal_amount" # <-- NUEVO CAMPO
|
|
]
|
|
|
|
# --- CAMBIO PARA DEPURACIÓN ---
|
|
# Bajamos los umbrales para asegurarnos de que los datos se extraen.
|
|
CONFIDENCE_THRESHOLDS: Dict[str, float] = {
|
|
"__default__": 0.82,
|
|
"supplier_name": 0.80,
|
|
"total_amount": 0.75,
|
|
"subtotal_amount": 0.75, # Un umbral razonable
|
|
"net_amount": 0.92,
|
|
"total_tax_amount": 0.0, # Ponemos 0.0 porque no viene de DocumentAI, lo calculamos nosotros
|
|
"receiver_name": 0.74,
|
|
"supplier_tax_id": 0.46
|
|
}
|
|
# Creamos una única instancia global de la configuración
|
|
settings = Settings()
|