Spaces:
Sleeping
Sleeping
version avec ui
Browse files- app.py +29 -40
- img/avril_logo_rvb.jpg +0 -0
app.py
CHANGED
@@ -1,24 +1,47 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
# Titre de l'application
|
5 |
-
st.set_page_config(page_title="
|
6 |
-
st.title("Chatbot AI avec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Chargement du modèle
|
9 |
@st.cache_data
|
10 |
def load_model():
|
11 |
-
return pipeline("
|
12 |
|
13 |
model = load_model()
|
14 |
|
15 |
# Interface utilisateur
|
16 |
-
st.sidebar.header("
|
17 |
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']
|
@@ -43,38 +66,4 @@ st.markdown("""
|
|
43 |
color: #555;
|
44 |
}
|
45 |
</style>
|
46 |
-
""", unsafe_allow_html=True)
|
47 |
-
|
48 |
-
|
49 |
-
# import streamlit as st
|
50 |
-
|
51 |
-
# x = st.slider('Select a value')
|
52 |
-
# st.write(x, 'squared is', x * x)
|
53 |
-
|
54 |
-
# #test app code de chatgpt
|
55 |
-
# import streamlit as st
|
56 |
-
# import tensorflow
|
57 |
-
# import torch
|
58 |
-
# from transformers import pipeline
|
59 |
-
|
60 |
-
# # Chargement du modèle Hugging Face (GPT-2 ou autre modèle de génération de texte)
|
61 |
-
# generator = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
|
62 |
-
|
63 |
-
# # Fonction pour générer une réponse du chatbot
|
64 |
-
# def chatbot_response(user_input):
|
65 |
-
# response = generator(user_input, max_length=100, num_return_sequences=1)
|
66 |
-
# return response[0]['generated_text']
|
67 |
-
|
68 |
-
# # Interface Streamlit
|
69 |
-
# st.title("Expert en nutrition des volailles de chair et de ponte")
|
70 |
-
|
71 |
-
# # Instructions
|
72 |
-
# st.markdown("### Posez une question à notre expert !")
|
73 |
-
|
74 |
-
# # Entrée utilisateur
|
75 |
-
# user_input = st.text_input("")
|
76 |
-
|
77 |
-
# if user_input:
|
78 |
-
# response = chatbot_response(user_input)
|
79 |
-
# st.write(f"Chatbot : {response}")
|
80 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
|
5 |
# Titre de l'application
|
6 |
+
st.set_page_config(page_title="Expert nutrition volaille", page_icon="🤖")
|
7 |
+
st.title("Chatbot AI avec l'expert nutrition")
|
8 |
+
|
9 |
+
st.sidebar.image("C:/Users/ROMO-ADM1/Documents/9. Avril/SIA Hackathon/poultry_nutritionist/img/avril_logo_rvb.jpg")
|
10 |
+
|
11 |
+
st.sidebar.header("")
|
12 |
+
#Choix production
|
13 |
+
choix_prod = st.sidebar.pills(
|
14 |
+
"Sur quelle espèce voulez-vous avoir des renseignements ?",
|
15 |
+
("Pondeuse", "Chair"),
|
16 |
+
)
|
17 |
+
|
18 |
+
#Niveau vulgarisation
|
19 |
+
choix_vulgarisation = st.sidebar.pills(
|
20 |
+
"Quel niveau de vulgarisation souhaitez-vous ? (1- Très vulgarisé 2-Intermédiaire 3-Technique)",
|
21 |
+
("1", "2", "3"),
|
22 |
+
)
|
23 |
+
|
24 |
+
#Années de publication
|
25 |
+
choix_annee = st.sidebar.slider("Années de publication",
|
26 |
+
min_value=2015,
|
27 |
+
max_value=2025,
|
28 |
+
value=(2020,2025))
|
29 |
+
|
30 |
|
31 |
# Chargement du modèle
|
32 |
@st.cache_data
|
33 |
def load_model():
|
34 |
+
return pipeline("text-generation", model="gpt2")
|
35 |
|
36 |
model = load_model()
|
37 |
|
38 |
# Interface utilisateur
|
39 |
+
st.sidebar.header("")
|
40 |
user_input = st.text_input("Vous : ", "")
|
41 |
|
42 |
if st.button("Envoyer"):
|
43 |
if user_input:
|
44 |
+
with st.spinner("Réflexion de l'IA..."):
|
45 |
# Génération de la réponse
|
46 |
response = model(user_input, max_length=100, num_return_sequences=1)
|
47 |
bot_response = response[0]['generated_text']
|
|
|
66 |
color: #555;
|
67 |
}
|
68 |
</style>
|
69 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img/avril_logo_rvb.jpg
ADDED
![]() |