diff --git a/backend/app/main.py b/backend/app/main.py index f54b79e..fc66fa0 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -1131,11 +1131,21 @@ def create_ai_configuration( # Desactivar configuraciones anteriores db.query(models.AIConfiguration).update({"is_active": False}) + # Determinar modelo por defecto según el proveedor si no se especifica + model_name = config.model_name + if not model_name: + if config.provider == "openai": + model_name = "gpt-4o" + elif config.provider == "gemini": + model_name = "gemini-2.5-pro" + else: + model_name = "default" + # Crear nueva configuración new_config = models.AIConfiguration( provider=config.provider, api_key=config.api_key, - model_name=config.model_name, + model_name=model_name, is_active=True ) diff --git a/backend/app/models.py b/backend/app/models.py index 808a607..8d5ad34 100644 --- a/backend/app/models.py +++ b/backend/app/models.py @@ -180,7 +180,8 @@ class AIConfiguration(Base): id = Column(Integer, primary_key=True, index=True) provider = Column(String(50), nullable=False) # openai, gemini api_key = Column(Text, nullable=False) - model_name = Column(String(100), nullable=False) + model_name = Column(String(100), nullable=True) + logo_url = Column(Text, nullable=True) # URL del logo configurable is_active = Column(Boolean, default=True) created_at = Column(DateTime(timezone=True), server_default=func.now()) updated_at = Column(DateTime(timezone=True), onupdate=func.now()) diff --git a/backend/app/schemas.py b/backend/app/schemas.py index 7693ad5..12b17bd 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -216,7 +216,7 @@ class InspectionDetail(Inspection): class AIConfigurationBase(BaseModel): provider: str # openai, gemini api_key: str - model_name: str + model_name: Optional[str] = None class AIConfigurationCreate(AIConfigurationBase): pass