Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
# Titre de l'application | |
st.set_page_config(page_title="Expert nutrition volaille", page_icon="🤖") | |
st.title("Chatbot AI avec l'expert nutrition") | |
st.sidebar.image("C:/Users/ROMO-ADM1/Documents/9. Avril/SIA Hackathon/poultry_nutritionist/img/avril_logo_rvb.jpg") | |
st.sidebar.header("") | |
#Choix production | |
choix_prod = st.sidebar.pills( | |
"Sur quelle espèce voulez-vous avoir des renseignements ?", | |
("Pondeuse", "Chair"), | |
) | |
#Niveau vulgarisation | |
choix_vulgarisation = st.sidebar.pills( | |
"Quel niveau de vulgarisation souhaitez-vous ? (1- Très vulgarisé 2-Intermédiaire 3-Technique)", | |
("1", "2", "3"), | |
) | |
#Années de publication | |
choix_annee = st.sidebar.slider("Années de publication", | |
min_value=2015, | |
max_value=2025, | |
value=(2020,2025)) | |
# Chargement du modèle | |
def load_model(): | |
return pipeline("text-generation", model="gpt2") | |
model = load_model() | |
# Interface utilisateur | |
st.sidebar.header("") | |
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) |