disham993's picture
Application file added.
33fbb25
import os, sys
from os.path import dirname as up
sys.path.append(os.path.abspath(os.path.join(up(__file__), os.pardir)))
from utils import *
df = pd.read_csv(CSV_FILE_PATH)
def gradio_interface(helper_function):
def clear_fields(query, output):
return "", ""
with gr.Blocks() as demo:
gr.Markdown("""
<h1> Question and Answer Bot for World Happiness Report 2023 </h1>
Only first 5 rows shown. To check out whole dataset:
https://www.kaggle.com/datasets/ajaypalsinghlo/world-happiness-report-2023
""")
with gr.Row():
with gr.Column():
inputs = [gr.Dataframe(df, row_count=(5, "fixed"), max_rows=5, label="World Happiness Report 2023")]
query = gr.Text(label="Ask question about one or more countries.", placeholder="Type your question here", lines=4)
btn_submit = gr.Button("Submit")
with gr.Column():
output = gr.TextArea(label="Response to the query.", lines=18)
btn_clear = gr.Button("Clear")
btn_submit.click(helper_function, inputs=[query], outputs=[output])
btn_clear.click(clear_fields, inputs=[query, output], outputs=[query, output])
return demo