Spaces:
Runtime error
Runtime error
File size: 428 Bytes
1a00d25 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import gradio as gr
from transformers import pipeline
# Charger le modèle UNE seule fois
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
def chat(message, history):
# Traduction
translated = translator(message)[0]['translation_text']
# Ajouter au chat
history.append((message, translated))
return history
# Interface chat
demo = gr.ChatInterface(fn=chat)
demo.launch() |