fix: correction de l'indentation Python dans models.py provoquant le crash du backend
Build and Push Docker Image / build-and-push (push) Successful in 41s

This commit is contained in:
xavier committed 2026-10-07 14:55:42 +02:00
1 parent ec37ac06fe
commit b3d92558fc
1 file changed
+17 -35
+17 -35
View File
@@ -1,60 +1,44 @@
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, Text from sqlalchemy import Column, Integer, String, Boolean, ForeignKey, DateTime, Float
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from datetime import datetime, timezone from datetime import datetime, timezone
from .database import Base from .database import Base
from sqlalchemy import Float, DateTime
from datetime import datetime, timezone
class User(Base): class User(Base):
__tablename__ = "users" __tablename__ = "users"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
email = Column(String, unique=True, index=True, nullable=False) email = Column(String, unique=True, index=True)
username = Column(String, unique=True, index=True, nullable=False) username = Column(String, unique=True, index=True)
hashed_password = Column(String, nullable=False) hashed_password = Column(String)
totp_secret = Column(String, nullable=False) totp_secret = Column(String)
is_admin = Column(Boolean, default=False) is_admin = Column(Boolean, default=False)
projects = relationship("Project", back_populates="owner")
# Relation : Un utilisateur peut avoir plusieurs projets
projects = relationship("Project", back_populates="owner", cascade="all, delete-orphan")
class Project(Base): class Project(Base):
__tablename__ = "projects" __tablename__ = "projects"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
title = Column(String, nullable=False) title = Column(String, index=True)
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc)) created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
is_pinned = Column(Boolean, default=False) is_pinned = Column(Boolean, default=False)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False) user_id = Column(Integer, ForeignKey("users.id"))
# Relations
owner = relationship("User", back_populates="projects") owner = relationship("User", back_populates="projects")
messages = relationship("Message", back_populates="project", cascade="all, delete-orphan") messages = relationship("Message", back_populates="project", cascade="all, delete-orphan")
class Message(Base): class Message(Base):
__tablename__ = "messages" __tablename__ = "messages"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
role = Column(String, nullable=False) # Ex: 'user', 'assistant', 'worker_1', 'system' role = Column(String)
content = Column(Text, nullable=False) content = Column(String)
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc)) created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
project_id = Column(Integer, ForeignKey("projects.id"), nullable=False) project_id = Column(Integer, ForeignKey("projects.id"))
# Relation
project = relationship("Project", back_populates="messages") project = relationship("Project", back_populates="messages")
class SystemSettings(Base): class SystemSettings(Base):
__tablename__ = "system_settings" __tablename__ = "system_settings"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
# Serveur Mail (Obligatoire)
smtp_host = Column(String, nullable=False) smtp_host = Column(String, nullable=False)
smtp_port = Column(Integer, nullable=False) smtp_port = Column(Integer, nullable=False)
smtp_user = Column(String, nullable=False) smtp_user = Column(String, nullable=False)
smtp_password = Column(String, nullable=False) smtp_password = Column(String, nullable=False)
# Clés API (Optionnelles)
openrouter_api_key = Column(String, nullable=True) openrouter_api_key = Column(String, nullable=True)
openrouter_management_key = Column(String, nullable=True) openrouter_management_key = Column(String, nullable=True)
groq_api_key = Column(String, nullable=True) groq_api_key = Column(String, nullable=True)
@@ -65,25 +49,23 @@ class SystemSettings(Base):
cloudflare_api_token = Column(String, nullable=True) cloudflare_api_token = Column(String, nullable=True)
huggingface_api_key = Column(String, nullable=True) huggingface_api_key = Column(String, nullable=True)
class AIModel(Base): class AIModel(Base):
"""Stocke la liste des modèles extraits depuis les fournisseurs.""" """Stocke la liste des modèles extraits depuis les fournisseurs."""
__tablename__ = "ai_models" __tablename__ = "ai_models"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
provider = Column(String, index=True) # ex: openrouter, groq provider = Column(String, index=True)
model_id = Column(String, unique=True, index=True) # ex: google/gemini-1.5-pro model_id = Column(String, unique=True, index=True)
name = Column(String) name = Column(String)
context_length = Column(Integer) context_length = Column(Integer)
pricing_prompt = Column(Float) # Coût pour 1M tokens pricing_prompt = Column(Float)
pricing_completion = Column(Float) pricing_completion = Column(Float)
last_updated = Column(DateTime, default=lambda: datetime.now(timezone.utc)) last_updated = Column(DateTime, default=lambda: datetime.now(timezone.utc))
class FinancialLog(Base): class FinancialLog(Base):
"""Suivi financier par fournisseur.""" """Suivi financier par fournisseur."""
__tablename__ = "financial_logs" __tablename__ = "financial_logs"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
provider = Column(String, index=True) provider = Column(String, index=True)
balance = Column(Float) # Crédit restant balance = Column(Float)
total_usage = Column(Float) # Consommation totale total_usage = Column(Float)
checked_at = Column(DateTime, default=lambda: datetime.now(timezone.utc)) checked_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))