Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,6 +21,9 @@ safety_settings = [
|
|
| 21 |
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"},
|
| 22 |
]
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
def upload_and_process_file(file_path):
|
| 25 |
max_retries = 3
|
| 26 |
retry_delay = 2
|
|
@@ -73,20 +76,25 @@ st.title("Mariam AI - Chat Intelligent")
|
|
| 73 |
if "chat" not in st.session_state:
|
| 74 |
st.session_state.chat = model.start_chat(history=[])
|
| 75 |
|
| 76 |
-
#
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
# Afficher l'historique des messages
|
| 92 |
for message in st.session_state.chat.history:
|
|
@@ -97,8 +105,28 @@ for message in st.session_state.chat.history:
|
|
| 97 |
if hasattr(part, 'image'):
|
| 98 |
st.image(part.image)
|
| 99 |
|
| 100 |
-
#
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
content = [prompt]
|
| 103 |
temp_files = []
|
| 104 |
|
|
|
|
| 21 |
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"},
|
| 22 |
]
|
| 23 |
|
| 24 |
+
def role_to_streamlit(role):
|
| 25 |
+
return "assistant" if role == "model" else role
|
| 26 |
+
|
| 27 |
def upload_and_process_file(file_path):
|
| 28 |
max_retries = 3
|
| 29 |
retry_delay = 2
|
|
|
|
| 76 |
if "chat" not in st.session_state:
|
| 77 |
st.session_state.chat = model.start_chat(history=[])
|
| 78 |
|
| 79 |
+
# CSS personnalisé pour le conteneur d'upload
|
| 80 |
+
st.markdown("""
|
| 81 |
+
<style>
|
| 82 |
+
.stButton>button {
|
| 83 |
+
height: 40px;
|
| 84 |
+
padding: 0 10px;
|
| 85 |
+
}
|
| 86 |
+
.upload-container {
|
| 87 |
+
display: flex;
|
| 88 |
+
align-items: center;
|
| 89 |
+
gap: 10px;
|
| 90 |
+
margin-bottom: 10px;
|
| 91 |
+
}
|
| 92 |
+
.custom-file-upload {
|
| 93 |
+
display: inline-block;
|
| 94 |
+
cursor: pointer;
|
| 95 |
+
}
|
| 96 |
+
</style>
|
| 97 |
+
""", unsafe_allow_html=True)
|
| 98 |
|
| 99 |
# Afficher l'historique des messages
|
| 100 |
for message in st.session_state.chat.history:
|
|
|
|
| 105 |
if hasattr(part, 'image'):
|
| 106 |
st.image(part.image)
|
| 107 |
|
| 108 |
+
# Créer un conteneur pour la zone de saisie et les boutons d'upload
|
| 109 |
+
input_container = st.container()
|
| 110 |
+
|
| 111 |
+
with input_container:
|
| 112 |
+
col1, col2, col3 = st.columns([8, 1, 1])
|
| 113 |
+
|
| 114 |
+
with col3:
|
| 115 |
+
uploaded_files = st.file_uploader("", type=["txt", "pdf"],
|
| 116 |
+
accept_multiple_files=True, key="files",
|
| 117 |
+
label_visibility="collapsed")
|
| 118 |
+
st.markdown("📁", unsafe_allow_html=True)
|
| 119 |
+
|
| 120 |
+
with col2:
|
| 121 |
+
uploaded_images = st.file_uploader("", type=["jpg", "jpeg", "png", "gif"],
|
| 122 |
+
accept_multiple_files=True, key="images",
|
| 123 |
+
label_visibility="collapsed")
|
| 124 |
+
st.markdown("📸", unsafe_allow_html=True)
|
| 125 |
+
|
| 126 |
+
with col1:
|
| 127 |
+
prompt = st.chat_input("Que puis-je faire pour vous ?")
|
| 128 |
+
|
| 129 |
+
if prompt:
|
| 130 |
content = [prompt]
|
| 131 |
temp_files = []
|
| 132 |
|