import gradio as gr from transformers import pipeline # Load the model from Hugging Face qa_pipeline = pipeline("question-answering", model="nikhilwani/question_answering") # Define the QA function def answer_question(context, question): result = qa_pipeline(question=question, context=context) return result["answer"] # Create a Gradio app using the new syntax for Gradio 5.5.0 with gr.Blocks() as demo: gr.Markdown("# Question Answering") gr.Markdown("Provide context and ask a question to get an answer.") with gr.Row(): context_input = gr.Textbox(lines=5, placeholder="Enter the context here...", label="Context") question_input = gr.Textbox(placeholder="Ask your question here...", label="Question") with gr.Row(): submit_button = gr.Button("Submit") output_box = gr.Textbox(label="Answer") # Connect the function to the components submit_button.click(answer_question, inputs=[context_input, question_input], outputs=output_box) # Launch the app demo.launch()