from transformers import pipeline import gradio as gr pipe_ar = pipeline("question-answering",model='ZeyadAhmed/AraElectra-Arabic-SQuADv2-QA') pipe_en = pipeline("question-answering",model='deepset/roberta-base-squad2') def q_a(lang,text,question): if lang == 'Arabic': myinput = { 'question': question, 'context':text } return pipe_ar(myinput)['answer'] elif lang == 'English': myinput = { 'question': question, 'context':text } return pipe_en(myinput)['answer'] demo = gr.Interface( fn= q_a, inputs=[gr.Radio(['Arabic', 'English'], label='Select Language',value= 'Arabic'), gr.Textbox(label = 'enter text',lines=10), gr.Textbox(label = 'enter question')], outputs=gr.Textbox(label = 'answer') ) demo.launch()