Spaces:
Runtime error
Runtime error
Download app.py from Skander453/chat: direct link, hf CLI and curl.
- Browser
- Download file 428 Bytes
-
https://huggingface.co/spaces/Skander453/chat/resolve/main/app.py
- Command line
-
hf download hf://spaces/Skander453/chat/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Skander453/chat/resolve/main/app.py
428 Bytes
| 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() |