pip install transformers from transformers import pipeline import gradio as gr pipe_ar = pipeline("question-answering",model='ZeyadAhmed/AraElectra-Arabic-SQuADv2-QA') # arabic model pipe_en = pipeline("question-answering",model='deepset/roberta-base-squad2') # english model def q_a(lang,text,question): if lang == 'Arabic': # if user select arabic myinput = { 'question': question, 'context':text } return pipe_ar(myinput)['answer'] # here will use pipe_ar which is the arabic model and return the answer elif lang == 'English': # user select english myinput = { 'question': question, 'context':text } return pipe_en(myinput)['answer'] #use english model app = gr.Interface( fn= q_a, inputs=[gr.Radio(['Arabic', 'English'], label='Select Language',value= 'Arabic'), # radio bottom for select the language and the defult languses will be arabic gr.Textbox(label = 'enter text',lines=10),# text box to enter the context gr.Textbox(label = 'enter question')],# text box for enter the question outputs=gr.Textbox(label = 'answer')# the output will display here ) app.launch()