Spaces:
Runtime error
Runtime error
first commit
Browse files- app.py +25 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
# from gradio.components
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def question_answering(question, context):
|
| 7 |
+
# Prepare the payload for the request
|
| 8 |
+
payload = {
|
| 9 |
+
"text": {
|
| 10 |
+
"question": question,
|
| 11 |
+
"context": context
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
# Send the POST request to the API endpoint
|
| 16 |
+
response = requests.post("https://38mr0ftz43.execute-api.ap-south-1.amazonaws.com/default/question_answering", json=payload)
|
| 17 |
+
output = response.json()['output']
|
| 18 |
+
|
| 19 |
+
# Return the response from the API
|
| 20 |
+
return output["answer"]
|
| 21 |
+
|
| 22 |
+
interface = gr.Interface(fn=question_answering, inputs=[gr.inputs.Textbox("question"), gr.inputs.Textbox("context")], outputs=["text"])
|
| 23 |
+
|
| 24 |
+
# Launch the gradio interface
|
| 25 |
+
interface.launch(share= True)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
requests==2.28.2
|