Spaces:
Runtime error
Runtime error
Update to the reset functionality (#6)
Browse files- Update to the reset functionality (4599b49d9a259ef376ac6afe9eda3d37bbba019c)
Co-authored-by: Disha Verma <[email protected]>
app.py
CHANGED
@@ -179,7 +179,7 @@ def enable_fields(url_status, canvas_api_key_status, submit_status, grade_status
|
|
179 |
def reset_data():
|
180 |
# Use shutil.rmtree() to delete output, docs, and vector_stores folders, reset grader and grader_qa, and get_grading_status, reset and return history
|
181 |
global grader, grader_qa
|
182 |
-
#If there's data in docs/output folder during grading
|
183 |
if os.path.isdir('output') and len(glob.glob("output/*.csv")) > 0 and len(glob.glob("docs/*.json")) > 0 and len(
|
184 |
glob.glob("docs/*.html")) > 0:
|
185 |
reset_folder('output')
|
@@ -187,17 +187,17 @@ def reset_data():
|
|
187 |
grader = None
|
188 |
grader_qa = None
|
189 |
history = [(None, 'Data reset successfully')]
|
190 |
-
return history
|
191 |
-
# If there's data in docs folder
|
192 |
elif len(glob.glob("docs/*.json")) > 0 and len(glob.glob("docs/*.html")):
|
193 |
reset_folder('docs')
|
194 |
history = [(None, 'Data reset successfully')]
|
195 |
-
return history
|
196 |
#If there's data in vector_stores folder
|
197 |
elif len(glob.glob("vector_stores/*.faiss")) > 0 or len(glob.glob("vector_stores/*.pkl")) > 0:
|
198 |
reset_folder('vector_stores')
|
199 |
history = [(None, 'Data reset successfully')]
|
200 |
-
return history
|
201 |
|
202 |
|
203 |
def get_output_dir(orig_name):
|
@@ -256,7 +256,7 @@ with gr.Blocks() as demo:
|
|
256 |
grade = gr.Button(value="Grade", variant="secondary")
|
257 |
download = gr.Button(value="Download", variant="secondary")
|
258 |
file = gr.components.File(label="CSV Output", container=False, visible=False).style(height=100)
|
259 |
-
reset = gr.
|
260 |
|
261 |
chatbot = gr.Chatbot([], label="Chat with grading results", elem_id="chatbot", height=400)
|
262 |
|
@@ -296,7 +296,7 @@ with gr.Blocks() as demo:
|
|
296 |
bot, chatbot, chatbot
|
297 |
)
|
298 |
|
299 |
-
reset.click(reset_data, inputs=[], outputs=[
|
300 |
bot, chatbot, chatbot)
|
301 |
|
302 |
upload.upload(upload_grading_results, inputs=[upload, chatbot], outputs=[chatbot], postprocess=False, ).then(
|
|
|
179 |
def reset_data():
|
180 |
# Use shutil.rmtree() to delete output, docs, and vector_stores folders, reset grader and grader_qa, and get_grading_status, reset and return history
|
181 |
global grader, grader_qa
|
182 |
+
#If there's data in docs/output folder during grading [During Grading]
|
183 |
if os.path.isdir('output') and len(glob.glob("output/*.csv")) > 0 and len(glob.glob("docs/*.json")) > 0 and len(
|
184 |
glob.glob("docs/*.html")) > 0:
|
185 |
reset_folder('output')
|
|
|
187 |
grader = None
|
188 |
grader_qa = None
|
189 |
history = [(None, 'Data reset successfully')]
|
190 |
+
return history, enabled, enabled, enabled, disabled, disabled, disabled
|
191 |
+
# If there's data in docs folder [During Ingestion]
|
192 |
elif len(glob.glob("docs/*.json")) > 0 and len(glob.glob("docs/*.html")):
|
193 |
reset_folder('docs')
|
194 |
history = [(None, 'Data reset successfully')]
|
195 |
+
return history, enabled, enabled, enabled, disabled, disabled, disabled
|
196 |
#If there's data in vector_stores folder
|
197 |
elif len(glob.glob("vector_stores/*.faiss")) > 0 or len(glob.glob("vector_stores/*.pkl")) > 0:
|
198 |
reset_folder('vector_stores')
|
199 |
history = [(None, 'Data reset successfully')]
|
200 |
+
return history, enabled, enabled, enabled, disabled, disabled, disabled
|
201 |
|
202 |
|
203 |
def get_output_dir(orig_name):
|
|
|
256 |
grade = gr.Button(value="Grade", variant="secondary")
|
257 |
download = gr.Button(value="Download", variant="secondary")
|
258 |
file = gr.components.File(label="CSV Output", container=False, visible=False).style(height=100)
|
259 |
+
reset = gr.ClearButton(value="Reset")
|
260 |
|
261 |
chatbot = gr.Chatbot([], label="Chat with grading results", elem_id="chatbot", height=400)
|
262 |
|
|
|
296 |
bot, chatbot, chatbot
|
297 |
)
|
298 |
|
299 |
+
reset.click(reset_data, inputs=[], outputs=[chatbot, url, canvas_api_key, submit, table, grade, download]).success(
|
300 |
bot, chatbot, chatbot)
|
301 |
|
302 |
upload.upload(upload_grading_results, inputs=[upload, chatbot], outputs=[chatbot], postprocess=False, ).then(
|