Spaces:
Running
Running
Florian.Moret
commited on
Commit
·
4cd263c
1
Parent(s):
1024e7a
test_app_gpt2
Browse files
app.py
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
import streamlit as st
|
2 |
|
3 |
-
x = st.slider('Select a value')
|
4 |
-
st.write(x, 'squared is', x * x)
|
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 |
|
|
|
1 |
+
# import streamlit as st
|
2 |
|
3 |
+
# x = st.slider('Select a value')
|
4 |
+
# st.write(x, 'squared is', x * x)
|
5 |
|
6 |
+
#test app code de chatgpt
|
7 |
+
import streamlit as st
|
8 |
+
from transformers import pipeline
|
9 |
|
10 |
+
# Chargement du modèle Hugging Face (GPT-2 ou autre modèle de génération de texte)
|
11 |
+
generator = pipeline('text-generation', model='gpt2')
|
12 |
|
13 |
+
# Fonction pour générer une réponse du chatbot
|
14 |
+
def chatbot_response(user_input):
|
15 |
+
response = generator(user_input, max_length=100, num_return_sequences=1)
|
16 |
+
return response[0]['generated_text']
|
17 |
|
18 |
+
# Interface Streamlit
|
19 |
+
st.title("Chatbot Hugging Face")
|
20 |
|
21 |
+
# Instructions
|
22 |
+
st.markdown("### Posez une question et le chatbot vous répondra !")
|
23 |
|
24 |
+
# Entrée utilisateur
|
25 |
+
user_input = st.text_input("Vous :")
|
26 |
|
27 |
+
if user_input:
|
28 |
+
response = chatbot_response(user_input)
|
29 |
+
st.write(f"Chatbot : {response}")
|
30 |
|