Corregir modelos de IA
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user