Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,20 @@ from transformers import pipeline
|
|
3 |
|
4 |
# Titre de l'application
|
5 |
st.set_page_config(page_title="Chatbot AI", page_icon="🤖")
|
6 |
-
st.title("Chatbot AI avec Hugging Face -
|
7 |
|
8 |
# Chargement du modèle
|
9 |
@st.cache_data
|
10 |
def load_model():
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
model = load_model()
|
14 |
|
@@ -18,7 +26,7 @@ user_input = st.text_input("Vous : ", "")
|
|
18 |
|
19 |
if st.button("Envoyer"):
|
20 |
if user_input:
|
21 |
-
with st.spinner("
|
22 |
# Génération de la réponse
|
23 |
response = model(user_input, max_length=100, num_return_sequences=1)
|
24 |
bot_response = response[0]['generated_text']
|
@@ -46,8 +54,6 @@ st.markdown("""
|
|
46 |
""", unsafe_allow_html=True)
|
47 |
|
48 |
|
49 |
-
|
50 |
-
|
51 |
# import streamlit as st
|
52 |
|
53 |
# x = st.slider('Select a value')
|
|
|
3 |
|
4 |
# Titre de l'application
|
5 |
st.set_page_config(page_title="Chatbot AI", page_icon="🤖")
|
6 |
+
st.title("Chatbot AI avec Hugging Face - Mistral AI ou BlenderBot")
|
7 |
|
8 |
# Chargement du modèle
|
9 |
@st.cache_data
|
10 |
def load_model():
|
11 |
+
# Si vous utilisez un modèle Mistral AI, mettez ici le modèle approprié
|
12 |
+
# Exemple de modèle de Mistral ou BlenderBot
|
13 |
+
try:
|
14 |
+
# Modèle Mistral (hypothétique ici, ajustez selon votre modèle Hugging Face)
|
15 |
+
return pipeline("text-generation", model="mistral-ai/mistral-7B", device=0) # Utilisez `device=0` si vous avez un GPU
|
16 |
+
except Exception as e:
|
17 |
+
st.error(f"Erreur de chargement du modèle: {e}")
|
18 |
+
# Modèle de remplacement Blenderbot si Mistral échoue
|
19 |
+
return pipeline("text-generation", model="facebook/blenderbot-400M-distill")
|
20 |
|
21 |
model = load_model()
|
22 |
|
|
|
26 |
|
27 |
if st.button("Envoyer"):
|
28 |
if user_input:
|
29 |
+
with st.spinner("Réflexion de l'IA..."):
|
30 |
# Génération de la réponse
|
31 |
response = model(user_input, max_length=100, num_return_sequences=1)
|
32 |
bot_response = response[0]['generated_text']
|
|
|
54 |
""", unsafe_allow_html=True)
|
55 |
|
56 |
|
|
|
|
|
57 |
# import streamlit as st
|
58 |
|
59 |
# x = st.slider('Select a value')
|