File size: 727 Bytes
db7adf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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://flz9hwkah3.execute-api.ap-south-1.amazonaws.com/default/question_answer_huggingface", 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()