Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -72,6 +72,10 @@ model = genai.GenerativeModel('gemini-1.5-flash',
|
|
72 |
st.set_page_config(page_title="Mariam - Assistant IA", page_icon="馃")
|
73 |
st.title("Mariam AI - Chat Intelligent")
|
74 |
|
|
|
|
|
|
|
|
|
75 |
# CSS personnalis茅 pour le conteneur d'upload
|
76 |
st.markdown("""
|
77 |
<style>
|
@@ -85,24 +89,24 @@ st.markdown("""
|
|
85 |
gap: 10px;
|
86 |
margin-bottom: 10px;
|
87 |
}
|
88 |
-
.
|
89 |
-
display:
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
-
.
|
94 |
-
|
95 |
}
|
96 |
-
.
|
97 |
-
|
98 |
}
|
99 |
</style>
|
100 |
""", unsafe_allow_html=True)
|
101 |
|
102 |
-
# Initialiser l'historique de chat
|
103 |
-
if "chat" not in st.session_state:
|
104 |
-
st.session_state.chat = model.start_chat(history=[])
|
105 |
-
|
106 |
# Afficher l'historique des messages
|
107 |
for message in st.session_state.chat.history:
|
108 |
with st.chat_message(role_to_streamlit(message.role)):
|
@@ -116,27 +120,46 @@ for message in st.session_state.chat.history:
|
|
116 |
input_container = st.container()
|
117 |
|
118 |
with input_container:
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
if prompt:
|
141 |
content = [prompt]
|
142 |
temp_files = []
|
|
|
72 |
st.set_page_config(page_title="Mariam - Assistant IA", page_icon="馃")
|
73 |
st.title("Mariam AI - Chat Intelligent")
|
74 |
|
75 |
+
# Initialiser l'historique de chat
|
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>
|
|
|
89 |
gap: 10px;
|
90 |
margin-bottom: 10px;
|
91 |
}
|
92 |
+
.custom-file-upload {
|
93 |
+
display: inline-block;
|
94 |
+
cursor: pointer;
|
95 |
+
}
|
96 |
+
.input-container {
|
97 |
+
display: flex; /* Utiliser flexbox pour aligner les 茅l茅ments */
|
98 |
+
align-items: center; /* Aligner verticalement les 茅l茅ments au centre */
|
99 |
+
gap: 10px; /* Ajouter un espace entre les 茅l茅ments */
|
100 |
}
|
101 |
+
.input-container > div {
|
102 |
+
flex-grow: 1; /* Permettre 脿 la zone de saisie de prendre l'espace disponible */
|
103 |
}
|
104 |
+
.input-container .st-chat-input {
|
105 |
+
flex-grow: 1; /* Permettre 脿 la zone de saisie de prendre l'espace disponible */
|
106 |
}
|
107 |
</style>
|
108 |
""", unsafe_allow_html=True)
|
109 |
|
|
|
|
|
|
|
|
|
110 |
# Afficher l'historique des messages
|
111 |
for message in st.session_state.chat.history:
|
112 |
with st.chat_message(role_to_streamlit(message.role)):
|
|
|
120 |
input_container = st.container()
|
121 |
|
122 |
with input_container:
|
123 |
+
# Utiliser une seule ligne pour la zone de saisie et les boutons
|
124 |
+
prompt = st.chat_input("Que puis-je faire pour vous ?", key="chat_input")
|
125 |
+
|
126 |
+
# Conteneur pour les ic么nes d'upload
|
127 |
+
upload_icons_container = st.container()
|
128 |
+
with upload_icons_container:
|
129 |
+
col1, col2 = st.columns(2) # Colonnes pour les ic么nes d'upload
|
130 |
+
|
131 |
+
with col1:
|
132 |
+
uploaded_files = st.file_uploader("", type=["txt", "mp4", "mp3", "pdf"],
|
133 |
+
accept_multiple_files=True, key="files",
|
134 |
+
label_visibility="collapsed")
|
135 |
+
st.markdown("馃搧", unsafe_allow_html=True)
|
136 |
+
|
137 |
+
with col2:
|
138 |
+
uploaded_images = st.file_uploader("", type=["jpg", "jpeg", "png", "gif"],
|
139 |
+
accept_multiple_files=True, key="images",
|
140 |
+
label_visibility="collapsed")
|
141 |
+
st.markdown("馃摳", unsafe_allow_html=True)
|
142 |
+
|
143 |
+
# Appliquer le style au conteneur
|
144 |
+
st.markdown(f"""
|
145 |
+
<style>
|
146 |
+
div[data-testid='stVerticalBlock']:has(div.uploadedFile) {{
|
147 |
+
flex-direction: row !important;
|
148 |
+
align-items: center;
|
149 |
+
gap: 10px;
|
150 |
+
}}
|
151 |
+
.stVerticalBlock {{
|
152 |
+
gap: 0rem;
|
153 |
+
}}
|
154 |
+
div[data-testid='stHorizontalBlock'] {{
|
155 |
+
align-items: center;
|
156 |
+
}}
|
157 |
+
div[data-testid='stTextInput'] {{
|
158 |
+
padding-bottom: 0;
|
159 |
+
}}
|
160 |
+
</style>
|
161 |
+
""", unsafe_allow_html=True)
|
162 |
+
|
163 |
if prompt:
|
164 |
content = [prompt]
|
165 |
temp_files = []
|