feat: Enhance GUI and processing services with new batch processing and estimation features, update concurrency settings, and improve styling organization.
This commit is contained in:
@@ -6,7 +6,10 @@ import os
|
||||
import logging
|
||||
import asyncio
|
||||
import openai
|
||||
from typing import List, Dict, Any, Optional, Tuple, Callable, Awaitable
|
||||
from typing import List, Dict, Any, Optional, Tuple, Callable, Awaitable, TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from application.service import InvoiceProcessingService
|
||||
|
||||
from application.profiles import get_profile
|
||||
from application.prompts import PromptBuilder
|
||||
@@ -21,7 +24,7 @@ from core.csv_utils import rows_from_data
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class BatchProcessor:
|
||||
def __init__(self, service):
|
||||
def __init__(self, service: 'InvoiceProcessingService'):
|
||||
"""
|
||||
Args:
|
||||
service: Instancia de InvoiceProcessingService para delegar la extracción individual.
|
||||
|
||||
@@ -50,7 +50,7 @@ class RetrySettings(BaseSettings):
|
||||
|
||||
class ProcessingSettings(BaseSettings):
|
||||
"""Configuración de procesamiento y concurrencia."""
|
||||
concurrency_limit: int = Field(20, validation_alias=AliasChoices("CONCURRENCY_LIMIT"))
|
||||
concurrency_limit: int = Field(100, validation_alias=AliasChoices("CONCURRENCY_LIMIT"))
|
||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
Encapsula la lógica de estimación previa al procesamiento.
|
||||
"""
|
||||
import os
|
||||
from typing import List, Dict, Any, Optional
|
||||
from typing import List, Dict, Any, Optional, TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from application.service import InvoiceProcessingService
|
||||
|
||||
from application.profiles import get_profile
|
||||
from application.prompts import PromptBuilder
|
||||
@@ -13,7 +16,7 @@ from application.file_discovery import get_sorted_radicados, find_file_for_type_
|
||||
from core.utils import collect_radicado_docs, collect_documents_flat
|
||||
|
||||
class Estimator:
|
||||
def __init__(self, service):
|
||||
def __init__(self, service: 'InvoiceProcessingService'):
|
||||
self.service = service
|
||||
|
||||
def estimate(
|
||||
|
||||
@@ -32,11 +32,16 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class InvoiceProcessingService:
|
||||
"""Fachada de negocio para extraer y transformar datos de facturas."""
|
||||
def __init__(self, extractor: InvoiceExtractorStrategy) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
extractor: InvoiceExtractorStrategy,
|
||||
batch_processor_factory: Callable[[InvoiceProcessingService], BatchProcessor],
|
||||
estimator_factory: Callable[[InvoiceProcessingService], Estimator]
|
||||
) -> None:
|
||||
self.extractor = extractor
|
||||
# Componentes delegados
|
||||
self.batch_processor = BatchProcessor(self)
|
||||
self.estimator = Estimator(self)
|
||||
# Componentes delegados inyectados mediante factories para evitar dependencia circular directa en construcción
|
||||
self.batch_processor = batch_processor_factory(self)
|
||||
self.estimator = estimator_factory(self)
|
||||
|
||||
# Lock para escrituras concurrentes al mismo CSV desde múltiples hilos
|
||||
# (Mantenido por retrocompatibilidad si se accede directo, aunque BatchProcessor usa su propio CSVManager)
|
||||
|
||||
Reference in New Issue
Block a user