Add useable demo to test functionality (#1)
Browse files- Add useable demo to test functionality (7e52d7ce69c3ed4cb6ad168876f02e6098ddf4be)
- app.py +1 -1
- functions/chat_functions.py +15 -1
- samples/bank_marketing_campaign.csv +0 -0
app.py
CHANGED
|
@@ -10,4 +10,4 @@ if "OPENAI_API_KEY" not in os.environ:
|
|
| 10 |
os.environ["OPENAI_API_KEY"] = getpass("Enter OpenAI API key:")
|
| 11 |
|
| 12 |
## Uncomment the line below to launch the chat app with UI
|
| 13 |
-
demo.launch(debug=True
|
|
|
|
| 10 |
os.environ["OPENAI_API_KEY"] = getpass("Enter OpenAI API key:")
|
| 11 |
|
| 12 |
## Uncomment the line below to launch the chat app with UI
|
| 13 |
+
demo.launch(debug=True)
|
functions/chat_functions.py
CHANGED
|
@@ -59,12 +59,26 @@ def delete_db(req: gr.Request):
|
|
| 59 |
if os.path.exists(db_file_path):
|
| 60 |
os.remove(db_file_path)
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
with gr.Blocks(css=css) as demo:
|
| 65 |
title = gr.HTML("<h1 style='text-align:center;'>Virtual Data Analyst</h1>")
|
| 66 |
description = gr.HTML("<p style='text-align:center;'>Upload a CSV file and chat with our virtual data analyst to get insights on your data set</p>")
|
|
|
|
|
|
|
| 67 |
file_output = gr.File(label="CSV File", show_label=True, elem_classes="file_marker", file_types=['.csv'])
|
|
|
|
|
|
|
| 68 |
|
| 69 |
@gr.render(inputs=file_output)
|
| 70 |
def data_options(filename, request: gr.Request):
|
|
|
|
| 59 |
if os.path.exists(db_file_path):
|
| 60 |
os.remove(db_file_path)
|
| 61 |
|
| 62 |
+
def run_example(input):
|
| 63 |
+
return input
|
| 64 |
+
|
| 65 |
+
def example_display(input):
|
| 66 |
+
if input == None:
|
| 67 |
+
display = True
|
| 68 |
+
else:
|
| 69 |
+
display = False
|
| 70 |
+
return gr.update(visible=display)
|
| 71 |
+
|
| 72 |
+
css= ".file_marker .large{min-height:50px !important;} .example_btn{max-width:300px;}"
|
| 73 |
|
| 74 |
with gr.Blocks(css=css) as demo:
|
| 75 |
title = gr.HTML("<h1 style='text-align:center;'>Virtual Data Analyst</h1>")
|
| 76 |
description = gr.HTML("<p style='text-align:center;'>Upload a CSV file and chat with our virtual data analyst to get insights on your data set</p>")
|
| 77 |
+
example_file = gr.File(visible=False, value="samples/bank_marketing_campaign.csv")
|
| 78 |
+
example_btn = gr.Button(value="Try Me: bank_marketing_campaign.csv", elem_classes="example_btn", size="md", variant="primary")
|
| 79 |
file_output = gr.File(label="CSV File", show_label=True, elem_classes="file_marker", file_types=['.csv'])
|
| 80 |
+
example_btn.click(fn=run_example, inputs=example_file, outputs=file_output)
|
| 81 |
+
file_output.change(fn=example_display, inputs=file_output, outputs=example_btn)
|
| 82 |
|
| 83 |
@gr.render(inputs=file_output)
|
| 84 |
def data_options(filename, request: gr.Request):
|
samples/bank_marketing_campaign.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|