Yeetek commited on
Commit
3344ed4
·
verified ·
1 Parent(s): 68171c1

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -62,17 +62,23 @@ async def lifespan(app: FastAPI):
62
  logger.info(f"Environment: {'HuggingFace Spaces' if settings.is_huggingface_spaces else 'Development'}")
63
  logger.info(f"Anthropic Model: {settings.anthropic_model.value}")
64
 
65
- # Initialize model manager and validate Anthropic connection
66
  model_manager = get_model_manager()
67
- health_status = await model_manager.health_check()
68
 
69
- # Check if at least one model is healthy
70
- healthy_models = [model for model, status in health_status.items() if status.get("healthy", False)]
71
- if healthy_models:
72
- app_state["anthropic_client_initialized"] = True
73
- logger.info(f"Anthropic integration initialized successfully with {len(healthy_models)} healthy models")
74
- else:
75
- raise Exception("No healthy Anthropic models available")
 
 
 
 
 
 
 
76
 
77
  logger.info("Application startup completed successfully")
78
 
 
62
  logger.info(f"Environment: {'HuggingFace Spaces' if settings.is_huggingface_spaces else 'Development'}")
63
  logger.info(f"Anthropic Model: {settings.anthropic_model.value}")
64
 
65
+ # Initialize model manager with graceful degradation
66
  model_manager = get_model_manager()
 
67
 
68
+ # Try to initialize with minimal validation
69
+ try:
70
+ # Only validate the primary model, not all models
71
+ primary_client = model_manager.get_client(settings.anthropic_model)
72
+ if primary_client:
73
+ app_state["anthropic_client_initialized"] = True
74
+ logger.info(f"Anthropic integration initialized with primary model: {settings.anthropic_model.value}")
75
+ else:
76
+ logger.warning("Primary model not available, but continuing startup")
77
+ app_state["anthropic_client_initialized"] = False
78
+ except Exception as model_error:
79
+ logger.warning(f"Model validation failed during startup: {str(model_error)}")
80
+ logger.info("Continuing startup without full model validation")
81
+ app_state["anthropic_client_initialized"] = False
82
 
83
  logger.info("Application startup completed successfully")
84