fix: fallback CPU embedding + protection CPAM contre crash OOM

- SentenceTransformer : fallback CPU si CUDA OOM (Ollama peut occuper la VRAM)
- Bloc CPAM dans main.py : try/except pour éviter crash fatal du pipeline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dom
2026-02-13 06:11:38 +01:00
parent e90450903e
commit 0d3cb83f12
2 changed files with 29 additions and 15 deletions

View File

@@ -355,18 +355,21 @@ def main(input_path: str | None = None) -> None:
# Contrôle CPAM : enrichir le dossier principal (fusionné ou dernier)
if cpam_data and subdir:
from .control.cpam_parser import match_dossier_ogc
controles = match_dossier_ogc(subdir, cpam_data)
if controles:
from .control.cpam_response import generate_cpam_response
target = merged if merged else (group_dossiers[-1] if group_dossiers else None)
if target:
logger.info(" CPAM : %d contrôle(s) pour %s", len(controles), subdir)
for ctrl in controles:
text, sources = generate_cpam_response(target, ctrl)
ctrl.contre_argumentation = text
ctrl.sources_reponse = sources
target.controles_cpam = controles
try:
from .control.cpam_parser import match_dossier_ogc
controles = match_dossier_ogc(subdir, cpam_data)
if controles:
from .control.cpam_response import generate_cpam_response
target = merged if merged else (group_dossiers[-1] if group_dossiers else None)
if target:
logger.info(" CPAM : %d contrôle(s) pour %s", len(controles), subdir)
for ctrl in controles:
text, sources = generate_cpam_response(target, ctrl)
ctrl.contre_argumentation = text
ctrl.sources_reponse = sources
target.controles_cpam = controles
except Exception:
logger.exception("Erreur CPAM pour %s", subdir)
# Écrire le dossier fusionné (après enrichissement CPAM éventuel)
if merged is not None and subdir: