Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,17 +5,22 @@ import json
|
|
5 |
data = []
|
6 |
|
7 |
# Função para adicionar contextos, perguntas e respostas
|
8 |
-
def add_entry(
|
9 |
global data
|
10 |
entry = {
|
11 |
-
"title": title,
|
12 |
"context": context,
|
13 |
-
"
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
data.append(entry)
|
21 |
return "Entry added!"
|
@@ -31,7 +36,6 @@ def save_to_json():
|
|
31 |
# Interface Gradio
|
32 |
with gr.Blocks() as demo:
|
33 |
with gr.Row():
|
34 |
-
title = gr.Textbox(label="Title")
|
35 |
context = gr.Textbox(lines=5, label="Context")
|
36 |
question = gr.Textbox(lines=2, label="Question")
|
37 |
answer = gr.Textbox(lines=2, label="Answer")
|
|
|
5 |
data = []
|
6 |
|
7 |
# Função para adicionar contextos, perguntas e respostas
|
8 |
+
def add_entry(context, question, answer, answer_start, entry_id):
|
9 |
global data
|
10 |
entry = {
|
|
|
11 |
"context": context,
|
12 |
+
"qas":[
|
13 |
+
{
|
14 |
+
"id": entry_id,
|
15 |
+
"question": question,
|
16 |
+
"answers": [
|
17 |
+
{
|
18 |
+
"text": answer,
|
19 |
+
"answer_start": answer_start
|
20 |
+
}
|
21 |
+
]
|
22 |
+
}
|
23 |
+
]
|
24 |
}
|
25 |
data.append(entry)
|
26 |
return "Entry added!"
|
|
|
36 |
# Interface Gradio
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Row():
|
|
|
39 |
context = gr.Textbox(lines=5, label="Context")
|
40 |
question = gr.Textbox(lines=2, label="Question")
|
41 |
answer = gr.Textbox(lines=2, label="Answer")
|