Salif SAWADOGO
🚀 deploy working version
187c3e9
import gradio as gr
from translation import Translator
def response(message, history, choice):
if choice=="French to Moore":
src_lang ="fra_Latn"
tgt_lang = "moor_Latn"
else:
src_lang ="moor_Latn"
tgt_lang = "fra_Latn"
result = translator.translate(
text=message,
src_lang=src_lang,
tgt_lang=tgt_lang,
)
return result
# Description de l'interface
description = """
Ce chatbot SaChi est une démo d'un modèle NLLB-200-600M fine-tuné pour la traduction entre le français et le mooré.
\nLes données utilisées proviennent de : [MooreFRCollections](https://huggingface.co/datasets/sawadogosalif/MooreFRCollections).
"""
theme = gr.themes.Default(primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.green)
gr_chatbot = gr.Chatbot(avatar_images=["assets/user.jpg", "assets/chatbot.jpg"])
with gr.Blocks(theme=theme, fill_height=True) as demo:
llm_choice = gr.Dropdown(
["French to Moore", "Moore to French"], label="Choix du sens de la traduction", value="French to Moore"
)
interface = gr.ChatInterface(
response,
title="SaChi Demo",
additional_inputs=[llm_choice],
description=description,
chatbot=gr_chatbot
)
if __name__ == "__main__":
translator = Translator()
demo.launch()