Update app.py
Browse files
app.py
CHANGED
|
@@ -76,8 +76,8 @@ def display_login_or_app():
|
|
| 76 |
|
| 77 |
# Configuration de la page
|
| 78 |
st.set_page_config(
|
| 79 |
-
page_title="Connexion -
|
| 80 |
-
page_icon="
|
| 81 |
layout="wide",
|
| 82 |
initial_sidebar_state="collapsed"
|
| 83 |
)
|
|
@@ -87,7 +87,7 @@ def display_login_or_app():
|
|
| 87 |
_ , center_col, _ = st.columns([0.5, 3, 0.5], gap="large") # Ajustez les poids si nécessaire
|
| 88 |
|
| 89 |
with center_col: # Tout le contenu statique va dans cette colonne centrale
|
| 90 |
-
# >>>>> CONTENU STATIQUE DE LA PAGE D'ACCUEIL (AVANT LOGIN) <
|
| 91 |
|
| 92 |
# --- AJOUT DU LOGO CENTRÉ ---
|
| 93 |
try:
|
|
@@ -114,147 +114,128 @@ def display_login_or_app():
|
|
| 114 |
# --- Texte principal centré ---
|
| 115 |
st.markdown("""
|
| 116 |
<div style='text-align: center;'>
|
| 117 |
-
<h3>
|
| 118 |
-
<p>Bénéficiez d'
|
| 119 |
</div>
|
| 120 |
""", unsafe_allow_html=True)
|
| 121 |
# --- FIN MODIFICATION ---
|
| 122 |
|
| 123 |
st.divider()
|
| 124 |
st.markdown("<h2 style='text-align: center;'>Notre mission</h2>", unsafe_allow_html=True)
|
| 125 |
-
st.markdown("<h3 style='text-align: center; font-weight: normal;'>
|
| 126 |
-
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Notre objectif est de fournir des
|
| 127 |
st.markdown(" ")
|
| 128 |
col1, col2, col3 = st.columns(3)
|
| 129 |
with col1:
|
| 130 |
-
st.markdown("#### ⚡
|
| 131 |
-
st.markdown("Utilisation de l'Intelligence Artificielle pour fournir
|
| 132 |
with col2:
|
| 133 |
-
st.markdown("#### 📄
|
| 134 |
-
st.markdown("Une équipe passionnée avec plus de
|
| 135 |
with col3:
|
| 136 |
-
st.markdown("#### 🛡️
|
| 137 |
-
st.markdown("Conformité stricte aux normes et
|
| 138 |
st.markdown(" ")
|
| 139 |
|
| 140 |
# --- Section Solutions IA Clés ---
|
| 141 |
st.divider()
|
| 142 |
-
st.markdown("<h2 style='text-align: center;'>Nos Solutions
|
| 143 |
st.markdown(" ") # Espace
|
| 144 |
|
| 145 |
feat_col1, feat_col2, feat_col3, feat_col4 = st.columns(4, gap="medium")
|
| 146 |
with feat_col1:
|
| 147 |
-
st.markdown("###
|
| 148 |
-
st.markdown("
|
| 149 |
with feat_col2:
|
| 150 |
-
st.markdown("###
|
| 151 |
-
st.markdown("
|
| 152 |
with feat_col3:
|
| 153 |
-
st.markdown("###
|
| 154 |
-
st.markdown("
|
| 155 |
with feat_col4:
|
| 156 |
-
st.markdown("###
|
| 157 |
-
st.markdown("
|
| 158 |
st.markdown(" ") # Espace
|
| 159 |
-
# --- FIN Section Solutions
|
| 160 |
|
| 161 |
|
| 162 |
# --- Section Fonctionnalités Détaillées ---
|
| 163 |
st.divider()
|
| 164 |
st.markdown("<p style='text-align: center; text-transform: uppercase; color: var(--text-color-light);'>Fonctionnalités Détaillées</p>", unsafe_allow_html=True)
|
| 165 |
-
st.markdown("<h2 style='text-align: center;'>La plateforme intelligente pour la
|
| 166 |
-
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Gagnez du temps et
|
| 167 |
st.markdown(" ")
|
| 168 |
fcol1, fcol2, fcol3 = st.columns(3)
|
| 169 |
with fcol1:
|
| 170 |
st.markdown("#### 🧑🤝🧑 Espaces de travail collaboratif")
|
| 171 |
-
st.markdown("Collaborez efficacement avec vos équipes, partagez et gérez vos
|
| 172 |
with fcol2:
|
| 173 |
-
st.markdown("#### 💡 AI
|
| 174 |
-
st.markdown("Obtenez des
|
| 175 |
with fcol3:
|
| 176 |
-
st.markdown("#### 💬 Assistant
|
| 177 |
-
st.markdown("Un assistant IA spécialisé
|
| 178 |
st.markdown(" ")
|
| 179 |
fcol4, fcol5, fcol6 = st.columns(3)
|
| 180 |
with fcol4:
|
| 181 |
-
st.markdown("#### ✅ Conformité
|
| 182 |
-
st.markdown("Assurez la conformité de vos projets aux normes
|
| 183 |
with fcol5:
|
| 184 |
st.markdown("#### 📖 Documentation technique")
|
| 185 |
-
st.markdown("Base de connaissances complète sur
|
| 186 |
with fcol6:
|
| 187 |
-
st.markdown("#### 💰 Analyse
|
| 188 |
-
st.markdown("Outils d'analyse et d'optimisation des
|
| 189 |
st.markdown(" ")
|
| 190 |
fcol7, fcol8, fcol9 = st.columns(3)
|
| 191 |
with fcol7:
|
| 192 |
-
st.markdown("#### ⏱️
|
| 193 |
-
st.markdown("
|
| 194 |
with fcol8:
|
| 195 |
st.markdown("#### 📄 Exportation facile")
|
| 196 |
-
st.markdown("Exportez vos
|
| 197 |
with fcol9:
|
| 198 |
st.markdown("#### 📈 Analyse")
|
| 199 |
-
st.markdown("Analysez vos
|
| 200 |
|
| 201 |
-
# --- SECTION
|
| 202 |
st.divider()
|
| 203 |
-
st.markdown("<h2 style='text-align: center;'>
|
| 204 |
-
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>
|
| 205 |
st.markdown(" ")
|
| 206 |
|
| 207 |
-
# Créer
|
| 208 |
reg_col1, reg_col2 = st.columns(2, gap="medium")
|
| 209 |
with reg_col1:
|
| 210 |
-
with st.container():
|
| 211 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>🏢
|
| 212 |
with reg_col2:
|
| 213 |
with st.container():
|
| 214 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>🏢
|
| 215 |
|
| 216 |
st.markdown(" ") # Espace vertical
|
| 217 |
|
| 218 |
reg_col3, reg_col4 = st.columns(2, gap="medium")
|
| 219 |
with reg_col3:
|
| 220 |
with st.container():
|
| 221 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>🏢
|
| 222 |
with reg_col4:
|
| 223 |
with st.container():
|
| 224 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>📄
|
| 225 |
-
|
| 226 |
-
st.markdown(" ") # Espace vertical
|
| 227 |
-
|
| 228 |
-
reg_col5, reg_col6 = st.columns(2, gap="medium")
|
| 229 |
-
with reg_col5:
|
| 230 |
-
with st.container():
|
| 231 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>🎖️ Corporation des maîtres électriciens du Québec</p>", unsafe_allow_html=True)
|
| 232 |
-
with reg_col6:
|
| 233 |
-
with st.container():
|
| 234 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>🎖️ Corporation des maîtres mécaniciens en tuyauterie du Québec</p>", unsafe_allow_html=True)
|
| 235 |
-
# --- FIN SECTION Conformité ---
|
| 236 |
|
| 237 |
-
# ---
|
| 238 |
st.divider()
|
| 239 |
-
st.markdown("<h2 style='text-align: center;'>
|
| 240 |
-
st.markdown("<p style='text-align: center;'>
|
| 241 |
-
st.markdown(" ") # Espace
|
| 242 |
-
st.markdown("**Ce que cela signifie pour vous :**")
|
| 243 |
-
st.markdown("""
|
| 244 |
-
- Plus de flexibilité : payez uniquement ce que vous utilisez
|
| 245 |
-
- Meilleure maîtrise de vos coûts
|
| 246 |
-
- Économisez jusqu'à 50% sur vos factures en ne payant que pour vos besoins réels
|
| 247 |
-
- Fini les frais fixes mensuels pour des fonctionnalités inutilisées
|
| 248 |
-
""")
|
| 249 |
-
st.markdown("Avec notre nouveau modèle, vous ne payez que pour les services réellement consommés, vous permettant ainsi d'optimiser votre budget selon vos besoins.")
|
| 250 |
st.markdown(" ") # Espace
|
| 251 |
-
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Pour plus d'informations
|
| 252 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>📧 <a href='mailto:info@
|
| 253 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>🌐 <a href='https://
|
| 254 |
-
st.markdown("<p style='text-align: center; font-weight: 500;'>📞
|
| 255 |
-
# --- FIN
|
| 256 |
|
| 257 |
-
# >>>>> FIN DU CONTENU STATIQUE CENTRÉ <
|
| 258 |
|
| 259 |
# --- Formulaire de Connexion (reste centré comme avant, sous le contenu statique) ---
|
| 260 |
st.divider()
|
|
@@ -287,7 +268,7 @@ def display_login_or_app():
|
|
| 287 |
|
| 288 |
# --- Exécution Principale ---
|
| 289 |
|
| 290 |
-
# >>>>> AFFICHAGE CONDITIONNEL : LOGIN ou APP <
|
| 291 |
if not display_login_or_app():
|
| 292 |
st.stop() # Arrête l'exécution si display_login_or_app retourne False (non connecté)
|
| 293 |
|
|
@@ -295,8 +276,8 @@ if not display_login_or_app():
|
|
| 295 |
|
| 296 |
# --- Configuration de la Page Principale ---
|
| 297 |
st.set_page_config(
|
| 298 |
-
page_title="
|
| 299 |
-
page_icon="
|
| 300 |
layout="wide",
|
| 301 |
initial_sidebar_state="expanded"
|
| 302 |
)
|
|
@@ -422,7 +403,7 @@ def generate_html_report(messages, profile_name, conversation_id=None, client_na
|
|
| 422 |
else:
|
| 423 |
messages_html += f'<div class="stChatMessage other-bubble"><strong>{html.escape(role.capitalize())} :</strong><div class="msg-content">{content_html}</div></div>\n'
|
| 424 |
|
| 425 |
-
html_output = f"""<!DOCTYPE html><html lang="fr"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Rapport
|
| 426 |
return html_output
|
| 427 |
|
| 428 |
# --- Helper Functions (Application Logic) ---
|
|
@@ -438,7 +419,7 @@ def start_new_consultation():
|
|
| 438 |
# Ajouter le message d'accueil
|
| 439 |
st.session_state.messages.append({
|
| 440 |
"role": "assistant",
|
| 441 |
-
"content": f"Bonjour! Je suis votre
|
| 442 |
})
|
| 443 |
if 'html_download_data' in st.session_state: del st.session_state.html_download_data
|
| 444 |
if "files_to_analyze" in st.session_state: del st.session_state.files_to_analyze
|
|
@@ -513,7 +494,7 @@ with st.sidebar:
|
|
| 513 |
except Exception as e:
|
| 514 |
st.error(f"Erreur logo: {e}")
|
| 515 |
|
| 516 |
-
st.title("
|
| 517 |
if st.button("➕ Nouvelle Consultation", key="new_consult_button_top", use_container_width=True):
|
| 518 |
save_current_conversation()
|
| 519 |
start_new_consultation()
|
|
@@ -602,7 +583,7 @@ with st.sidebar:
|
|
| 602 |
if current_profile: profile_name = current_profile.get('name', 'Expert')
|
| 603 |
conv_id = st.session_state.current_conversation_id
|
| 604 |
html_string = generate_html_report(st.session_state.messages, profile_name, conv_id, client_name_export)
|
| 605 |
-
if html_string: id_part = f"Conv{conv_id}" if conv_id else datetime.now().strftime('%Y%m%d_%H%M'); filename = f"
|
| 606 |
else: st.error("Échec génération HTML.")
|
| 607 |
except Exception as e: st.error(f"Erreur génération HTML: {e}"); st.exception(e)
|
| 608 |
st.rerun()
|
|
@@ -610,14 +591,23 @@ with st.sidebar:
|
|
| 610 |
download_info = st.session_state.html_download_data
|
| 611 |
st.download_button(label="⬇️ Télécharger HTML", data=download_info["data"].encode("utf-8"), file_name=download_info["filename"], mime="text/html", key="dl_html", use_container_width=True, on_click=lambda: st.session_state.update(html_download_data=None))
|
| 612 |
|
| 613 |
-
# --- Liens
|
| 614 |
st.markdown('<hr style="margin: 1rem 0; border-top: 1px solid var(--border-color);">', unsafe_allow_html=True)
|
| 615 |
-
st.markdown('<div class="sidebar-subheader">🔗
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
|
| 622 |
# --- Bouton Déconnexion ---
|
| 623 |
st.markdown('<hr style="margin: 1rem 0; border-top: 1px solid var(--border-color);">', unsafe_allow_html=True)
|
|
@@ -639,23 +629,23 @@ with main_container:
|
|
| 639 |
# Titre dynamique
|
| 640 |
if 'expert_advisor' in st.session_state:
|
| 641 |
current_profile = st.session_state.expert_advisor.get_current_profile()
|
| 642 |
-
profile_name = "
|
| 643 |
st.title(f"Assistant: {profile_name}")
|
| 644 |
if not current_profile or current_profile.get('id') == 'default_expert': st.markdown("*Profil expert par défaut actif.*")
|
| 645 |
-
else: st.title("
|
| 646 |
st.divider()
|
| 647 |
|
| 648 |
# Affichage du chat (le contenu statique est géré dans la page de login)
|
| 649 |
if not st.session_state.messages and 'expert_advisor' in st.session_state:
|
| 650 |
profile = st.session_state.expert_advisor.get_current_profile()
|
| 651 |
prof_name = profile.get('name', 'par défaut') if profile else "par défaut"
|
| 652 |
-
st.session_state.messages.append({"role": "assistant", "content": f"Bonjour! Je suis votre
|
| 653 |
|
| 654 |
# Boucle d'affichage des messages
|
| 655 |
for message in st.session_state.messages:
|
| 656 |
role = message.get("role", "unknown"); content = message.get("content", "*Message vide*")
|
| 657 |
if role == "system": continue
|
| 658 |
-
avatar = "👤" if role == "user" else "
|
| 659 |
with st.chat_message(role, avatar=avatar):
|
| 660 |
display_content = str(content) if not isinstance(content, str) else content
|
| 661 |
# Utiliser unsafe_allow_html=True peut être risqué si le contenu vient d'une source non sûre
|
|
@@ -692,7 +682,7 @@ if action_to_process and action_to_process.get("role") == "user":
|
|
| 692 |
|
| 693 |
if is_analysis_request:
|
| 694 |
# --- Logique Analyse Fichiers ---
|
| 695 |
-
with st.chat_message("assistant", avatar="
|
| 696 |
with st.spinner("Analyse des fichiers..."):
|
| 697 |
try:
|
| 698 |
history_context = [m for m in st.session_state.messages[:-1] if m.get("role") != "system"]
|
|
@@ -778,7 +768,7 @@ if action_to_process and action_to_process.get("role") == "user":
|
|
| 778 |
|
| 779 |
else: # Traiter comme chat normal
|
| 780 |
# --- Logique Réponse Claude ---
|
| 781 |
-
with st.chat_message("assistant", avatar="
|
| 782 |
placeholder = st.empty()
|
| 783 |
with st.spinner("L'expert réfléchit..."):
|
| 784 |
try:
|
|
|
|
| 76 |
|
| 77 |
# Configuration de la page
|
| 78 |
st.set_page_config(
|
| 79 |
+
page_title="Connexion - Desmarais & Gagné Assistant",
|
| 80 |
+
page_icon="🏭",
|
| 81 |
layout="wide",
|
| 82 |
initial_sidebar_state="collapsed"
|
| 83 |
)
|
|
|
|
| 87 |
_ , center_col, _ = st.columns([0.5, 3, 0.5], gap="large") # Ajustez les poids si nécessaire
|
| 88 |
|
| 89 |
with center_col: # Tout le contenu statique va dans cette colonne centrale
|
| 90 |
+
# >>>>> CONTENU STATIQUE DE LA PAGE D'ACCUEIL (AVANT LOGIN) <
|
| 91 |
|
| 92 |
# --- AJOUT DU LOGO CENTRÉ ---
|
| 93 |
try:
|
|
|
|
| 114 |
# --- Texte principal centré ---
|
| 115 |
st.markdown("""
|
| 116 |
<div style='text-align: center;'>
|
| 117 |
+
<h3>Desmarais & Gagné Assistant - La plateforme intelligente qui révolutionne vos projets de fabrication métallique.</h3>
|
| 118 |
+
<p>Bénéficiez d'expertise en fabrication métallique, soudure et transformation de métal grâce à notre technologie d'IA avancée.</p>
|
| 119 |
</div>
|
| 120 |
""", unsafe_allow_html=True)
|
| 121 |
# --- FIN MODIFICATION ---
|
| 122 |
|
| 123 |
st.divider()
|
| 124 |
st.markdown("<h2 style='text-align: center;'>Notre mission</h2>", unsafe_allow_html=True)
|
| 125 |
+
st.markdown("<h3 style='text-align: center; font-weight: normal;'>Excellence en fabrication métallique depuis quatre décennies</h3>", unsafe_allow_html=True)
|
| 126 |
+
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Notre objectif est de fournir des solutions complètes de qualité pour tous vos besoins en fabrication métallique.</p>", unsafe_allow_html=True)
|
| 127 |
st.markdown(" ")
|
| 128 |
col1, col2, col3 = st.columns(3)
|
| 129 |
with col1:
|
| 130 |
+
st.markdown("#### ⚡ Expertise métallique")
|
| 131 |
+
st.markdown("Utilisation de l'Intelligence Artificielle pour fournir une expertise en fabrication métallique, poinçonnage, coupage et assemblage.")
|
| 132 |
with col2:
|
| 133 |
+
st.markdown("#### 📄 Solutions personnalisées")
|
| 134 |
+
st.markdown("Une équipe passionnée avec plus de 40 ans d'expérience dans le secteur de la fabrication métallique.")
|
| 135 |
with col3:
|
| 136 |
+
st.markdown("#### 🛡️ Qualité supérieure")
|
| 137 |
+
st.markdown("Conformité stricte aux normes de qualité et certifications (ISO 9001, CWB et soudure robotisée).")
|
| 138 |
st.markdown(" ")
|
| 139 |
|
| 140 |
# --- Section Solutions IA Clés ---
|
| 141 |
st.divider()
|
| 142 |
+
st.markdown("<h2 style='text-align: center;'>Nos Solutions Clés</h2>", unsafe_allow_html=True)
|
| 143 |
st.markdown(" ") # Espace
|
| 144 |
|
| 145 |
feat_col1, feat_col2, feat_col3, feat_col4 = st.columns(4, gap="medium")
|
| 146 |
with feat_col1:
|
| 147 |
+
st.markdown("### 🔧 Fabrication métallique")
|
| 148 |
+
st.markdown("Solutions complètes et de qualité pour tous besoins en poinçonnage, coupage, découpage à froid et pliage hydraulique.")
|
| 149 |
with feat_col2:
|
| 150 |
+
st.markdown("### 🔥 Expertise en soudure")
|
| 151 |
+
st.markdown("Soudure MIG, TIG, par points et robotisée sur acier, aluminium et autres matériaux soudables.")
|
| 152 |
with feat_col3:
|
| 153 |
+
st.markdown("### 🚚 Diables DG-600")
|
| 154 |
+
st.markdown("Diables en aluminium ultralégers et robustes avec accessoires pour diverses applications.")
|
| 155 |
with feat_col4:
|
| 156 |
+
st.markdown("### 🏗️ Environnements contrôlés")
|
| 157 |
+
st.markdown("Conception et fabrication de cabines insonorisées et bâtiments modulaires préfabriqués.")
|
| 158 |
st.markdown(" ") # Espace
|
| 159 |
+
# --- FIN Section Solutions ---
|
| 160 |
|
| 161 |
|
| 162 |
# --- Section Fonctionnalités Détaillées ---
|
| 163 |
st.divider()
|
| 164 |
st.markdown("<p style='text-align: center; text-transform: uppercase; color: var(--text-color-light);'>Fonctionnalités Détaillées</p>", unsafe_allow_html=True)
|
| 165 |
+
st.markdown("<h2 style='text-align: center;'>La plateforme intelligente pour la fabrication métallique</h2>", unsafe_allow_html=True)
|
| 166 |
+
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Gagnez du temps et optimisez vos projets grâce à notre IA conçue pour la fabrication métallique. Une plateforme complète pour vous assister dans vos besoins.</p>", unsafe_allow_html=True)
|
| 167 |
st.markdown(" ")
|
| 168 |
fcol1, fcol2, fcol3 = st.columns(3)
|
| 169 |
with fcol1:
|
| 170 |
st.markdown("#### 🧑🤝🧑 Espaces de travail collaboratif")
|
| 171 |
+
st.markdown("Collaborez efficacement avec vos équipes, partagez et gérez vos informations en un seul endroit.")
|
| 172 |
with fcol2:
|
| 173 |
+
st.markdown("#### 💡 AI Assistance")
|
| 174 |
+
st.markdown("Obtenez des informations techniques en quelques secondes sur la base de notre expertise interne.")
|
| 175 |
with fcol3:
|
| 176 |
+
st.markdown("#### 💬 Assistant spécialisé")
|
| 177 |
+
st.markdown("Un assistant IA spécialisé en fabrication métallique répondant à vos questions techniques en temps réel.")
|
| 178 |
st.markdown(" ")
|
| 179 |
fcol4, fcol5, fcol6 = st.columns(3)
|
| 180 |
with fcol4:
|
| 181 |
+
st.markdown("#### ✅ Conformité aux normes")
|
| 182 |
+
st.markdown("Assurez la conformité de vos projets aux normes de qualité grâce à notre vérification automatique.")
|
| 183 |
with fcol5:
|
| 184 |
st.markdown("#### 📖 Documentation technique")
|
| 185 |
+
st.markdown("Base de connaissances complète sur nos produits et services de fabrication métallique.")
|
| 186 |
with fcol6:
|
| 187 |
+
st.markdown("#### 💰 Analyse technique")
|
| 188 |
+
st.markdown("Outils d'analyse et d'optimisation des processus basés sur notre expertise en fabrication métallique.")
|
| 189 |
st.markdown(" ")
|
| 190 |
fcol7, fcol8, fcol9 = st.columns(3)
|
| 191 |
with fcol7:
|
| 192 |
+
st.markdown("#### ⏱️ Réponses rapides")
|
| 193 |
+
st.markdown("Obtenez des informations précises et rapides pour mieux planifier vos projets de fabrication.")
|
| 194 |
with fcol8:
|
| 195 |
st.markdown("#### 📄 Exportation facile")
|
| 196 |
+
st.markdown("Exportez vos conversations au format PDF en un seul clic.")
|
| 197 |
with fcol9:
|
| 198 |
st.markdown("#### 📈 Analyse")
|
| 199 |
+
st.markdown("Analysez vos documents et plans techniques (fichiers PDF, DOCX, CSV et images).")
|
| 200 |
|
| 201 |
+
# --- SECTION Certifications ---
|
| 202 |
st.divider()
|
| 203 |
+
st.markdown("<h2 style='text-align: center;'>Certifications et expertise</h2>", unsafe_allow_html=True)
|
| 204 |
+
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Desmarais & Gagné se conforme aux principales certifications du secteur de la fabrication métallique</p>", unsafe_allow_html=True)
|
| 205 |
st.markdown(" ")
|
| 206 |
|
| 207 |
+
# Créer 2 lignes de 2 colonnes pour les certifications
|
| 208 |
reg_col1, reg_col2 = st.columns(2, gap="medium")
|
| 209 |
with reg_col1:
|
| 210 |
+
with st.container():
|
| 211 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>🏢 Certification ISO 9001</p>", unsafe_allow_html=True)
|
| 212 |
with reg_col2:
|
| 213 |
with st.container():
|
| 214 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>🏢 Certification CWB</p>", unsafe_allow_html=True)
|
| 215 |
|
| 216 |
st.markdown(" ") # Espace vertical
|
| 217 |
|
| 218 |
reg_col3, reg_col4 = st.columns(2, gap="medium")
|
| 219 |
with reg_col3:
|
| 220 |
with st.container():
|
| 221 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>🏢 Certification Soudure Robotisée</p>", unsafe_allow_html=True)
|
| 222 |
with reg_col4:
|
| 223 |
with st.container():
|
| 224 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>📄 Expertise en fabrication sur mesure</p>", unsafe_allow_html=True)
|
| 225 |
+
# --- FIN SECTION Certifications ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
+
# --- SECTION CONTACT ---
|
| 228 |
st.divider()
|
| 229 |
+
st.markdown("<h2 style='text-align: center;'>Contactez-nous</h2>", unsafe_allow_html=True)
|
| 230 |
+
st.markdown("<p style='text-align: center;'>N'hésitez pas à nous contacter pour toute question ou information supplémentaire.</p>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
st.markdown(" ") # Espace
|
| 232 |
+
st.markdown("<p style='text-align: center; color: var(--text-color-light);'>Pour plus d'informations, n'hésitez pas à nous contacter</p>", unsafe_allow_html=True)
|
| 233 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>📧 <a href='mailto:info@dg-inc.qc.ca'>info@dg-inc.qc.ca</a></p>", unsafe_allow_html=True)
|
| 234 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>🌐 <a href='https://www.dg-inc.qc.ca' target='_blank'>https://www.dg-inc.qc.ca</a></p>", unsafe_allow_html=True)
|
| 235 |
+
st.markdown("<p style='text-align: center; font-weight: 500;'>📞 Tél.: 450 372-9630</p>", unsafe_allow_html=True)
|
| 236 |
+
# --- FIN SECTION CONTACT ---
|
| 237 |
|
| 238 |
+
# >>>>> FIN DU CONTENU STATIQUE CENTRÉ <
|
| 239 |
|
| 240 |
# --- Formulaire de Connexion (reste centré comme avant, sous le contenu statique) ---
|
| 241 |
st.divider()
|
|
|
|
| 268 |
|
| 269 |
# --- Exécution Principale ---
|
| 270 |
|
| 271 |
+
# >>>>> AFFICHAGE CONDITIONNEL : LOGIN ou APP <
|
| 272 |
if not display_login_or_app():
|
| 273 |
st.stop() # Arrête l'exécution si display_login_or_app retourne False (non connecté)
|
| 274 |
|
|
|
|
| 276 |
|
| 277 |
# --- Configuration de la Page Principale ---
|
| 278 |
st.set_page_config(
|
| 279 |
+
page_title="Desmarais & Gagné Assistant",
|
| 280 |
+
page_icon="🏭",
|
| 281 |
layout="wide",
|
| 282 |
initial_sidebar_state="expanded"
|
| 283 |
)
|
|
|
|
| 403 |
else:
|
| 404 |
messages_html += f'<div class="stChatMessage other-bubble"><strong>{html.escape(role.capitalize())} :</strong><div class="msg-content">{content_html}</div></div>\n'
|
| 405 |
|
| 406 |
+
html_output = f"""<!DOCTYPE html><html lang="fr"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Rapport Desmarais & Gagné - {html.escape(profile_name)}{conv_id_display}</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet"><style>{custom_css} body{{padding:20px;background-color:var(--background-color,#F9FAFB);max-width:1200px;margin:20px auto;box-shadow:0 2px 10px rgba(0,0,0,.1);border-radius:8px}}.search-bubble{{background-color:#F0FDF4;border:1px solid #BBF7D0;color:#14532D;padding:.8rem 1.2rem;margin-bottom:1rem;border-radius:var(--border-radius-md);box-shadow:var(--box-shadow-sm);line-height:1.6}}.search-bubble .msg-content p,.search-bubble .msg-content ul,.search-bubble .msg-content ol{{color:#14532D}}.other-bubble{{background-color:#FEFCE8;border:1px solid #FEF08A}}.report-header h1{{text-align:center;color:var(--primary-color,#3B82F6);font-size:1.8rem;margin-bottom:15px;padding-bottom:10px;border-bottom:2px solid var(--primary-color,#3B82F6)}}.report-info{{margin-bottom:25px;padding:10px;background-color:var(--border-color-light,#F3F4F6);border-radius:var(--border-radius-sm);font-size:.9rem;color:var(--text-color-light,#6B7280)}}.report-info p{{margin:3px 0}}section[data-testid=stSidebar],div[data-testid=stChatInput],.stButton{{display:none!important}}.msg-content table{{font-size:.9em}}.msg-content th,.msg-content td{{padding:6px 9px}}.msg-content pre{{font-size:.85rem}}</style></head><body><div class="report-header"><h1>Rapport Desmarais & Gagné</h1></div><div class="report-info"><p><strong>Expert :</strong> {html.escape(profile_name)}</p>{client_display}<p><strong>Date :</strong> {now}</p><p><strong>ID Conversation :</strong> {html.escape(str(conversation_id)) if conversation_id else 'N/A'}</p></div><div class="conversation-history">{messages_html}</div></body></html>"""
|
| 407 |
return html_output
|
| 408 |
|
| 409 |
# --- Helper Functions (Application Logic) ---
|
|
|
|
| 419 |
# Ajouter le message d'accueil
|
| 420 |
st.session_state.messages.append({
|
| 421 |
"role": "assistant",
|
| 422 |
+
"content": f"Bonjour! Je suis votre assistant Desmarais & Gagné, spécialisé en {profile_name}. Comment puis-je vous aider aujourd'hui? (Tapez `/search votre_recherche` pour une recherche web via Google)"
|
| 423 |
})
|
| 424 |
if 'html_download_data' in st.session_state: del st.session_state.html_download_data
|
| 425 |
if "files_to_analyze" in st.session_state: del st.session_state.files_to_analyze
|
|
|
|
| 494 |
except Exception as e:
|
| 495 |
st.error(f"Erreur logo: {e}")
|
| 496 |
|
| 497 |
+
st.title("Desmarais & Gagné Assistant")
|
| 498 |
if st.button("➕ Nouvelle Consultation", key="new_consult_button_top", use_container_width=True):
|
| 499 |
save_current_conversation()
|
| 500 |
start_new_consultation()
|
|
|
|
| 583 |
if current_profile: profile_name = current_profile.get('name', 'Expert')
|
| 584 |
conv_id = st.session_state.current_conversation_id
|
| 585 |
html_string = generate_html_report(st.session_state.messages, profile_name, conv_id, client_name_export)
|
| 586 |
+
if html_string: id_part = f"Conv{conv_id}" if conv_id else datetime.now().strftime('%Y%m%d_%H%M'); filename = f"Rapport_DesmGagne_{id_part}.html"; st.session_state.html_download_data = {"data": html_string, "filename": filename}; st.success("Rapport prêt.")
|
| 587 |
else: st.error("Échec génération HTML.")
|
| 588 |
except Exception as e: st.error(f"Erreur génération HTML: {e}"); st.exception(e)
|
| 589 |
st.rerun()
|
|
|
|
| 591 |
download_info = st.session_state.html_download_data
|
| 592 |
st.download_button(label="⬇️ Télécharger HTML", data=download_info["data"].encode("utf-8"), file_name=download_info["filename"], mime="text/html", key="dl_html", use_container_width=True, on_click=lambda: st.session_state.update(html_download_data=None))
|
| 593 |
|
| 594 |
+
# --- Liens Documentation ---
|
| 595 |
st.markdown('<hr style="margin: 1rem 0; border-top: 1px solid var(--border-color);">', unsafe_allow_html=True)
|
| 596 |
+
st.markdown('<div class="sidebar-subheader">🔗 Documentation et ressources</div>', unsafe_allow_html=True)
|
| 597 |
+
dg_links = {
|
| 598 |
+
"SOUDURE": "https://www.dg-inc.qc.ca/specialites/soudure/soudure-robotisee/",
|
| 599 |
+
"MÉTAL EN FEUILLES": "https://www.dg-inc.qc.ca/specialites/metal-en-feuilles/poinconnage/",
|
| 600 |
+
"DIABLES DG-600": "https://www.dg-inc.qc.ca/produits/chariots-diables/produits/",
|
| 601 |
+
"ENVIRONNEMENTS CONTRÔLÉS": "https://www.cab-expert.com/",
|
| 602 |
+
"CATALOGUE PRODUITS": "https://www.dg-inc.qc.ca/produits/",
|
| 603 |
+
"CONTACTEZ-NOUS": "https://www.dg-inc.qc.ca/contact/"
|
| 604 |
+
}
|
| 605 |
+
for link_name, link_url in dg_links.items():
|
| 606 |
+
if link_url and link_url != "#" and link_url.strip():
|
| 607 |
+
st.markdown(f"* [{link_name}]({link_url})")
|
| 608 |
+
else:
|
| 609 |
+
st.markdown(f"* {link_name} *(Lien non disponible)*")
|
| 610 |
+
st.caption("Propriété intellectuelle de Desmarais & Gagné inc. | 565 Maisonneuve, Granby, Québec")
|
| 611 |
|
| 612 |
# --- Bouton Déconnexion ---
|
| 613 |
st.markdown('<hr style="margin: 1rem 0; border-top: 1px solid var(--border-color);">', unsafe_allow_html=True)
|
|
|
|
| 629 |
# Titre dynamique
|
| 630 |
if 'expert_advisor' in st.session_state:
|
| 631 |
current_profile = st.session_state.expert_advisor.get_current_profile()
|
| 632 |
+
profile_name = "Desmarais & Gagné Assistant"; profile_name = current_profile.get('name', profile_name) if current_profile else profile_name
|
| 633 |
st.title(f"Assistant: {profile_name}")
|
| 634 |
if not current_profile or current_profile.get('id') == 'default_expert': st.markdown("*Profil expert par défaut actif.*")
|
| 635 |
+
else: st.title("Desmarais & Gagné Assistant"); st.markdown("*Erreur: Module expert non initialisé.*")
|
| 636 |
st.divider()
|
| 637 |
|
| 638 |
# Affichage du chat (le contenu statique est géré dans la page de login)
|
| 639 |
if not st.session_state.messages and 'expert_advisor' in st.session_state:
|
| 640 |
profile = st.session_state.expert_advisor.get_current_profile()
|
| 641 |
prof_name = profile.get('name', 'par défaut') if profile else "par défaut"
|
| 642 |
+
st.session_state.messages.append({"role": "assistant", "content": f"Bonjour! Je suis votre assistant Desmarais & Gagné, spécialisé en {prof_name}. Comment puis-je vous aider aujourd'hui? (Tapez `/search votre_recherche` pour une recherche web via Google)"})
|
| 643 |
|
| 644 |
# Boucle d'affichage des messages
|
| 645 |
for message in st.session_state.messages:
|
| 646 |
role = message.get("role", "unknown"); content = message.get("content", "*Message vide*")
|
| 647 |
if role == "system": continue
|
| 648 |
+
avatar = "👤" if role == "user" else "🏭" if role == "assistant" else "🔎" if role == "search_result" else "🤖"
|
| 649 |
with st.chat_message(role, avatar=avatar):
|
| 650 |
display_content = str(content) if not isinstance(content, str) else content
|
| 651 |
# Utiliser unsafe_allow_html=True peut être risqué si le contenu vient d'une source non sûre
|
|
|
|
| 682 |
|
| 683 |
if is_analysis_request:
|
| 684 |
# --- Logique Analyse Fichiers ---
|
| 685 |
+
with st.chat_message("assistant", avatar="🏭"):
|
| 686 |
with st.spinner("Analyse des fichiers..."):
|
| 687 |
try:
|
| 688 |
history_context = [m for m in st.session_state.messages[:-1] if m.get("role") != "system"]
|
|
|
|
| 768 |
|
| 769 |
else: # Traiter comme chat normal
|
| 770 |
# --- Logique Réponse Claude ---
|
| 771 |
+
with st.chat_message("assistant", avatar="🏭"):
|
| 772 |
placeholder = st.empty()
|
| 773 |
with st.spinner("L'expert réfléchit..."):
|
| 774 |
try:
|