Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -34,7 +34,12 @@ def add_query(category, query, positive1, positive2, negative1, negative2):
|
|
| 34 |
with open(DATA_FILE, "w") as file:
|
| 35 |
json.dump(stored_data, file, indent=4)
|
| 36 |
|
| 37 |
-
return f"Added query: {query} under category '{category}' with responses."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# Gradio UI
|
| 40 |
with gr.Blocks() as app:
|
|
@@ -59,7 +64,10 @@ with gr.Blocks() as app:
|
|
| 59 |
outputs=status_output
|
| 60 |
)
|
| 61 |
|
| 62 |
-
gr.Markdown("### Download Stored Queries:")
|
| 63 |
-
download_button = gr.
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
app.launch()
|
|
|
|
| 34 |
with open(DATA_FILE, "w") as file:
|
| 35 |
json.dump(stored_data, file, indent=4)
|
| 36 |
|
| 37 |
+
return f"✅ Added query: {query} under category '{category}' with responses."
|
| 38 |
+
|
| 39 |
+
# Function to serve the updated JSON file for download
|
| 40 |
+
def download_json():
|
| 41 |
+
with open(DATA_FILE, "r") as file:
|
| 42 |
+
return file.read()
|
| 43 |
|
| 44 |
# Gradio UI
|
| 45 |
with gr.Blocks() as app:
|
|
|
|
| 64 |
outputs=status_output
|
| 65 |
)
|
| 66 |
|
| 67 |
+
gr.Markdown("### Save & Download Stored Queries:")
|
| 68 |
+
download_button = gr.Button("Download JSON")
|
| 69 |
+
download_output = gr.File(label="Download File")
|
| 70 |
+
|
| 71 |
+
download_button.click(download_json, outputs=download_output)
|
| 72 |
|
| 73 |
app.launch()
|