Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,16 +12,19 @@ st.title("💬 Chatbot avec Claude 3")
|
|
| 12 |
if "messages" not in st.session_state:
|
| 13 |
st.session_state["messages"] = []
|
| 14 |
|
| 15 |
-
# Affichage de tous les messages précédents
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
if msg["role"] == "user":
|
| 20 |
-
st.
|
| 21 |
else:
|
| 22 |
-
st.
|
| 23 |
|
| 24 |
-
#
|
|
|
|
|
|
|
|
|
|
| 25 |
with st.container():
|
| 26 |
prompt = st.text_input("Posez votre question :", key="chat")
|
| 27 |
if prompt:
|
|
@@ -50,4 +53,4 @@ with st.container():
|
|
| 50 |
|
| 51 |
# Ajouter et afficher la réponse de l'assistant
|
| 52 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
| 53 |
-
st.
|
|
|
|
| 12 |
if "messages" not in st.session_state:
|
| 13 |
st.session_state["messages"] = []
|
| 14 |
|
| 15 |
+
# Affichage de tous les messages précédents dans un container pour une meilleure gestion de l'espace
|
| 16 |
+
chat_container = st.container()
|
| 17 |
+
with chat_container:
|
| 18 |
+
for msg in st.session_state.messages:
|
| 19 |
if msg["role"] == "user":
|
| 20 |
+
st.markdown(f"<div style='margin-left: 10px;'><img src='https://www.example.com/user_icon.png' width='24'> User: {msg['content']}</div>", unsafe_allow_html=True)
|
| 21 |
else:
|
| 22 |
+
st.markdown(f"<div style='margin-right: 10px; text-align: right;'><img src='https://www.example.com/bot_icon.png' width='24'> Assistant: {msg['content']}</div>", unsafe_allow_html=True)
|
| 23 |
|
| 24 |
+
# Créer un espace vide pour pousser l'input en bas
|
| 25 |
+
st.empty()
|
| 26 |
+
|
| 27 |
+
# Entrée pour les nouvelles questions en bas
|
| 28 |
with st.container():
|
| 29 |
prompt = st.text_input("Posez votre question :", key="chat")
|
| 30 |
if prompt:
|
|
|
|
| 53 |
|
| 54 |
# Ajouter et afficher la réponse de l'assistant
|
| 55 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
| 56 |
+
st.markdown(f"<div style='margin-right: 10px; text-align: right;'><img src='https://www.example.com/bot_icon.png' width='24'> Assistant: {msg}</div>", unsafe_allow_html=True)
|