Fix model config alignment and improve error messaging
- Replace sys.exit(1) with ValueError in _validate_models() — prevents killing the worker process on invalid model keys - ModelConfiguration now reads defaults from core.config instead of hardcoding model keys - Fix .env: google-gemini20 → google-gemini31 (align with MODEL_MAPPINGS) - Improve "No data extracted" error message to explain the document must be a marketing brief Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c6025b02e3
commit
d71a044a3c
3 changed files with 28 additions and 11 deletions
|
|
@ -439,13 +439,11 @@ class DocumentAnalyzer:
|
|||
# Validate primary models
|
||||
for model in self.primary_models:
|
||||
if model not in valid_models:
|
||||
logging.error(f"Invalid primary model: {model}. Available: {valid_models}")
|
||||
sys.exit(1)
|
||||
|
||||
# Validate consolidation model
|
||||
raise ValueError(f"Invalid primary model: {model}. Available: {valid_models}")
|
||||
|
||||
# Validate consolidation model
|
||||
if self.consolidation_model not in valid_models:
|
||||
logging.error(f"Invalid consolidation model: {self.consolidation_model}. Available: {valid_models}")
|
||||
sys.exit(1)
|
||||
raise ValueError(f"Invalid consolidation model: {self.consolidation_model}. Available: {valid_models}")
|
||||
|
||||
# Validate API keys
|
||||
api_key_status = config.validate_api_keys()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,20 @@ from enum import Enum
|
|||
from typing import Dict, List, Optional, Any
|
||||
import uuid
|
||||
|
||||
def _default_primary_models() -> List[str]:
|
||||
try:
|
||||
from core.config import config
|
||||
return config.get_default_primary_models()
|
||||
except Exception:
|
||||
return ['anthropic-sonnet45', 'google-gemini31']
|
||||
|
||||
def _default_consolidation_model() -> str:
|
||||
try:
|
||||
from core.config import config
|
||||
return config.DEFAULT_CONSOLIDATION_MODEL
|
||||
except Exception:
|
||||
return 'anthropic-sonnet45'
|
||||
|
||||
class JobPhase(Enum):
|
||||
"""Processing phases for a job"""
|
||||
QUEUED = "QUEUED"
|
||||
|
|
@ -116,10 +130,8 @@ class ModelInfo:
|
|||
@dataclass
|
||||
class ModelConfiguration:
|
||||
"""Model selection configuration for a job"""
|
||||
primary_models: List[str] = field(default_factory=lambda: [
|
||||
'openai-gpt51', 'anthropic-sonnet45', 'google-gemini31'
|
||||
])
|
||||
consolidation_model: str = 'openai-gpt51'
|
||||
primary_models: List[str] = field(default_factory=_default_primary_models)
|
||||
consolidation_model: str = field(default_factory=_default_consolidation_model)
|
||||
minimum_success_threshold: int = 1
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -58,7 +58,14 @@ async def run_job(job: Job, ws_manager: WebSocketManager) -> bool:
|
|||
result = await analyzer.process_document_multi_model(job.upload_path, progress)
|
||||
|
||||
if not result.raw_data:
|
||||
error_msg = "No data extracted from document"
|
||||
notes = "; ".join(result.processing_notes) if result.processing_notes else ""
|
||||
error_msg = (
|
||||
"No marketing deliverables found in this document. "
|
||||
"Please ensure you upload a marketing brief (PDF, PPTX, DOCX, or XLSX) "
|
||||
"containing campaign assets or deliverables."
|
||||
)
|
||||
if notes:
|
||||
error_msg += f" (Details: {notes})"
|
||||
await progress.emit_failure(error_msg)
|
||||
return False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue