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