sylvielsstfr
commited on
Commit
·
8a40fd9
1
Parent(s):
71474a5
update
Browse files
app.py
CHANGED
|
@@ -1,26 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
|
| 4 |
-
# Modèle public GPT-2 pour réponses réalistes
|
| 5 |
-
generator = pipeline("text-generation", model="gpt2")
|
| 6 |
|
|
|
|
| 7 |
def respond(message, history):
|
| 8 |
-
# Initialisation de l'historique
|
| 9 |
history = history or []
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
answer = generator(message, max_length=50, do_sample=True)[0]["generated_text"]
|
| 13 |
-
|
| 14 |
# Ajouter la conversation sous forme de liste [user, bot]
|
| 15 |
history.append([message, answer])
|
| 16 |
-
|
| 17 |
-
# Retourner textbox vide + historique pour Gradio 3.43
|
| 18 |
return "", history
|
| 19 |
|
| 20 |
-
#
|
| 21 |
iface = gr.ChatInterface(respond, title="Chat Demo")
|
| 22 |
-
|
| 23 |
-
# Lancer localement
|
| 24 |
iface.launch()
|
| 25 |
|
| 26 |
-
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Réponses factices pour démonstration
|
| 4 |
def respond(message, history):
|
|
|
|
| 5 |
history = history or []
|
| 6 |
+
# Réponse simple basée sur le message
|
| 7 |
+
answer = f"Réponse démo à: {message}"
|
|
|
|
|
|
|
| 8 |
# Ajouter la conversation sous forme de liste [user, bot]
|
| 9 |
history.append([message, answer])
|
|
|
|
|
|
|
| 10 |
return "", history
|
| 11 |
|
| 12 |
+
# Interface Gradio
|
| 13 |
iface = gr.ChatInterface(respond, title="Chat Demo")
|
|
|
|
|
|
|
| 14 |
iface.launch()
|
| 15 |
|
|
|