Spaces:
Sleeping
Sleeping
File size: 2,206 Bytes
8a117ed c6d095e 8a117ed 08fbb23 8a117ed 438c874 8a117ed 08fbb23 8a117ed 63aa460 8a117ed 400d41c 8a117ed 438c874 4cd263c b0f391f 4cd263c b0f391f 8a117ed b0f391f 8a117ed b0f391f 8a117ed b0f391f 8a117ed 1024e7a 8a117ed 1024e7a 8a117ed 1024e7a 8a117ed b0f391f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import streamlit as st
import tensorflow
from transformers import pipeline
# Titre de l'application
st.set_page_config(page_title="Chatbot AI", page_icon="🤖")
st.title("Chatbot AI avec Hugging Face - GPT2")
# Chargement du modèle
@st.cache_data
def load_model():
return pipeline("text-generation", model="gpt2")
model = load_model()
# Interface utilisateur
st.sidebar.header("Options")
user_input = st.text_input("Vous : ", "")
if st.button("Envoyer"):
if user_input:
with st.spinner("Réflexion de l'IA..."):
# Génération de la réponse
response = model(user_input, max_length=100, num_return_sequences=1)
bot_response = response[0]['generated_text']
st.markdown("**Bot :** " + bot_response)
else:
st.warning("Veuillez entrer un message!")
# Styles CSS pour améliorer l'apparence
st.markdown("""
<style>
.st-bx {
background-color: #f1f1f1;
border-radius: 10px;
padding: 10px;
margin: 10px 0;
}
.st-bx h2 {
color: #4CAF50;
}
.st-bx p {
color: #555;
}
</style>
""", unsafe_allow_html=True)
# import streamlit as st
# x = st.slider('Select a value')
# st.write(x, 'squared is', x * x)
# #test app code de chatgpt
# import streamlit as st
# import tensorflow
# import torch
# from transformers import pipeline
# # Chargement du modèle Hugging Face (GPT-2 ou autre modèle de génération de texte)
# generator = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
# # Fonction pour générer une réponse du chatbot
# def chatbot_response(user_input):
# response = generator(user_input, max_length=100, num_return_sequences=1)
# return response[0]['generated_text']
# # Interface Streamlit
# st.title("Expert en nutrition des volailles de chair et de ponte")
# # Instructions
# st.markdown("### Posez une question à notre expert !")
# # Entrée utilisateur
# user_input = st.text_input("")
# if user_input:
# response = chatbot_response(user_input)
# st.write(f"Chatbot : {response}")
|