import gradio as gr import requests # from gradio.components def question_answering(question, context): # Prepare the payload for the request payload = { "text": { "question": question, "context": context } } # Send the POST request to the API endpoint response = requests.post("https://38mr0ftz43.execute-api.ap-south-1.amazonaws.com/default/question_answering", json=payload) output = response.json()['output'] # Return the response from the API return output["answer"] interface = gr.Interface(fn=question_answering, inputs=[gr.inputs.Textbox("question"), gr.inputs.Textbox("context")], outputs=["text"]) # Launch the gradio interface interface.launch()