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()