Spaces:
Runtime error
Runtime error
Update app2.py
Browse files
app2.py
CHANGED
@@ -23,8 +23,10 @@ pipe_tapas = pipeline(
|
|
23 |
|
24 |
|
25 |
def process(query, file, correct_answer, rows=20):
|
26 |
-
table = pd.read_csv(file.name, header=0).astype(str)
|
27 |
-
table = table[:rows]
|
|
|
|
|
28 |
result_tapex = pipe_tapex(table=table, query=query)
|
29 |
result_tapas = pipe_tapas(table=table, query=query)
|
30 |
return result_tapex["answer"], result_tapas["answer"], correct_answer
|
@@ -32,7 +34,8 @@ def process(query, file, correct_answer, rows=20):
|
|
32 |
|
33 |
# Inputs
|
34 |
query_text = gr.Text(label="Enter a question")
|
35 |
-
input_file = gr.File(label="Upload a CSV file", type="file")
|
|
|
36 |
rows_slider = gr.Slider(label="Number of rows")
|
37 |
|
38 |
# Output
|
@@ -54,7 +57,7 @@ iface = gr.Interface(
|
|
54 |
description=description,
|
55 |
layout="vertical",
|
56 |
fn=process,
|
57 |
-
inputs=[query_text,
|
58 |
outputs=[answer_text_tapex, answer_text_tapas],
|
59 |
examples=[
|
60 |
["Which team has the most wins?", "default_file.csv", 20],
|
|
|
23 |
|
24 |
|
25 |
def process(query, file, correct_answer, rows=20):
|
26 |
+
# table = pd.read_csv(file.name, header=0).astype(str)
|
27 |
+
# table = table[:rows]
|
28 |
+
data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]}
|
29 |
+
table = pd.DataFrame.from_dict(data)
|
30 |
result_tapex = pipe_tapex(table=table, query=query)
|
31 |
result_tapas = pipe_tapas(table=table, query=query)
|
32 |
return result_tapex["answer"], result_tapas["answer"], correct_answer
|
|
|
34 |
|
35 |
# Inputs
|
36 |
query_text = gr.Text(label="Enter a question")
|
37 |
+
# input_file = gr.File(label="Upload a CSV file", type="file")
|
38 |
+
input_data = gr.Text(label="Input table json data")
|
39 |
rows_slider = gr.Slider(label="Number of rows")
|
40 |
|
41 |
# Output
|
|
|
57 |
description=description,
|
58 |
layout="vertical",
|
59 |
fn=process,
|
60 |
+
inputs=[query_text, input_data, rows_slider],
|
61 |
outputs=[answer_text_tapex, answer_text_tapas],
|
62 |
examples=[
|
63 |
["Which team has the most wins?", "default_file.csv", 20],
|