Spaces:
Runtime error
Runtime error
Commit
·
2e1ca86
1
Parent(s):
bc958d5
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gradio import CSVLogger
|
3 |
+
from huggingface_hub import Repository as repo
|
4 |
+
import os
|
5 |
+
HF_TOKEN = os.getenv('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')# #'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'
|
6 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "tigo_question_answer")
|
7 |
+
def question_answer(context, question):
|
8 |
+
predictions = model.predict([{"context": context, "qas": [{"question": question, "id": "0",}],}])
|
9 |
+
prediccion = predictions[0][0]['answer'][0]
|
10 |
+
return prediccion
|
11 |
+
iface = gr.Interface(fn=question_answer, inputs=["text", "text"], outputs=["text"],
|
12 |
+
allow_flagging="manual", #manual
|
13 |
+
flagging_options=["correcto", "incorrecto"],
|
14 |
+
flagging_dir='flagged',
|
15 |
+
flagging_callback=hf_writer)
|
16 |
+
iface.launch(enable_queue=True)
|